public async Task <ActionResult> CreateVat(AddVatViewModel request) { if (!ModelState.IsValid) { Alert($"Invalid Request.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } try { var addVatRequest = new AddVatRequest { VatCategoryId = request.VatCategoryId, Rate = request.Rate, EffectiveDate = request.EffectiveDate, EndDate = request.EndDate }; var result = await _vatService.Create(addVatRequest); if (!result.Success) { Alert($"{result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } Alert($"Vat Created Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } catch (Exception ex) { Alert($"Error! {ex.Message}.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } }
public ActionResult CreateVat(Guid vatCategoryId, string vatCategoryName) { var vat = new AddVatViewModel { VatCategoryId = vatCategoryId }; ViewBag.vatCategoryName = vatCategoryName; return(View(vat)); }