async fn update(
    db: Data<PgPool>,
    auth: TokenUser,
    path: web::Path<JigId>,
    req: Json<<module::Update as ApiEndpoint>::Req>,
) -> Result<HttpResponse, error::NotFound> {
    let parent_id = path.into_inner();

    db::jig::authz(&*db, auth.0.user_id, Some(parent_id)).await?;

    let req = req.into_inner();

    let exists = db::jig::module::update(
        &*db,
        parent_id,
        req.id,
        req.body.as_ref(),
        req.index,
        req.is_complete,
    )
    .await?;

    if !exists {
        return Err(error::NotFound::ResourceNotFound);
    }

    Ok(HttpResponse::NoContent().finish())
}
/// Update a module in a draft JIG.
Update a module in a draft JIG.
Update a module in a draft JIG .
async fn update(
    db: Data<PgPool>,
    auth: TokenUser,
    path: web::Path<JigId>,
    req: Json<<module::Update as ApiEndpoint>::Req>,
) -> Result<HttpResponse, error::NotFound> {
    let parent_id = path.into_inner();
    db::jig::authz(&*db, auth.0.user_id, Some(parent_id)).await?;
    let req = req.into_inner();
    let exists = db::jig::module::update(
        &*db,
        parent_id,
        req.id,
        req.body.as_ref(),
        req.index,
        req.is_complete,
    )
    .await?;
    if !exists {
        return Err(error::NotFound::ResourceNotFound);
    }
    Ok(HttpResponse::NoContent().finish())
}
async fn update ( db : Data < PgPool > , auth : TokenUser , path : web :: Path < JigId > , req : Json < < module :: Update as ApiEndpoint > :: Req > , ) -> Result < HttpResponse , error :: NotFound > { let parent_id = path . into_inner ( ) ; db :: jig :: authz ( & * db , auth . 0 . user_id , Some ( parent_id ) ) . await ? ; let req = req . into_inner ( ) ; let exists = db :: jig :: module :: update ( & * db , parent_id , req . id , req . body . as_ref ( ) , req . index , req . is_complete , ) . await ? ; if ! exists { return Err ( error :: NotFound :: ResourceNotFound ) ; } Ok ( HttpResponse :: NoContent ( ) . finish ( ) ) }
Update a module in a draft JIG.
Update a module in a draft JIG .
db
Data<PgPool>
auth
TokenUser
path
web::Path<JigId>
req
Json<<module::Update as ApiEndpoint>::Req>
db
Data<PgPool>
auth
TokenUser
path
web::Path<JigId>
req
Json<<module::Update as ApiEndpoint>::Req>