public async Task <ActionResult> Edit(Guid id, EditVatCategoryViewModel request) { if (!ModelState.IsValid) { Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } if (!id.Equals(request.Id)) { Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } try { var vatCategoryUpdateRequest = new UpdateVatCategoryRequest { Id = request.Id, Name = request.Name, Description = request.Description }; var result = await _vatCategoryService.Update(id, vatCategoryUpdateRequest); if (!result.Success) { Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } Alert($"Vat Category Updated Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Index))); } catch { Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } }
// GET: VatCategory/Edit/5 public async Task <ActionResult> Edit(Guid id) { var vatCategory = new EditVatCategoryViewModel(); try { var result = await _vatCategoryService.FindById(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(vatCategory)); } vatCategory.Id = result.Data.Id; vatCategory.Name = result.Data.Name; vatCategory.Description = result.Data.Description; return(View(vatCategory)); } catch (Exception ex) { Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(vatCategory)); } }