public ActionResult Delete(Guid id) { try { string roomId = string.Empty; var roomDetail = roomRepository.GetRoomById(id).FirstOrDefault(); roomId = roomRepository.DeleteRoom(id, LogInManager.LoggedInUserId); if (!string.IsNullOrWhiteSpace(roomId)) { #region Delete Room Features //Delete Room Features. roomRepository.DeleteRoomFeaturesMappingByRoom(id, LogInManager.LoggedInUserId); #endregion #region Update Floor (No. Of Rooms) //Decrease the no. of rooms quantity from floor. var floor = floorRepository.GetFloorById(roomDetail.FloorId).FirstOrDefault(); if (floor != null) { floor.NoOfRoom = floor.NoOfRoom > 0 ? (floor.NoOfRoom - 1) : 0; floorRepository.UpdateFloor(floor); } #endregion return(Json(new { IsSuccess = true, data = new { RoomId = id } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Room not deleted successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "Delete"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult Details(Guid id) { var userId = User.Identity.GetUserName(); if (userRoleRepository.GetRoleByUserName(userId) != null) { FloorsModel floorModel = floorRepository.GetFloorById(id); return(View("DetailsFloors", floorModel)); } else { return(RedirectToAction("Contact", "Home")); } }
public ActionResult Edit(Guid id) { var floor = floorRepository.GetFloorById(id); FloorVM model = new FloorVM(); if (floor != null && floor.Count > 0) { model = floor[0]; return(View(model)); } return(RedirectToAction("List")); }
public ActionResult Create(FormCollection collection) { try { var userId = User.Identity.GetUserName(); var floorItems = new List <FloorsModel>(); if (userRoleRepository.GetRoleByUserName(userId) != null) { var userRole = userRoleRepository.GetRoleByUserName(userId).IdUserType; var userDepartment = userRoleRepository.GetRoleByUserName(userId).IdDepartment; var filterDepartmentId = departmentRepository.GetDepartmentIdByName(userDepartment); var spaceAlreadyBooked = 0; //Get relevant floors for department floorItems = floorRepository.GetFloorByDepartmentId(filterDepartmentId); if (floorItems != null && floorItems.Count != 0) { ViewBag.datafloors = floorItems; } else { ViewBag.Message = "No floor space has been allocated for your department. Please contact your admin."; } // TODO: Add insert logic here if (ViewBag.Message != "No floor space has been allocated for your department. Please contact your admin.") { BookingsModel bookingModel = new BookingsModel(); bookingModel.IdFloor = Guid.Parse(Request.Form["Floor"]); bookingModel.IdBuilding = floorRepository.GetFloorById(Guid.Parse(Request.Form["Floor"])).IdBuilding; bookingModel.UserName = userId; bookingModel.UserDepartment = userDepartment; bookingModel.UserRole = userRole; UpdateModel(bookingModel); var maxFloorBuildingSpace = floorRepository.GetFloorByFloorIdandBuildingIdandDepartmentId(bookingModel.IdFloor, bookingModel.IdBuilding, filterDepartmentId).BookableSeats; var bookingsOnFloorBuildingDepartment = bookingRepository.GetBookingByDepartmentFloorBuilding(userDepartment, bookingModel.IdFloor, bookingModel.IdBuilding, bookingModel.BookingValidFrom, bookingModel.BookingValidTo); if (bookingsOnFloorBuildingDepartment == null || bookingsOnFloorBuildingDepartment.Count == 0) { spaceAlreadyBooked = bookingModel.BookedSeats; } else { foreach (BookingsModel booking in bookingsOnFloorBuildingDepartment) { spaceAlreadyBooked = spaceAlreadyBooked + booking.BookedSeats; } spaceAlreadyBooked = spaceAlreadyBooked + bookingModel.BookedSeats; } if (bookingRepository.IsDuplicateBooking(bookingModel) == false && spaceAlreadyBooked <= maxFloorBuildingSpace) { bookingRepository.InsertBooking(bookingModel); return(RedirectToAction("Index")); } else { return(RedirectToAction("IndexError")); } } else { return(RedirectToAction("IndexFilterErrorBooking")); } } else { return(RedirectToAction("Contact", "Home")); } } catch { return(View("CreateBooking")); } }
public object GetFloorById(int id) { return(_floorRepository.GetFloorById(id)); }