mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-24 17:11:49 +00:00
feat: parent mutation
This commit is contained in:
parent
8b3305dae7
commit
2833d9850b
2 changed files with 38 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
pub struct Mutation;
|
pub struct Mutation;
|
||||||
|
|
||||||
pub mod session;
|
pub mod session;
|
||||||
pub mod candidate;
|
pub mod candidate;
|
||||||
|
pub mod parent;
|
||||||
36
core/src/database/mutation/parent.rs
Normal file
36
core/src/database/mutation/parent.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
use crate::Mutation;
|
||||||
|
|
||||||
|
use ::entity::parent::{self, Model};
|
||||||
|
use sea_orm::*;
|
||||||
|
|
||||||
|
impl Mutation {
|
||||||
|
pub async fn create_parent(db: &DbConn, application_id: i32) -> Result<Model, DbErr> {
|
||||||
|
parent::ActiveModel {
|
||||||
|
application: Set(application_id),
|
||||||
|
created_at: Set(chrono::offset::Local::now().naive_local()),
|
||||||
|
updated_at: Set(chrono::offset::Local::now().naive_local()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.insert(db)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn add_parent_details(
|
||||||
|
db: &DbConn,
|
||||||
|
user: Model,
|
||||||
|
name: String,
|
||||||
|
surname: String,
|
||||||
|
telephone: String,
|
||||||
|
email: String,
|
||||||
|
) -> Result<Model, sea_orm::DbErr> {
|
||||||
|
let mut user: parent::ActiveModel = user.into();
|
||||||
|
user.name = Set(Some(name));
|
||||||
|
user.surname = Set(Some(surname));
|
||||||
|
user.telephone = Set(Some(telephone));
|
||||||
|
user.email = Set(Some(email));
|
||||||
|
|
||||||
|
user.updated_at = Set(chrono::offset::Local::now().naive_local());
|
||||||
|
|
||||||
|
user.update(db).await
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue