コード例 #1
0
        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 }));
            }
        }
コード例 #2
0
        public ActionResult Edit(Guid id, FormCollection collection)
        {
            try
            {
                var userId = User.Identity.GetUserName();
                if (userRoleRepository.GetRoleByUserName(userId) != null && userRoleRepository.GetRoleByUserName(userId).IdUserType == "Admin")
                {
                    // TODO: Add update logic here
                    var alreadySetFloorLimit = 0;

                    var departmentItems = departmentRepository.GetAllDepartments();
                    if (departmentItems != null && departmentItems.Count != 0)
                    {
                        ViewBag.datadepartments = departmentItems;
                    }

                    var buildingItems = buildingRepository.GetAllOfficeBuildings();
                    if (buildingItems != null && buildingItems.Count != 0)
                    {
                        ViewBag.databuildings = buildingItems;
                    }

                    FloorsModel floorsModel = new FloorsModel();

                    floorsModel.IdDepartment = Guid.Parse(Request.Form["Department"]);
                    floorsModel.IdBuilding   = Guid.Parse(Request.Form["Building"]);


                    UpdateModel(floorsModel);

                    var floors = floorRepository.GetFloorByDepartmentId(floorsModel.IdDepartment);

                    foreach (FloorsModel floor in floors)
                    {
                        alreadySetFloorLimit = floor.BookableSeats + alreadySetFloorLimit;
                    }

                    alreadySetFloorLimit = alreadySetFloorLimit + floorsModel.BookableSeats;

                    if (alreadySetFloorLimit <= departmentRepository.GetDepartmentById(floorsModel.IdDepartment).MaximumSeatsPerDepartment)
                    {
                        floorRepository.UpdateFloor(floorsModel);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(RedirectToAction("IndexError_MaximumSurpassed"));
                    }
                }
                else
                {
                    return(RedirectToAction("Contact", "Home"));
                }
            }
            catch
            {
                return(View("EditFloor"));
            }
        }
コード例 #3
0
        public ActionResult Edit(FloorVM model)
        {
            try
            {
                string floorId = string.Empty;
                model.UpdatedBy = LogInManager.LoggedInUserId;

                #region Check Floor Code Available.

                if (this.CheckFloorCodeAvailable(model.Id, model.Code) == false)
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = string.Format("Floor Code : {0} already exist.", model.Code)
                    }, JsonRequestBehavior.AllowGet));
                }

                #endregion

                floorId = floorRepository.UpdateFloor(model);

                if (!string.IsNullOrWhiteSpace(floorId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            FloorId = floorId
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Floor details not updated successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Edit");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }