/////////////////////////////edit clothes public ActionResult EditClothes(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cloth data = db.Clothes.Find(id); if (data == null) { return(HttpNotFound()); } AddClothes PassedData = new AddClothes(); PassedData.productID = data.ProductID; PassedData.name = data.name; PassedData.color = data.color; PassedData.Brand = data.Brand; PassedData.Price = data.Price; PassedData.sale = data.sale; PassedData.Size = data.Size; PassedData.img = data.img; Admon.name = Adminloggedin.name; Admon.password = Adminloggedin.password; Admon.Type = Adminloggedin.type; ViewBag.Message = Admon; return(View(PassedData)); }
public ActionResult EditClothes(AddClothes data) { if (ModelState.IsValid) { var PassedData = db.Clothes.Find(data.productID); PassedData.ProductID = data.productID; PassedData.name = data.name; PassedData.color = data.color; PassedData.Brand = data.Brand; PassedData.Price = data.Price; PassedData.sale = data.sale; PassedData.Size = data.Size; MemoryStream target = new MemoryStream(); data.file.InputStream.CopyTo(target); PassedData.img = target.ToArray(); db.Entry(PassedData).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("DashBoard")); } Admon.name = Adminloggedin.name; Admon.password = Adminloggedin.password; Admon.Type = Adminloggedin.type; ViewBag.Message = Admon; return(View(data)); }
public ActionResult AddClothes(AddClothes addClothes) { if (ModelState.IsValid) { Cloth clothesData = new Cloth(); clothesData.img = new byte[addClothes.file.ContentLength]; MemoryStream target = new MemoryStream(); addClothes.file.InputStream.CopyTo(target); clothesData.img = target.ToArray(); clothesData.name = addClothes.name; clothesData.Size = addClothes.Size; clothesData.Brand = addClothes.Brand; clothesData.Price = addClothes.Price; clothesData.sale = addClothes.sale; clothesData.color = addClothes.color; db.Clothes.Add(clothesData); db.SaveChanges(); return(RedirectToAction("DashBoard")); } Admon.name = Adminloggedin.name; Admon.password = Adminloggedin.password; Admon.Type = Adminloggedin.type; ViewBag.Message = Admon; return(View(addClothes)); }