private void FirstStart() { ModelContainer cont = new ModelContainer(); BranchRepository branchRepository = new BranchRepository(cont); CategoryRepository categoryRepository = new CategoryRepository(cont); CompanyOwnerRepository companyOwnerRepository = new CompanyOwnerRepository(cont); PersonRepository personRepository = new PersonRepository(cont); PositionRepository positionRepository = new PositionRepository(cont); RoomRepository roomRepository = new RoomRepository(cont); TableRepository tableRepository = new TableRepository(cont); ClientRepository clientRepository = new ClientRepository(cont); if (positionRepository.Positions().Count() == 0) { positionRepository.AddPosition("Суперпользователь", true, true, true, true, true, true); } CompanyOwner co = new CompanyOwner(); if (personRepository.Persones().Count() == 0) { co = companyOwnerRepository.AddCompanyOwner("Суперпользователь", "", "", "", "", "super", "super".GetHashCode().ToString(), "", "", "", positionRepository.GetPositionByName("Суперпользователь")); } Branch b = new Branch(); if (branchRepository.Branches().Count() == 0) { b = branchRepository.AddBranch("", "", DateTime.Now, DateTime.Now, "", "", "", "", "", co, null); } Room r = new Room(); if (roomRepository.Rooms().Count() == 0) { r = roomRepository.AddRoom("", b); } if (categoryRepository.Categotyes().Count() == 0) { categoryRepository.AddCategory(""); } if (tableRepository.Tables().Count() == 0) { tableRepository.AddTable(1, "", r); } if (clientRepository.Clients().Count() == 0) { clientRepository.AddClient("Клиент", "", "", "", "", "", "", "", "", "", "", ""); } }
// Add a new room public void PostRoom(RoomViewModel room) { var newRoom = new Room() { Name = room.Name, Description = room.Description, ConferenceId = room.ConferenceId }; _roomRepo.AddRoom(newRoom); _roomRepo.SaveChanges(); }
public void AddRoom(Room r) { RoomRepo.AddRoom(r); }
public ActionResult Create(FloorVM model) { try { string floorId = string.Empty; model.CreatedBy = 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.AddFloor(model); if (!string.IsNullOrWhiteSpace(floorId)) { #region Add Rooms int roomNo = (model.FloorNo.Value * 100); for (int intI = 1; intI <= model.NoOfRoom; intI++) { RoomVM room = new RoomVM(); room.FloorId = Guid.Parse(floorId); room.Type = ""; room.RoomNo = (roomNo + intI).ToString(); room.Description = ""; room.StatusId = Guid.Parse(RoomStatusType.CLEAN); room.IsActive = true; room.IsOccupied = false; room.CreatedBy = LogInManager.LoggedInUserId; roomRepository.AddRoom(room); } #endregion return(Json(new { IsSuccess = true, data = new { FloorId = floorId } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Floor details not saved successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "Create"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult Create(RoomVM model) { try { string roomId = string.Empty; model.CreatedBy = LogInManager.LoggedInUserId; #region Check Room No Available. if (this.CheckRoomNoAvailable(model.Id, model.RoomNo) == false) { return(Json(new { IsSuccess = false, errorMessage = string.Format("Room No : {0} already exist.", model.RoomNo) }, JsonRequestBehavior.AllowGet)); } #endregion model.StatusId = Guid.Parse(RoomStatusType.CLEAN); roomId = roomRepository.AddRoom(model); if (!string.IsNullOrWhiteSpace(roomId)) { model.Id = Guid.Parse(roomId); #region Update Floor (No. Of Rooms) //Increase the no. of rooms quantity in floor. var floor = floorRepository.GetFloorById(model.FloorId).FirstOrDefault(); if (floor != null) { floor.NoOfRoom = floor.NoOfRoom > 0 ? (floor.NoOfRoom + 1) : 0; floorRepository.UpdateFloor(floor); } #endregion #region Add Room Features if (model.RoomFeatures != null && model.RoomFeatures.Count > 0) { foreach (var item in model.RoomFeatures) { RoomFeaturesMappingVM roomFeaturesMapping = new RoomFeaturesMappingVM(); roomFeaturesMapping.RoomId = Guid.Parse(roomId); roomFeaturesMapping.RoomFeatureId = item; roomFeaturesMapping.CreatedBy = LogInManager.LoggedInUserId; roomFeaturesMapping.UpdatedBy = LogInManager.LoggedInUserId; roomRepository.AddUpdateRoomFeaturesMapping(roomFeaturesMapping); } } #endregion return(Json(new { IsSuccess = true, data = new { RoomId = roomId, Room = model } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Room details not saved successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "Create"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }