public IEnumerable <RoomVM> GetAllRooms() { var mng = new RoomManager(); var rooms = RoomMapper.MapListOfRooms(mng.GetAllRooms()); return(rooms); }
public Node EnableRoomEncryption(EnableRoomEncryptionRequest request) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation request.MustNotNull(nameof(request)); request.DataRoomRescueKeyPassword.MustNotNullOrEmptyOrWhitespace(nameof(request.DataRoomRescueKeyPassword), true); request.Id.MustPositive(nameof(request.Id)); #endregion ApiUserKeyPair apiDataRoomRescueKey = null; if (request.DataRoomRescueKeyPassword != null) { try { UserKeyPair cryptoPair = Crypto.Sdk.Crypto.GenerateUserKeyPair(request.DataRoomRescueKeyPassword); apiDataRoomRescueKey = UserMapper.ToApiUserKeyPair(cryptoPair); } catch (CryptoException ce) { DracoonClient.Log.Debug(Logtag, $"Generation of user key pair failed with '{ce.Message}'!"); throw new DracoonCryptoException(CryptoErrorMapper.ParseCause(ce), ce); } } ApiEnableRoomEncryptionRequest apiEnableRoomEncryptionRequest = RoomMapper.ToApiEnableRoomEncryptionRequest(request, apiDataRoomRescueKey); IRestRequest restRequest = _client.Builder.PutEnableRoomEncryption(request.Id, apiEnableRoomEncryptionRequest); ApiNode result = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PutEnableRoomEncryption); return(NodeMapper.FromApiNode(result)); }
public List <Room> RetrieveAllById(int hotel) { var roomMapper = new RoomMapper(); try { var lstResult = SqlDao.GetInstance() .ExecuteQueryProcedure( roomMapper.GetRetriveAllByIdStatement(hotel) ); if (lstResult.Count <= 0) { return(default(List <Room>)); } var obj = EntityObjectMapper.BuildObjects(lstResult); return(obj.Cast <Room>().ToList()); } catch (Exception e) { ManageException(e); } return(null); }
public void ToApiCreateRoomRequest() { // ARRANGE GroupMemberAcceptance paramGMA = GroupMemberAcceptance.AutoAllow; string expectedGMAValue = "autoallow"; ApiCreateRoomRequest expected = FactoryRoom.ApiCreateRoomRequest; expected.NewGroupMemberAcceptance = expectedGMAValue; CreateRoomRequest param = new CreateRoomRequest(expected.Name) { ParentId = expected.ParentId.Value, Quota = expected.Quota, Notes = expected.Notes, RecycleBinRetentionPeriod = expected.RecycleBinRetentionPeriod, HasInheritPermissions = expected.InheritPermissions.Value, AdminUserIds = expected.AdminIds, AdminGroupIds = expected.AdminGroupIds, NewGroupMemberAcceptance = paramGMA }; Mock.Arrange(() => EnumConverter.ConvertGroupMemberAcceptanceToValue(paramGMA)).Returns(expectedGMAValue); // ACT ApiCreateRoomRequest actual = RoomMapper.ToApiCreateRoomRequest(param); // ASSERT Assert.Equal(expected, actual, new ApiCreateRoomRequestComparer()); }
public T RetrieveByRoomNumber <T>(Room room) { var roomMapper = new RoomMapper(); try { var instance = SqlDao.GetInstance(); var operation = roomMapper.GetRetrieveByRoomNumberStatement(room.IdHotel, room.RoomNumber); var lstResult = instance.ExecuteQueryProcedure(operation); if (lstResult.Count <= 0) { return(default(T)); } var objs = EntityObjectMapper.BuildObjects(lstResult); return(objs.Cast <T>().ToList()[0]); } catch (Exception e) { ManageException(e); } return(default(T)); }
//Constructor public ReservationConsole() { TimeSlotMapper.getInstance().initializeDirectory(); ReservationMapper.getInstance().initializeDirectory(); UserMapper.getInstance().initializeDirectory(); RoomMapper.getInstance().initializeDirectory(); updateDirectories(); }
public int Add(DTORoom dtoRoom) { Room entityRoom = RoomMapper.GetEntityRoom(dtoRoom); UnitOfWork.RoomRepository.Add(entityRoom); UnitOfWork.Commit(); return(entityRoom.Id); }
public IHttpActionResult CreateRoom(RoomVM res) { var mng = new RoomManager(); var room = RoomMapper.MapRoomVM(res); mng.AddNewRoom(room); return(Ok(res)); }
public List <DTORoom> GetAll() { List <DTORoom> dtoRoomsList = new List <DTORoom>(); foreach (var item in UnitOfWork.RoomRepository.GetAll()) { dtoRoomsList.Add(RoomMapper.GetDTORoom(item)); } return(dtoRoomsList); }
public IHttpActionResult GetRoom(int id) { var mng = new RoomManager(); var room = RoomMapper.MapRoom(mng.GetRoomById(id)); if (room == null) { return(NotFound()); } return(Ok(room)); }
public MessageHub(DataContext dataContext) { _repositoryWrapper = new RepositoryWrapper(dataContext); var messageMapper = new MessageMapper(); var roomMapper = new RoomMapper(); var userMapper = new UserMapper(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(messageMapper)); configuration = new MapperConfiguration(cfg => cfg.AddProfile(roomMapper)); configuration = new MapperConfiguration(cfg => cfg.AddProfile(userMapper)); _mapper = new Mapper(configuration); }
public ActionResult GetAllRooms() { List<RoomDTO> roomDTOs = new List<RoomDTO>(); try { _roomService.ViewRooms().ForEach(room => roomDTOs.Add(RoomMapper.BackendRoomToGraphicalEditorRoom(room))); return Ok(roomDTOs); } catch (NotFoundException exception) { return NotFound(exception.Message); } }
public ActionResult Edit(RoomViewModel room) { if (ModelState.IsValid) { _unitOfWork.Room_List.Update(RoomMapper.Map(room, _unitOfWork.RoomType_List.GetAll().FirstOrDefault(f => f.Type == room.Type).ID.ToString(), _unitOfWork.HotelData_List.GetAll().FirstOrDefault(f => f.Name == room.Hotel).ID.ToString())); Ok(); return(RedirectToAction("Index", "Room", null)); } Forbidden(); return(Content(GenerateError())); }
public ActionResult Create(RoomViewModel room) { if (ModelState.IsValid) { Room instance = RoomMapper.Map(room, _unitOfWork.RoomType_List.GetAll().FirstOrDefault(f => f.Type == room.Type).ID.ToString(), _unitOfWork.HotelData_List.GetAll().FirstOrDefault(f => f.Name == room.Hotel).ID.ToString()); _unitOfWork.Room_List.Add(instance); Ok(); return(Json(new { RoomID = instance.ID.ToString() })); } Forbidden(); return(Content(GenerateError())); }
public void ToApiEnableRoomEncryptionRequest() { // ARRANGE ApiEnableRoomEncryptionRequest expected = FactoryRoom.ApiEnableRoomEncryptionRequest; EnableRoomEncryptionRequest param = new EnableRoomEncryptionRequest(1234, expected.IsEncryptionEnabled) { DataRoomRescueKeyPassword = "******", UseDataSpaceRescueKey = expected.UseDataSpaceRescueKey, }; // ACT ApiEnableRoomEncryptionRequest actual = RoomMapper.ToApiEnableRoomEncryptionRequest(param, expected.DataRoomRescueKey); // ASSERT Assert.Equal(expected, actual, new ApiEnableRoomEncryptionRequestComparer()); }
// Method used to update the lists inside each directories public void updateDirectories() { // Updating timeSlots of each reservations List <TimeSlot> timeSlotList = TimeSlotMapper.getInstance().getAllTimeSlot().Values.ToList(); timeSlotList.Sort((x, y) => x.hour.CompareTo(y.hour)); for (int i = 0; i < ReservationMapper.getInstance().getListOfReservations().Count; i++) { foreach (TimeSlot timeSlot in timeSlotList) { if (ReservationMapper.getInstance().getListOfReservations()[i].reservationID == timeSlot.reservationID && !ReservationMapper.getInstance().getListOfReservations()[i].timeSlots.Contains(timeSlot)) { ReservationMapper.getInstance().getListOfReservations()[i].timeSlots.Add(timeSlot); } } } // Updating the waitList of each timeSlot for (int i = 0; i < TimeSlotMapper.getInstance().getListOfTimeSlots().Count; i++) { List <int> waitList = TimeSlotMapper.getInstance().getAllUsers(TimeSlotMapper.getInstance().getListOfTimeSlots()[i].timeSlotID); if (waitList != null) { for (int j = 0; j < waitList.Count; j++) { if (!TimeSlotMapper.getInstance().getListOfTimeSlots()[i].waitlist.Contains(waitList[j])) { TimeSlotMapper.getInstance().getListOfTimeSlots()[i].waitlist.Enqueue(waitList[j]); } } } } // Updating the reservations for each room for (int i = 0; i < RoomMapper.getInstance().getListOfRooms().Count; i++) { foreach (KeyValuePair <int, Reservation> reservation in ReservationMapper.getInstance().getAllReservation()) { if (reservation.Value.roomID == RoomMapper.getInstance().getListOfRooms()[i].roomID) { RoomMapper.getInstance().getListOfRooms()[i].roomReservations.Add(reservation.Value); } } } }
public void ToApiUpdateRoomRequest() { // ARRANGE ApiUpdateRoomRequest expected = FactoryRoom.ApiUpdateRoomRequest; UpdateRoomRequest param = new UpdateRoomRequest(12) { Name = expected.Name, Quota = expected.Quota, Notes = expected.Notes }; // ACT ApiUpdateRoomRequest actual = RoomMapper.ToApiUpdateRoomRequest(param); // ASSERT Assert.Equal(expected, actual, new ApiUpdateRoomRequestComparer()); }
public Node UpdateRoom(UpdateRoomRequest request) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation request.MustNotNull(nameof(request)); request.Name.MustNotNullOrEmptyOrWhitespace(nameof(request.Name)); request.Id.MustPositive(nameof(request.Id)); request.Quota.NullableMustNotNegative(nameof(request.Quota)); #endregion ApiUpdateRoomRequest apiUpdateRoomRequest = RoomMapper.ToApiUpdateRoomRequest(request); IRestRequest restRequest = _client.Builder.PutRoom(request.Id, apiUpdateRoomRequest); ApiNode result = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PutRoom); return(NodeMapper.FromApiNode(result)); }
// Hotel Rooms HotelSearchRoom public HotelSearchRoom GetAvailableRoom(string SessionId, int ResIndex, string HotelCode, string SID) { //var roomexists= //if (true) //{ //} var Result = RoomAvailabiltyService.Availabilty(SessionId, ResIndex, HotelCode, SID); //map tbo rooms rsp to general res HotelSearchRoom hotelSearchRoom = RoomMapper.MapTboRoomRspTogenrl(Result, SID); // apply business rules on rooms //ApplyRoomsBusiness(rooms); //save rooms in DB SearchRepo manager = new SearchRepo(); manager.SaveSearchRooms(hotelSearchRoom.Packages, SID, HotelCode); var Res = manager.GetTBOHotelDetails(hotelSearchRoom, HotelCode, SID); // return Res; return(hotelSearchRoom); }
public Node CreateRoom(CreateRoomRequest request) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation request.MustNotNull(nameof(request)); request.ParentId.MustPositive(nameof(request.ParentId)); request.Name.MustNotNullOrEmptyOrWhitespace(nameof(request.Name)); request.Quota.NullableMustNotNegative(nameof(request.Quota)); request.RecycleBinRetentionPeriod.NullableMustNotNegative(nameof(request.RecycleBinRetentionPeriod)); if (request.AdminUserIds.CheckEnumerableNullOrEmpty() && request.AdminGroupIds.CheckEnumerableNullOrEmpty()) { throw new ArgumentNullException(nameof(request.AdminUserIds) + " | " + nameof(request.AdminGroupIds), "Room must have an admin user or admin group."); } if (request.AdminUserIds != null) { request.AdminUserIds.EnumerableMustNotNullOrEmpty(nameof(request.AdminUserIds)); request.AdminUserIds.ForEach(id => id.MustPositive(nameof(request.AdminUserIds) + " element")); } if (request.AdminGroupIds != null) { request.AdminGroupIds.EnumerableMustNotNullOrEmpty(nameof(request.AdminGroupIds)); request.AdminGroupIds.ForEach(id => id.MustPositive(nameof(request.AdminGroupIds) + " element")); } #endregion ApiCreateRoomRequest apiCreateRoomRequest = RoomMapper.ToApiCreateRoomRequest(request); IRestRequest restRequest = _client.Builder.PostRoom(apiCreateRoomRequest); ApiNode result = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PostRoom); return(NodeMapper.FromApiNode(result)); }
public async Task <IActionResult> AddRoom([FromBody] RoomModel admin) { var name = await _roomService.AddRoom(RoomMapper.Map(admin)); return(Ok(name)); }
public async Task <IActionResult> UpdateAdmin([FromBody] RoomModel room) { var name = await _roomService.UpdateRoom(RoomMapper.Map(room)); return(Ok(name)); }
public List <Room> getAllRooms() { return(RoomMapper.getInstance().getListOfRooms()); }
public async Task <Room> Get(int id) { var room = await _roomRepository.Get(id); return(RoomMapper.Map(room)); }
public async Task <Room> Update(Room room) { var data = await _roomRepository.Update(RoomMapper.Map(room)); return(room); }
public async Task <Room> GetRoom(int id) { var entity = await _roomRepository.Get(id); return(RoomMapper.Map(entity)); }
public async Task <Room> AddRoom(Room room) { var addedEntity = await _roomRepository.Add(RoomMapper.Map(room)); return(RoomMapper.Map(addedEntity)); }
public RoomsController() { this._service = new RoomService(); this._mapper = new RoomMapper(); }
public RoomService() { repository = RoomRepository.GetInstance(); mapper = new RoomMapper(); }
public async Task <Room> UpdateRoom(Room room) { var updated = await _roomRepository.Update(RoomMapper.Map(room)); return(RoomMapper.Map(updated)); }