public ActionResult Create(MasterSuppliers cvm, HttpPostedFileBase imgfile) { string path = uploadimgfile(imgfile); if (path.Equals("-1")) { ViewBag.error = "Image could not be uploaded...."; } else { MasterSuppliers cat = new MasterSuppliers(); cat.Name = cvm.Name; cat.OwnerName = cvm.OwnerName; cat.ContactNo = cvm.ContactNo; cat.EmailId = cvm.EmailId; cat.Address = cvm.Address; cat.PhotoPath = path; cat.cat_status = 1; cat.lat = cvm.lat; cat.Long = cvm.Long; cat.TotalDue = cvm.TotalDue; cat.OpeningDue = cvm.OpeningDue; cat.VendorID = cvm.VendorID; cat.CreateDate = cvm.CreateDate; ViewBag.SportType1 = new SelectList(db.masterVendors, "VendorID", "Name"); db.masterSuppliers.Add(cat); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public ActionResult DeleteConfirmed(int id) { MasterSuppliers masterSuppliers = db.masterSuppliers.Find(id); db.masterSuppliers.Remove(masterSuppliers); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MasterSuppliers masterSuppliers = db.masterSuppliers.Find(id); if (masterSuppliers == null) { return(HttpNotFound()); } return(View(masterSuppliers)); }
// GET: MasterSuppliers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MasterSuppliers masterSuppliers = db.masterSuppliers.Find(id); Session["FileName"] = masterSuppliers.PhotoPath; if (masterSuppliers == null) { return(HttpNotFound()); } ViewBag.SportType1 = new SelectList(db.masterVendors, "VendorID", "Name"); return(View(masterSuppliers)); }
public ActionResult Edit(MasterSuppliers cvm, HttpPostedFileBase imgfile) { string path = ""; var cat = db.masterSuppliers.Where(x => x.SupplierID == cvm.SupplierID).FirstOrDefault(); if (cat.PhotoPath == Session["FileName"].ToString() && imgfile == null) { path = cat.PhotoPath; } else { path = uploadimgfile1(imgfile); } if (path.Equals("-1") && cat.PhotoPath != Session["FileName"].ToString()) { ViewBag.error = "Image could not be uploaded...."; } else { cat.Name = cvm.Name; cat.OwnerName = cvm.OwnerName; cat.ContactNo = cvm.ContactNo; cat.EmailId = cvm.EmailId; cat.Address = cvm.Address; cat.PhotoPath = path; cat.cat_status = 1; cat.lat = cvm.lat; cat.Long = cvm.Long; cat.TotalDue = cvm.TotalDue; cat.OpeningDue = cvm.OpeningDue; cat.VendorID = cvm.VendorID; cat.CreateDate = cvm.CreateDate; ViewBag.SportType1 = new SelectList(db.masterVendors, "VendorID", "Name"); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }