public ActionResult AddBuilding(Building buildings) { Room rooms = new Room(); if (ModelState.IsValid) { //db.Entry(buildings).State = EntityState.Added; //db.SaveChanges(); //return View("Index"); } return View("Edit"); }
public ActionResult CreateBuilding(RoomLookupModel model) { Building buildings = new Building(); buildings = model.buildingCreate; List<string> buildingCodes = (from b in db.Buildings select b.BuildingCode).ToList(); if (buildingCodes.Contains((buildings.BuildingCode).ToUpper())) { TempData["notice"] = "This building code already exists. Please choose another."; return RedirectToAction("CreateBuilding", "RoomLookup"); } if (ModelState.IsValid) { db.Entry(buildings).State = EntityState.Added; db.SaveChanges(); return RedirectToAction("Index"); } //Room room = new Room(); //room = model.roomsCreated; //if (ModelState.IsValid) //{ // db.Entry(model.roomsCreate).State = EntityState.Added; // db.SaveChanges(); // return RedirectToAction("Index"); //} return View("Index"); }