Exemple #1
0
        public ActionResult AddToPromo([Bind(Include = "id, internal_code_1")] Product product)
        {
            //if (id == null)
            //{
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //}
            //int id = 1;
            int id_product = product.id;

            if (ModelState.IsValid)
            {
                PromotionsDetail promotionsDetail = new PromotionsDetail();
                promotionsDetail.discount_off = 0;
                promotionsDetail.discount_on  = 0;
                promotionsDetail.edlp         = 0;
                promotionsDetail.product_id   = 1;
                promotionsDetail.promotion_id = 1;
                promotionsDetail.te_off       = 0;
                promotionsDetail.te_on        = 0;
                promotionsDetail.volume       = 0;

                db.PromotionsDetails.Add(promotionsDetail);
                db.SaveChanges();
                //return RedirectToAction("Index");
            }

            return(RedirectToAction("AddToPromo"));

            //ViewBag.product_id = new SelectList(db.Products, "id", "internal_code_1", promotionsDetail.product_id);
            //ViewBag.promotion_id = new SelectList(db.Promotions, "id", "promo_name", promotionsDetail.promotion_id);
            //return View(promotionsDetail);
            //var products = db.Products.Include(p => p.PromoGroup);
            //return View(products.ToList());
        }
        //------

        public ActionResult DeleteItem(int id, int promoid)
        {
            PromotionsDetail promotionsDetail = db.PromotionsDetails.Find(id);

            db.PromotionsDetails.Remove(promotionsDetail);
            db.SaveChanges();
            return(RedirectToAction("Edit", new { id = promoid }));
        }
Exemple #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            PromotionsDetail promotionsDetail = db.PromotionsDetails.Find(id);

            db.PromotionsDetails.Remove(promotionsDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public PartialViewResult AddProducts(int?id, FormCollection form)
        {
            var getsegmentlist = db.Segments.ToList();

            getsegmentlist.Insert(0, new Segment {
                name = "All", id = 0
            });
            SelectList list_segment = new SelectList(getsegmentlist, "id", "name");

            ViewBag.SegmentListName = list_segment;
            ViewBag.Id = id;

            int intDDL_Segment = 0;

            if (form["SegmentList"] != null)
            {
                intDDL_Segment = Convert.ToInt32(form["SegmentList"].ToString());
            }



            var promotion = db.Promotions.Find(id);
            var pds       = new List <PromotionsDetail>();

            if (intDDL_Segment == 0)
            {
                foreach (var item in db.Products)
                {
                    PromotionsDetail pd = new PromotionsDetail();
                    pd.product_id   = item.id;
                    pd.Product      = item;
                    pd.Promotion    = promotion;
                    pd.promotion_id = promotion.id;
                    pds.Add(pd);
                }
            }
            else
            {
                foreach (var item in db.Products)
                {
                    if (item.PromoGroup.segment_id == intDDL_Segment)
                    {
                        PromotionsDetail pd = new PromotionsDetail();
                        pd.product_id   = item.id;
                        pd.Product      = item;
                        pd.Promotion    = promotion;
                        pd.promotion_id = promotion.id;
                        pds.Add(pd);
                    }
                }
            }


            return(PartialView(pds.ToList()));
        }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "id,product_id,promotion_id,volume,discount_on,discount_off")] PromotionsDetail promotionsDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(promotionsDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.product_id   = new SelectList(db.Products, "id", "internal_code_1", promotionsDetail.product_id);
     ViewBag.promotion_id = new SelectList(db.Promotions, "id", "promo_name", promotionsDetail.promotion_id);
     return(View(promotionsDetail));
 }
Exemple #6
0
        // GET: PromotionsDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PromotionsDetail promotionsDetail = db.PromotionsDetails.Find(id);

            if (promotionsDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(promotionsDetail));
        }
Exemple #7
0
        // GET: PromotionsDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PromotionsDetail promotionsDetail = db.PromotionsDetails.Find(id);

            if (promotionsDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.product_id   = new SelectList(db.Products, "id", "internal_code_1", promotionsDetail.product_id);
            ViewBag.promotion_id = new SelectList(db.Promotions, "id", "promo_name", promotionsDetail.promotion_id);
            return(View(promotionsDetail));
        }
        //public class ProductRequest
        //{
        //    public string[] Params { get; set; }
        //    public int Id { get; set; }
        //}


        public ActionResult AddProduct(int?id, int pid)
        {
            //foreach (var item in checkbox)
            //{
            //    products.Add(db.Products.Find(item));
            //}
            var promotion            = db.Promotions.Find(id);
            PromotionsDetail detail  = new PromotionsDetail();
            Product          product = db.Products.Find(pid);

            detail.Product      = product;
            detail.product_id   = product.id;
            detail.promotion_id = promotion.id;
            db.PromotionsDetails.Add(detail);
            promotion.PromotionsDetails.Add(detail);
            id = promotion.id;
            db.SaveChanges();
            return(RedirectToAction("Edit", "Promotions", new { id }));
        }
Exemple #9
0
        public ActionResult AddToPromo2(int id)
        {
            if (ModelState.IsValid)
            {
                PromotionsDetail promotionsDetail = new PromotionsDetail();
                promotionsDetail.discount_off = 0;
                promotionsDetail.discount_on  = 0;
                promotionsDetail.edlp         = 0;
                promotionsDetail.product_id   = id;
                promotionsDetail.promotion_id = 1;
                promotionsDetail.te_off       = 0;
                promotionsDetail.te_on        = 0;
                promotionsDetail.volume       = 0;

                db.PromotionsDetails.Add(promotionsDetail);
                db.SaveChanges();
            }



            return(RedirectToAction("AddToPromo"));
        }
Exemple #10
0
 public ActionResult TestEdit([Bind(Include = "id,promostatus_id,shipment_from,shipment_to,active_from,active_to,promo_name,customer_id,edit_date,note,week1,week2,week3,week4,leaflet_fee,secondaryplacement_fee,promotype_id")] Promotion promotion, [Bind(Include = "id,product_id,promotion_id,volume,discount_on,discount_off")] PromotionsDetail promotionsDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(promotion).State        = EntityState.Modified;
         db.Entry(promotionsDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customer_id    = new SelectList(db.Customers, "id", "name", promotion.customer_id);
     ViewBag.promostatus_id = new SelectList(db.PromotionsStatuses, "id", "name", promotion.promostatus_id);
     ViewBag.promotype_id   = new SelectList(db.PromotionsTypes, "id", "name", promotion.promotype_id);
     return(View(promotion));
 }