public ActionResult Create([Bind(Include = "DistrictID,DistrictName")] District district) { if (ModelState.IsValid) { db.Districts.Add(district); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(district)); }
public ActionResult Create([Bind(Include = "DocID,Address,FirstName,LastName,Username,DOB,Email,RegionID,Password,isActive,TariffCode,isOnline")] Doctor doctor) { if (ModelState.IsValid) { db.Doctors.Add(doctor); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RegionID = new SelectList(db.Regions, "RegionID", "RegionName", doctor.RegionID); return(View(doctor)); }
public ActionResult Create([Bind(Include = "AdminID,FirstName,LastName,userName,password,DistrictID")] Admin admin) { if (ModelState.IsValid) { db.Admins.Add(admin); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "DistrictName", admin.DistrictID); return(View(admin)); }
public ActionResult Create([Bind(Include = "PatientID,FirstName,LastName,Email,Contact,Supervisor,PatientSince")] Patient patient) { if (ModelState.IsValid) { db.Patients.Add(patient); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Supervisor = new SelectList(db.Doctors, "DocID", "Address", patient.Supervisor); return(View(patient)); }
public ActionResult Create([Bind(Include = "RegionID,RegionName,DistrictID")] Region region) { if (ModelState.IsValid) { db.Regions.Add(region); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DistrictID = new SelectList(db.Districts, "DistrictID", "DistrictName", region.DistrictID); return(View(region)); }
public void Save() { try { context.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }