public IHttpActionResult PostDiscount(DiscountSummaryModel discount)

        {
            DiscountSummary model = new DiscountSummary();

            model.DiscountType   = discount.DiscountType;
            model.DiscountValue  = discount.DiscountValue;
            model.FromDate       = Convert.ToDateTime(discount.FromDate);
            model.ToDate         = Convert.ToDateTime(discount.ToDate);
            model.FromProductSKU = discount.FromProductSKU;
            model.ToProductSKU   = discount.ToProductSKU;
            model.FromStyleSKU   = discount.FromStyleSKU;
            model.ToStyleSKU     = discount.ToStyleSKU;
            model.FromPrice      = discount.FromPrice;
            model.ToPrice        = discount.ToPrice;
            model.IsActive       = true;
            if (discount.ProductList != null)
            {
                model.PromotionalDiscounts = discount.ProductList.Select(x => new PromotionalDiscount
                {
                    ProductID = Convert.ToInt16(x),
                    IsActive  = true,
                }).ToList();
            }
            try
            {
                db.DiscountSummaries.Add(model);
                db.SaveChanges();
            }
            catch (Exception ex) { }
            return(Ok(model));
        }
Beispiel #2
0
        public ActionResult GetProductList(DiscountSummaryModel discount)
        {
            var list = Services.DiscountService.Create(discount);

            return(View(list));
        }
Beispiel #3
0
        public DiscountSummaryModel Create(DiscountSummaryModel discount)
        {
            var list2   = new List <ProductModel>();
            var intList = new List <int>();
            var list    = new List <ProductModel>();
            var x       = Convert.ToInt32(discount.FromProductSKU);
            var y       = Convert.ToInt32(discount.ToProductSKU);

            for (var i = x; i <= y; i++)
            {
                var str = "";
                if (i < 10)
                {
                    str = "00" + i;
                }
                else if (i < 100)
                {
                    str = "0" + i;
                }
                else
                {
                    str = "" + i;
                }
                var ProductList = ServerResponse.Invoke <List <ProductModel> >("api/product/getByProductSKU?productSku=" + str, "", "GET");
                list.AddRange(ProductList);
            }
            var style1 = Convert.ToInt32(discount.FromStyleSKU);
            var style2 = Convert.ToInt32(discount.ToStyleSKU);

            for (int j = style1; j <= style2; j++)
            {
                var str1 = "";
                if (j < 10)
                {
                    str1 = "000" + j;
                }
                else if (j < 100)
                {
                    str1 = "00" + j;
                }
                else if (j < 1000)
                {
                    str1 = "0" + j;
                }
                else
                {
                    str1 = "" + j;
                }
                var listFF = list.Where(m => m.StyleSKU.Contains(str1)).ToList();
                list2.AddRange(listFF);
            }
            if (discount.FromPrice != null && discount.ToPrice != null)
            {
                list2 = list2.Where(ym => Convert.ToDecimal(ym.CostPrice) >= Convert.ToDecimal(discount.FromPrice) && Convert.ToDecimal(ym.CostPrice) <= Convert.ToDecimal(discount.ToPrice)).ToList();
            }
            foreach (var item in list2)
            {
                var id = item.Id;
                intList.Add(id);
            }
            string[] value = intList.Select(i => i.ToString()).ToArray();
            discount.ProductList = value;;
            var create = ServerResponse.Invoke <DiscountSummaryModel>("api/discount/create", JsonConvert.SerializeObject(discount), "POST");

            return(create);
        }
Beispiel #4
0
 public bool Delete(DiscountSummaryModel model)
 {
     return(ServerResponse.Invoke <bool>("api/discountSummary/delete", JsonConvert.SerializeObject(model), "POST"));
 }
        public JsonResult Create(DiscountSummaryModel discount)
        {
            var PromotionlDiscountList = Services.DiscountService.Create(discount);

            return(Json(PromotionlDiscountList, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteConfirmed(DiscountSummaryModel model)
        {
            bool status = Services.DiscountService.Delete(model);

            return(RedirectToAction("Index", "Discount"));
        }