public ActionResult AddnewProductinbundle(BundlePriceDetailsitemVm bundlePriceDetailsitemVm)
        {
            if (ModelState.IsValid)
            {
                tbld_bundle_price_details tbldBundlePriceDetails = new tbld_bundle_price_details
                {
                    quantity             = bundlePriceDetailsitemVm.Quantity,
                    batch_id             = bundlePriceDetailsitemVm.BatchId,
                    bundle_price_id      = bundlePriceDetailsitemVm.BundlePriceId,
                    sku_id               = bundlePriceDetailsitemVm.SkuId,
                    db_lifting_price     = bundlePriceDetailsitemVm.DbLiftingPrice,
                    outlet_lifting_price = bundlePriceDetailsitemVm.OutletLiftingPrice,
                    mrp        = bundlePriceDetailsitemVm.Mrp,
                    start_date = bundlePriceDetailsitemVm.StartDate,
                    end_date   = bundlePriceDetailsitemVm.EndDate,
                    status     = bundlePriceDetailsitemVm.Status
                };
                Db.tbld_bundle_price_details.Add(tbldBundlePriceDetails);
                Db.SaveChanges();

                return(Json("Save", JsonRequestBehavior.AllowGet));
                //return Redirect("/BundlePrice/Details/"+BundlePriceDetailsitemVM.bundle_price_id);
            }

            return(Json("Error", JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        // GET: BundlePriceDetails/Details/5
        public ActionResult Details(int?id)
        {
            tbld_bundle_price_details tbldBundlePriceDetails = _db.tbld_bundle_price_details.Find(id);

            if (tbldBundlePriceDetails == null)
            {
                return(HttpNotFound());
            }

            var firstOrDefault = _db.tbld_SKU.SingleOrDefault(x => x.SKU_id == tbldBundlePriceDetails.sku_id);

            if (firstOrDefault != null)
            {
                BundlePriceindexitemVm bundlePriceindexitemVm = new BundlePriceindexitemVm
                {
                    Id            = tbldBundlePriceDetails.id,
                    BundlePriceId = tbldBundlePriceDetails.bundle_price_id,
                    SkuName       = firstOrDefault.SKUName,
                    BatchId       = tbldBundlePriceDetails.batch_id,
                    DbPrice       = tbldBundlePriceDetails.db_lifting_price,
                    OutletPrice   = tbldBundlePriceDetails.outlet_lifting_price,
                    Mrp           = tbldBundlePriceDetails.mrp,
                    StartDate     = tbldBundlePriceDetails.start_date,
                    EndDate       = tbldBundlePriceDetails.end_date,
                    Status        = tbldBundlePriceDetails.status == 1 ? "Active" : "InActive "
                };

                return(View(bundlePriceindexitemVm));
            }
            return(null);
        }
예제 #3
0
 public ActionResult Edit(tbld_bundle_price_details tbldBundlePriceDetails)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(tbldBundlePriceDetails).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Details", "BundlePrice", new{ id = tbldBundlePriceDetails.bundle_price_id }));
     }
     ViewBag.IsActive = new SelectList(_db.status.ToList(), "status_Id", "status_code");
     return(View(tbldBundlePriceDetails));
 }
        public ActionResult Addnewproductprice(BundlePriceDetailsitemVm bundlePriceDetailsitemVm)
        {
            var bundlePriceDetails = Db.tbld_bundle_price_details.OrderByDescending(u => u.id).FirstOrDefault(x => x.sku_id == bundlePriceDetailsitemVm.SkuId);

            if (bundlePriceDetails != null)
            {
                int batchId = bundlePriceDetails.batch_id;

                //need previous betch inactive

                if (ModelState.IsValid)
                {
                    tbld_bundle_price_details tbldBundlePriceDetails = new tbld_bundle_price_details
                    {
                        quantity             = bundlePriceDetailsitemVm.Quantity,
                        batch_id             = batchId + 1,
                        bundle_price_id      = bundlePriceDetailsitemVm.BundlePriceId,
                        sku_id               = bundlePriceDetailsitemVm.SkuId,
                        db_lifting_price     = bundlePriceDetailsitemVm.DbLiftingPrice,
                        outlet_lifting_price = bundlePriceDetailsitemVm.OutletLiftingPrice,
                        mrp        = bundlePriceDetailsitemVm.Mrp,
                        start_date = bundlePriceDetailsitemVm.StartDate,
                        end_date   = bundlePriceDetailsitemVm.EndDate,
                        status     = bundlePriceDetailsitemVm.Status
                    };

                    Db.tbld_bundle_price_details.Add(tbldBundlePriceDetails);

                    Db.tbld_bundle_price_details.Where(x => x.batch_id == batchId - 1 && x.sku_id == bundlePriceDetailsitemVm.SkuId && x.status != 2).ToList().ForEach(x =>
                    {
                        x.status   = 2;
                        x.end_date = DateTime.Now;
                    });

                    Db.SaveChanges();
                    return(Json("Save", JsonRequestBehavior.AllowGet));
                    //return Redirect("/BundlePrice/Details/"+BundlePriceDetailsitemVM.bundle_price_id);
                }
            }


            return(Json("Error", JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        // GET: BundlePriceDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbld_bundle_price_details tbldBundlePriceDetails = _db.tbld_bundle_price_details.Find(id);
            var skuName = _db.tbld_SKU.SingleOrDefault(x => x.SKU_id == tbldBundlePriceDetails.sku_id);

            if (tbldBundlePriceDetails == null)
            {
                return(HttpNotFound());
            }

            if (skuName != null)
            {
                ViewBag.SKuName = skuName.SKUName;
            }

            ViewBag.IsActive = new SelectList(_db.status.ToList(), "status_Id", "status_code");

            return(View(tbldBundlePriceDetails));
        }