public IActionResult Create() { ViewData["Name"] = new SelectList(_db.Department.GetAll(), "Id", "Name"); FloorVm floorVm = new FloorVm(); return(PartialView("_CreateView", floorVm)); }
public IActionResult Edit(int id) { ViewData["Name"] = new SelectList(_db.Department.GetAll(), "Id", "Name"); var floor = _db.Floor.Get(id); FloorVm floorVm = new FloorVm(); floorVm.Id = floor.Id; floorVm.Name = floor.Name; floorVm.Decription = floor.Decription; floorVm.DepartmentId = floor.DepartmentId; return(PartialView("_EditView", floorVm)); }
public IActionResult Delete(FloorVm floorVm) { if (ModelState.IsValid) { Floor floor = _db.Floor.GetFirstOrDefault(c => c.Id == floorVm.Id); floor.IsActive = false; floor.IsDeleted = true; _db.Floor.Update(floor); bool isUpdated = _db.Save() > 0; return(Json(floorVm)); } floorVm.IsValid = false; floorVm.Message = "Validation Failed!. Please try Again with valid data."; return(Json(floorVm)); }
public IActionResult Create(FloorVm floorVm) { if (ModelState.IsValid) { Floor floor = new Floor() { Name = floorVm.Name, Decription = floorVm.Decription, DepartmentId = floorVm.DepartmentId, IsActive = floorVm.IsActive, IsDeleted = false }; _db.Floor.Add(floor); bool isUpdated = _db.Save() > 0; return(Json(floorVm)); } floorVm.IsValid = false; floorVm.Message = "Validation Failed!. Please try Again with valid data."; return(Json(floorVm)); }
public IActionResult Edit(FloorVm floorVm) { if (ModelState.IsValid) { Floor floor = _db.Floor.GetFirstOrDefault(c => c.Id == floorVm.Id); floor.Id = floorVm.Id; floor.Name = floorVm.Name; floor.Decription = floorVm.Decription; floor.DepartmentId = floorVm.DepartmentId; _db.Floor.Update(floor); bool isUpdated = _db.Save() > 0; return(Json(floorVm)); } floorVm.IsValid = false; floorVm.Message = "Validation Failed!. Please try Again with valid data."; return(Json(floorVm)); }