public ActionResult Create(Land l, int LandStatusId) { try { using (db) { l.LandStatusId = LandStatusId; l.AdminId = Convert.ToInt32(Session["aid"]); l.CreateDate = DateTime.Now; db.Lands.Add(l); db.SaveChanges(); } } catch (System.Data.Entity.Validation.DbEntityValidationException e) { Exception raise = e; foreach (var validationErrors in e.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; //TempData["message"] = "Something is wrong! " + e; } return(RedirectToAction("List")); }
public ActionResult Create(Payment p) { using (db) { db.Payments.Add(p); db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult Create(Room r) { using (db) { db.Rooms.Add(r); db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult Create(Floor f) { using (db) { db.Floors.Add(f); db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult Create(Sale s) { using (db) { //s.Date = DateTime.Now; db.Sales.Add(s); db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult Create(Building b, int BuildingStatusId, int BuildTypeId) { using (db) { b.BuildingStatusId = BuildingStatusId; b.BuildTypeId = BuildTypeId; db.Buildings.Add(b); db.SaveChanges(); } return(RedirectToAction("List")); }