Can update couple information
This commit is contained in:
@ -130,3 +130,17 @@ pub async fn get_all(m: FamilyInPath) -> HttpResult {
|
||||
pub async fn get_single(m: FamilyAndCoupleInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(CoupleAPI::new(m.to_couple())))
|
||||
}
|
||||
|
||||
/// Update a couple information
|
||||
pub async fn update(m: FamilyAndCoupleInPath, req: web::Json<CoupleRequest>) -> HttpResult {
|
||||
let mut couple = m.to_couple();
|
||||
|
||||
if let Err(e) = req.0.to_couple(&mut couple).await {
|
||||
log::error!("Failed to parse couple information {e}!");
|
||||
return Ok(HttpResponse::BadRequest().body(e.to_string()));
|
||||
}
|
||||
|
||||
couples_service::update(&mut couple).await?;
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
Reference in New Issue
Block a user