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()); } }
public JavaScriptResult Edit(VatCategoryViewModel vatCategoryVm) { try { _vatCategoryService.Update(Mapper.Map <VatCategory>(vatCategoryVm)); return(JavaScript($"ShowResult('{"Data updated successfully."}','{"success"}','{"redirect"}','{"/VATCategory"}')")); } catch (Exception ex) { return(JavaScript($"ShowResult('{ex.Message}','failure')")); } }