public ActionResult Create([Bind(Include = "SalespersonID,SalespersonName,SalespersonTelephone,SalespersonFax,TerritoryID")] SALESPERSON sALESPERSON) { if (ModelState.IsValid) { var count = db.SALESPERSONs.ToList().Count(); if (count == 0) { sALESPERSON.SalespersonID = "01"; sALESPERSON.SalespersonName = "Ikechukwu"; sALESPERSON.SalespersonTelephone = "2265068940"; sALESPERSON.SalespersonFax = "555673"; sALESPERSON.TerritoryID = "03"; } else { sALESPERSON.SalespersonID = "0" + (count + 1).ToString(); } db.SALESPERSONs.Add(sALESPERSON); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TerritoryID = new SelectList(db.TERRITORies, "TerritoryID", "TerritoryName", sALESPERSON.TerritoryID); return(View(sALESPERSON)); }
public ActionResult DeleteConfirmed(string id) { SALESPERSON sALESPERSON = db.SALESPERSON.Find(id); db.SALESPERSON.Remove(sALESPERSON); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Salesperson_ID,Salesperson_Name,Salesperson_Telephone,Salesperson_Fax,Territory_ID")] SALESPERSON sALESPERSON) { if (ModelState.IsValid) { db.Entry(sALESPERSON).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Territory_ID = new SelectList(db.TERRITORY, "Territory_ID", "Territory_ID", sALESPERSON.Territory_ID); return(View(sALESPERSON)); }
// GET: SALESPERSONs/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SALESPERSON sALESPERSON = db.SALESPERSON.Find(id); if (sALESPERSON == null) { return(HttpNotFound()); } return(View(sALESPERSON)); }
// GET: SALESPERSONs/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SALESPERSON sALESPERSON = db.SALESPERSON.Find(id); if (sALESPERSON == null) { return(HttpNotFound()); } ViewBag.Territory_ID = new SelectList(db.TERRITORY, "Territory_ID", "Territory_ID", sALESPERSON.Territory_ID); return(View(sALESPERSON)); }