コード例 #1
0
        public async Task <ActionResult> EditPromotionDiscountItem(Guid id, EditPromotionDiscountItemViewModel 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 promotionDiscountEditRequest = new UpdatePromotionDiscountItemRequest {
                    Id = request.Id, PromotionDiscountId = request.PromotionDiscountId, ParentProductQuantity = request.ParentProductQuantity, DiscountRate = request.DiscountRate, FreeOfChargeQuantity = request.FreeOfChargeQuantity, EffectiveDate = request.EffectiveDate, EndDate = request.EndDate
                };
                var result = await _promotionDiscountItemService.Update(id, promotionDiscountEditRequest);

                if (!result.Success)
                {
                    Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }

                Alert($"Discount Details Updated Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(PromotionDiscountItemDetails), new { id = request.PromotionDiscountId }));
            }
            catch
            {
                Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
        }
コード例 #2
0
        public async Task <ActionResult> EditPromotionDiscountItem(Guid id)
        {
            var promotionDiscountItem = new EditPromotionDiscountItemViewModel();

            try
            {
                var result = await _promotionDiscountItemService.FindByIdInclusive(id, x => x.Include(p => p.PromotionDiscount));

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View(promotionDiscountItem));
                }
                promotionDiscountItem.Id = result.Data.Id;
                promotionDiscountItem.ParentProductQuantity = result.Data.ParentProductQuantity;
                promotionDiscountItem.FreeOfChargeQuantity  = result.Data.FreeOfChargeQuantity;
                promotionDiscountItem.EffectiveDate         = result.Data.EffectiveDate;
                promotionDiscountItem.EndDate             = result.Data.EndDate;
                promotionDiscountItem.DiscountRate        = result.Data.DiscountRate;
                promotionDiscountItem.PromotionDiscountId = result.Data.PromotionDiscount.Id;
                return(View(promotionDiscountItem));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(promotionDiscountItem));
            }
        }