Exemple #1
0
        // GET: SaleValueDiscount/Details/5
        public async Task <ActionResult> Details(Guid id)
        {
            var saleValueDiscount = new SaleValueDiscountDetailsViewModel();

            try
            {
                var result = await _saleValueDiscountService.FindById(id);

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View(saleValueDiscount));
                }
                saleValueDiscount.Code            = result.Data.Code;
                saleValueDiscount.Id              = result.Data.Id;
                saleValueDiscount.TierId          = result.Data.TierId;
                saleValueDiscount.Description     = result.Data.Description;
                saleValueDiscount.DateCreated     = result.Data.CreatedAt;
                saleValueDiscount.DateLastUpdated = result.Data.LastUpdated;
                return(View(saleValueDiscount));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(saleValueDiscount));
            }
        }
Exemple #2
0
        public async Task <ActionResult> Delete(Guid id, SaleValueDiscountDetailsViewModel 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 _saleValueDiscountService.Delete(id);

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