Esempio n. 1
0
        public ActionResult Create([Bind(Include = "Id,ProdDepartmentId,SeasonInfoId,Name")] ProdColor prodColor, int?BuyerInfoId, int?BrandId)
        {
            if (ModelState.IsValid)
            {
                if (db.ProdColor.Where(x => x.ProdDepartmentId == prodColor.ProdDepartmentId && x.SeasonInfoId == prodColor.SeasonInfoId && x.Name.ToLower() == prodColor.Name.ToLower()).Count() > 0)
                {
                    Danger("Exists. Try different.", true);
                }
                else
                {
                    prodColor.OpBy = 1;
                    prodColor.OpOn = DateTime.Now;
                    db.ProdColor.Add(prodColor);
                    db.SaveChanges();
                    Success("Saved successfully!", true);
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.BuyerInfoId      = new SelectList(db.BuyerInfo.OrderBy(x => x.Name), "Id", "Name", BuyerInfoId);
            ViewBag.BrandId          = new SelectList(db.Brand.Where(x => x.BuyerInfoId == prodColor.SeasonInfo.BuyerInfoId).OrderBy(x => x.Name), "Id", "Name", BrandId);
            ViewBag.ProdDepartmentId = new SelectList(db.ProdDepartment.Where(x => x.Brand.BuyerInfoId == prodColor.ProdDepartment.Brand.BuyerInfoId).OrderBy(x => x.Name), "Id", "Name", prodColor.ProdDepartmentId);
            ViewBag.SeasonInfoId     = new SelectList(db.SeasonInfo.OrderBy(x => x.Name), "Id", "Name", prodColor.SeasonInfoId);

            return(View(prodColor));
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProdColor prodColor = db.ProdColor.Find(id);

            db.ProdColor.Remove(prodColor);
            db.SaveChanges();
            Success("Deleted successfully", true);
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        // GET: ProdColors/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProdColor prodColor = db.ProdColor.Find(id);

            if (prodColor == null)
            {
                return(HttpNotFound());
            }
            return(View(prodColor));
        }
Esempio n. 4
0
        // GET: ProdColors/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProdColor prodColor = db.ProdColor.Find(id);

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

            ViewBag.BuyerInfoId      = new SelectList(db.BuyerInfo.OrderBy(x => x.Name), "Id", "Name", prodColor.SeasonInfo.BuyerInfoId);
            ViewBag.BrandId          = new SelectList(db.Brand.Where(x => x.BuyerInfoId == prodColor.SeasonInfo.BuyerInfoId).OrderBy(x => x.Name), "Id", "Name", prodColor.ProdDepartment.BrandId);
            ViewBag.ProdDepartmentId = new SelectList(db.ProdDepartment.Where(x => x.Brand.BuyerInfoId == prodColor.ProdDepartment.Brand.BuyerInfoId).OrderBy(x => x.Name), "Id", "Name", prodColor.ProdDepartmentId);
            ViewBag.SeasonInfoId     = new SelectList(db.SeasonInfo.OrderBy(x => x.Name), "Id", "Name", prodColor.SeasonInfoId);
            return(View(prodColor));
        }