public async Task <ActionResult> Edit(int Id, Movement movement) { if (ModelState.IsValid && Id.Equals(movement.Id)) { try { await _service.Update(movement); return(RedirectToAction(nameof(Index))); } catch (ModelValidationException e) { ModelState.AddModelError("MovementValidation", e.Message); return(View(await GetViewModel(movement))); } catch (NotFoundException e) { TempData["ErrorMessage"] = e.Message; return(new HttpStatusCodeResult(HttpStatusCode.NotFound, e.Message)); } catch (DbUpdateException e) { TempData["ErrorMessage"] = e.Message; return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, e.Message)); } } else { return(View(await GetViewModel(movement))); } }
public IHttpActionResult UpdateMovement(Movement obj) { try { _service.Update(obj); return(Ok()); } catch (ApplicationException e) { return(BadRequest(e.Message)); } }