public ActionResult DeleteConfirmed(int id)
        {
            ProdDepartment prodDepartment = db.ProdDepartment.Find(id);

            db.ProdDepartment.Remove(prodDepartment);
            db.SaveChanges();
            Success("Deleted successfully!", true);
            return(RedirectToAction("Index"));
        }
        // GET: ProdDepartment/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProdDepartment prodDepartment = db.ProdDepartment.Find(id);

            if (prodDepartment == null)
            {
                return(HttpNotFound());
            }
            return(View(prodDepartment));
        }
        // GET: ProdDepartment/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProdDepartment prodDepartment = db.ProdDepartment.Find(id);

            if (prodDepartment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BuyerInfoId = new SelectList(db.BuyerInfo, "Id", "Name", prodDepartment.Brand.BuyerInfoId);
            ViewBag.BrandId     = new SelectList(db.Brand.Where(x => x.BuyerInfoId == prodDepartment.Brand.BuyerInfoId), "Id", "Name", prodDepartment.BrandId);
            return(View(prodDepartment));
        }
 public ActionResult Edit([Bind(Include = "Id,BrandId,Name")] ProdDepartment prodDepartment, int?BuyerInfoId)
 {
     if (ModelState.IsValid)
     {
         if (db.ProdDepartment.Where(x => x.BrandId == prodDepartment.BrandId &&
                                     x.Name == prodDepartment.Name && x.Id != prodDepartment.Id).Count() > 0)
         {
             Danger("Name exists! Try different.", true);
         }
         else
         {
             db.Entry(prodDepartment).State = EntityState.Modified;
             db.SaveChanges();
             Success("Saved successfully!", true);
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.BuyerInfoId = new SelectList(db.BuyerInfo, "Id", "Name", BuyerInfoId);
     ViewBag.BrandId     = new SelectList(db.Brand.Where(x => x.BuyerInfoId == BuyerInfoId), "Id", "Name", prodDepartment.BrandId);
     return(View(prodDepartment));
 }