public ActionResult Create([Bind(Include = "HCID,Center,Latitude,Longtitude,District,Parish")] Health_Center health_Center) { var query = db.Health_Centers.Count() + 1; string temp = "HC-" + query; bool exist = false; try { var search = db.Health_Centers.Where(c => c.HCID == temp).Single(); exist = true; } catch { exist = false; } if (exist) { var all = db.Health_Centers.ToList(); var HC = all.Last(); HC.HCID = "HC-" + DataModels.DataProcess.NextNumber(HC.HCID); } else { health_Center.HCID = temp; } if (ModelState.IsValid) { db.Health_Centers.Add(health_Center); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(health_Center)); }
public ActionResult DeleteConfirmed(string id) { Health_Center health_Center = db.Health_Centers.Find(id); db.Health_Centers.Remove(health_Center); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "HCID,Center,Latitude,Longtitude,District,Parish")] Health_Center health_Center) { if (ModelState.IsValid) { db.Entry(health_Center).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(health_Center)); }
// GET: Health_Center/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Health_Center health_Center = db.Health_Centers.Find(id); if (health_Center == null) { return(HttpNotFound()); } return(View(health_Center)); }