(
params: web::Form<CreateForm>,
pool: web::Data<SqlitePool>,
session: Session,
)
| 44 | } |
| 45 | |
| 46 | pub async fn create( |
| 47 | params: web::Form<CreateForm>, |
| 48 | pool: web::Data<SqlitePool>, |
| 49 | session: Session, |
| 50 | ) -> Result<impl Responder, Error> { |
| 51 | if params.description.is_empty() { |
| 52 | session::set_flash(&session, FlashMessage::error("Description cannot be empty"))?; |
| 53 | Ok(web::Redirect::to("/").using_status_code(StatusCode::FOUND)) |
| 54 | } else { |
| 55 | db::create_task(params.into_inner().description, &pool) |
| 56 | .await |
| 57 | .map_err(error::ErrorInternalServerError)?; |
| 58 | |
| 59 | session::set_flash(&session, FlashMessage::success("Task successfully added"))?; |
| 60 | |
| 61 | Ok(web::Redirect::to("/").using_status_code(StatusCode::FOUND)) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | #[derive(Debug, Deserialize)] |
| 66 | pub struct UpdateParams { |
no test coverage detected