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 })); } }