public ActionResult Create(FloorViewModel model) { try { bool result = _floorService.AddFloor(model); if (result) { return(RedirectToAction(nameof(Index))); } throw new Exception(); } catch { ModelState.AddModelError(string.Empty, "Ooops! Something went wrong!"); return(View()); } }
public string SaveFloor(FloorModel floor) { Mapper.CreateMap <FloorModel, Floor>(); Floor fl = Mapper.Map <FloorModel, Floor>(floor); fl.CrBy = User.Identity.Name; fl.CrDate = DateTime.Now; bool bl = flrService.IsFloorNo(floor.FloorNo, floor.TowerID); if (bl == true) { return((2).ToString()); } else { int i = flrService.AddFloor(fl); return(i.ToString()); } }