public async Task <ActionResult> DeleteVat(Guid id, VatDetailsViewModel request) { if (!ModelState.IsValid) { Alert("Bad Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } if (id == null) { Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } try { var result = await _vatService.Delete(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } Alert($"Vat Deleted Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } catch { Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(Vats), new { id = request.VatCategoryId })); } }
public async Task <ActionResult> DeleteVat(Guid id) { if (id == null) { Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } var vat = new VatDetailsViewModel(); try { var result = await _vatService.FindByIdInclusive(id, x => x.Include(p => p.VatCategory)); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(vat)); } vat.Rate = result.Data.Rate; vat.Id = result.Data.Id; vat.EffectiveDate = result.Data.EffectiveDate; vat.EndDate = result.Data.EndDate; vat.DateCreated = result.Data.CreatedAt; vat.DateLastUpdated = result.Data.LastUpdated; vat.VatCategoryName = result.Data.VatCategory.Name; vat.VatCategoryId = result.Data.VatCategory.Id; return(View(vat)); } catch (Exception ex) { Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(vat)); } }
// GET: VATs/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VAT vAT = db.VATs.Find(id); if (vAT == null) { return(HttpNotFound()); } VatDetailsViewModel vdvm = new VatDetailsViewModel(); vdvm.VATPercId = vAT.VATPercId; vdvm.VATValue = vAT.VATValue; return(View(vdvm)); }