Exemplo n.º 1
0
        // GET: VatCategory/Details/5
        public async Task <ActionResult> Details(Guid id)
        {
            var vatCategory = new VatCategoryDetailsViewModel();

            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.Code            = result.Data.Code;
                vatCategory.Id              = result.Data.Id;
                vatCategory.Name            = result.Data.Name;
                vatCategory.Description     = result.Data.Description;
                vatCategory.DateCreated     = result.Data.CreatedAt;
                vatCategory.DateLastUpdated = result.Data.LastUpdated;
                return(View(vatCategory));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(vatCategory));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Delete(Guid id, VatCategoryDetailsViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert("Bad Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            if (id == null)
            {
                Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            try
            {
                var result = await _vatCategoryService.Delete(id);

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }
                Alert($"Vat Category Deleted 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());
            }
        }