public async Task Should_raise_admin_consultation_message(RoomType?transferTo) { _eventHandler = new VhOfficerCallEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual); var callbackEvent = new CallbackEvent { EventType = EventType.Transfer, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, ParticipantId = participantForEvent.Id, TransferTo = transferTo, TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); EventHubClientMock.Verify(x => x.AdminConsultationMessage(conference.Id, transferTo.Value, participantForEvent.Username.ToLowerInvariant(), null), Times.Once); }
/// <summary> /// updating room by parameters /// </summary> /// <param name="ID">room's ID</param> /// <param name="Beds">Beds - optional</param> /// <param name="Type">Room Type - optional</param> /// <param name="Price">Price - optional</param> /// <returns>true if success, false else</returns> public bool UpdateRoom(uint ID, uint Beds = 0, RoomType?Type = null, uint Price = 0) { XElement roomToUpdate = (from item in Xrooms.Elements() where (item.Element("id").Value == ID.ToString()) select item).FirstOrDefault(); if (roomToUpdate == null) { return(false); } try { if (Beds > 0) { roomToUpdate.Element("Beds").Value = Beds.ToString(); } if (Type.HasValue) { roomToUpdate.Element("Type").Value = Type.ToString(); } if (Price > 0) { roomToUpdate.Element("Price").Value = Price.ToString(); } Xrooms.Save(roomsFile); return(true); } catch { return(false); } }
/// <inheritdoc/> public async Task <IListResult <Room> > GetRoomsAsync(int max = 100, string teamId = "", RoomType?type = null, SortBy?sortBy = null) { var roomParams = new List <KeyValuePair <string, string> >(); if (max != 100) { roomParams.Add(new KeyValuePair <string, string>(nameof(max), max.ToString())); } if (!string.IsNullOrEmpty(teamId)) { roomParams.Add(new KeyValuePair <string, string>(nameof(teamId), teamId)); } if (type != null) { roomParams.Add(new KeyValuePair <string, string>(nameof(type), type.ToString().ToLower())); } if (sortBy != null) { roomParams.Add(new KeyValuePair <string, string>(nameof(sortBy), sortBy.ToString().ToLower())); } var path = await GetPathWithQueryAsync(WxTeamsConstants.RoomsUrl, roomParams); return(await TeamsClient.GetResultsAsync <Room>(path)); }
public UpdateEndpointStatusAndRoomCommand(Guid conferenceId, Guid endpointId, EndpointState status, RoomType?room) { ConferenceId = conferenceId; EndpointId = endpointId; Status = status; Room = room; }
public UpdateParticipantStatusAndRoomCommand(Guid conferenceId, Guid participantId, ParticipantState participantState, RoomType?room) { ConferenceId = conferenceId; ParticipantId = participantId; ParticipantState = participantState; Room = room; }
public void should_update_room(RoomType?newRoom) { var endpoint = new Endpoint("old name", "*****@*****.**", "1234", "*****@*****.**"); endpoint.UpdateCurrentRoom(newRoom); endpoint.CurrentRoom.Should().Be(newRoom); }
private static void GetRoomTypeEnums(ConferenceEventRequest request, out RoomType?transferTo, out RoomType?transferFrom) { var isTransferFromEnum = Enum.TryParse(request.TransferFrom, out RoomType transferFromEnum); var isTransferToEnum = Enum.TryParse(request.TransferTo, out RoomType transferToEnum); transferFrom = isTransferFromEnum ? transferFromEnum : (RoomType?)null; transferTo = isTransferToEnum ? transferToEnum : (RoomType?)null; }
public RoomForRentAnnouncementPreferenceResponse(Guid id, Guid cityId, decimal?priceMin, decimal?priceMax, RoomType?roomType, IEnumerable <Guid> cityDistricts) : base(id) { PriceMin = priceMin; PriceMax = priceMax; CityId = cityId; RoomType = roomType; CityDistricts = cityDistricts.ToList().AsReadOnly(); }
/// <summary> /// Gets all. /// </summary> /// <param name="keyword">The keyword.</param> /// <param name="hostelId">The hostel identifier.</param> /// <param name="onlyPrivated">only private rooms</param> /// <param name="roomType">the room type</param> /// <param name="sortRoomBy">sort rooms by</param> /// <param name="minimumBeds">the minimum beds needed</param> /// <param name="page">The page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns> /// the list of rooms /// </returns> public async Task <IPagedList <Room> > GetAll( string keyword = null, int?hostelId = null, bool?onlyPrivated = null, RoomType?roomType = null, SortRoomBy sortRoomBy = SortRoomBy.Name, int?minimumBeds = null, int page = 0, int pageSize = int.MaxValue) { var query = this.roomRepository.Table .Include(c => c.Hostel) .Where(c => !c.Deleted); if (!string.IsNullOrEmpty(keyword)) { query = query.Where(c => c.Name.Contains(keyword)); } if (hostelId.HasValue) { query = query.Where(c => c.HostelId == hostelId.Value); } if (onlyPrivated.HasValue) { query = query.Where(c => c.IsPrivated.Equals(onlyPrivated.Value)); } if (roomType.HasValue) { var roomTypeId = Convert.ToInt16(roomType); query = query.Where(c => c.RoomTypeId == roomTypeId); } if (minimumBeds.HasValue) { query = query.Where(c => c.Beds >= minimumBeds.Value); } switch (sortRoomBy) { case SortRoomBy.Name: query = query.OrderBy(c => c.Name); break; case SortRoomBy.Beds: query = query.OrderBy(c => c.Beds); break; case SortRoomBy.RoomType: query = query.OrderBy(c => c.RoomTypeId); break; } return(await new PagedList <Room>().Async(query, page, pageSize)); }
public UserRoomForRentAnnouncementPreferenceUpdatedIntegrationEvent(Guid correlationId, DateTimeOffset creationDate, Guid userId, Guid roomForRentAnnouncementPreferenceId, Guid cityId, decimal?priceMin, decimal?priceMax, RoomType?roomType, IEnumerable <Guid> cityDistricts) : base(correlationId, creationDate) { UserId = userId; RoomForRentAnnouncementPreferenceId = roomForRentAnnouncementPreferenceId; CityId = cityId; PriceMin = priceMin; PriceMax = priceMax; RoomType = roomType; CityDistricts = cityDistricts.ToList().AsReadOnly(); }
public SaveEventCommand(Guid conferenceId, string externalEventId, EventType eventType, DateTime externalTimestamp, RoomType?transferredFrom, RoomType?transferredTo, string reason, string phone) { ConferenceId = conferenceId; ExternalEventId = externalEventId; EventType = eventType; ExternalTimestamp = externalTimestamp; TransferredFrom = transferredFrom; TransferredTo = transferredTo; Reason = reason; IsEndpoint = eventType.IsEndpointEvent(); Phone = phone; }
public void SetCurrentBuild(int type) { var rType = (RoomType)type; _currentSelection = rType == _currentSelection || type == -1 ? (RoomType?)null : rType; if (_currentSelection == null) { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); } else { Cursor.SetCursor(type == 0 ? _textures[0] : _textures[type - 2], Vector2.zero, CursorMode.Auto); } }
public Event(Guid conferenceId, string externalEventId, EventType eventType, DateTime externalTimestamp, RoomType?transferredFrom, RoomType?transferredTo, string reason, string phone) { ExternalEventId = externalEventId; EventType = eventType; ExternalTimestamp = externalTimestamp; TransferredFrom = transferredFrom; TransferredTo = transferredTo; Reason = reason; ConferenceId = conferenceId; Timestamp = DateTime.UtcNow; EndpointFlag = false; Phone = phone; }
public UserRoomForRentAnnouncementPreferenceCreatedIntegrationEvent(Guid correlationId, DateTimeOffset creationDate, Guid userId, Guid roomForRentAnnouncementPreferenceId, string userEmail, Guid cityId, bool serviceActive, AnnouncementSendingFrequency announcementSendingFrequency, decimal?priceMin, decimal?priceMax, RoomType?roomType, IEnumerable <Guid> cityDistricts) : base(correlationId, creationDate) { UserId = userId; RoomForRentAnnouncementPreferenceId = roomForRentAnnouncementPreferenceId; UserEmail = userEmail; CityId = cityId; ServiceActive = serviceActive; AnnouncementSendingFrequency = announcementSendingFrequency; PriceMin = priceMin; PriceMax = priceMax; RoomType = roomType; CityDistricts = cityDistricts.ToList().AsReadOnly(); }
/// <summary> /// Lists all rooms where the authenticated user belongs. /// </summary> /// <param name="teamId">If not null, only list the rooms that are associated with the team by team id.</param> /// <param name="max">The maximum number of rooms in the response. If null, all rooms are listed.</param> /// <param name="type">If not null, only list the rooms of this type. Otherwise all rooms are listed.</param> /// <param name="sortBy">If not null, sort results by roomId(id), most recent activity(lastactivity), or most recently created(created).</param> /// <param name="completionHandler">The completion handler.</param> /// <remarks>Since: 0.1.0</remarks> public void List(string teamId, int?max, RoomType?type, RoomSortType?sortBy, Action <SparkApiEventArgs <List <Room> > > completionHandler) { ServiceRequest request = BuildRequest(); request.Method = HttpMethod.GET; request.RootElement = "items"; if (teamId != null) { request.AddQueryParameters("teamId", teamId); } if (max != null) { request.AddQueryParameters("max", max); } if (type != null) { request.AddQueryParameters("type", type.ToString().ToLower()); } if (sortBy != null) { string strSortBy = null; switch (sortBy) { case RoomSortType.ById: strSortBy = "id"; break; case RoomSortType.ByLastActivity: strSortBy = "lastactivity"; break; case RoomSortType.ByCreated: strSortBy = "created"; break; default: completionHandler?.Invoke(new SparkApiEventArgs <List <Room> >(false, new SparkError(SparkErrorCode.IllegalOperation, "sort type is invalid."), null)); return; } request.AddQueryParameters("sortBy", strSortBy); } request.Execute <List <Room> >(completionHandler); }
public async Task Should_save_event_with_room_id() { var seededConference = await TestDataManager.SeedConference(); TestContext.WriteLine($"New seeded conference id: {seededConference.Id}"); _newConferenceId = seededConference.Id; var externalEventId = "AutomatedEventTestRoomIdIsSaved"; var externalTimeStamp = DateTime.UtcNow.AddMinutes(-10); var participantId = seededConference.GetParticipants().First().Id; RoomType?transferredFrom = RoomType.WaitingRoom; RoomType?transferredTo = RoomType.ConsultationRoom; var reason = "Automated"; var eventType = EventType.Disconnected; var roomId = new Random().Next(); var command = new SaveEventCommand(_newConferenceId, externalEventId, eventType, externalTimeStamp, transferredFrom, transferredTo, reason, null) { ParticipantId = participantId, ParticipantRoomId = roomId }; await _handler.Handle(command); Event savedEvent; await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions)) { savedEvent = await db.Events.FirstOrDefaultAsync(x => x.ExternalEventId == externalEventId && x.ParticipantId == participantId); } savedEvent.Should().NotBeNull(); savedEvent.ExternalEventId.Should().Be(externalEventId); savedEvent.EventType.Should().Be(eventType); savedEvent.ExternalTimestamp.Should().Be(externalTimeStamp); savedEvent.TransferredFrom.Should().Be(transferredFrom); savedEvent.TransferredTo.Should().Be(transferredTo); savedEvent.Reason.Should().Be(reason); savedEvent.EndpointFlag.Should().BeFalse(); savedEvent.Phone.Should().Be(command.Phone); savedEvent.ParticipantRoomId.Should().Be(command.ParticipantRoomId); }
/// <summary> /// Lists all rooms where the authenticated user belongs. /// </summary> /// <param name="teamId">If not null, only list the rooms that are associated with the team by team id.</param> /// <param name="max">The maximum number of rooms in the response. If null, all rooms are listed.</param> /// <param name="type">If not null, only list the rooms of this type. Otherwise all rooms are listed.</param> /// <param name="completionHandler">The completion handler.</param> /// <remarks>Since: 0.1.0</remarks> public void List(string teamId, int?max, RoomType?type, Action <SparkApiEventArgs <List <Room> > > completionHandler) { ServiceRequest request = BuildRequest(); request.Method = HttpMethod.GET; request.RootElement = "items"; if (teamId != null) { request.AddQueryParameters("teamId", teamId); } if (max != null) { request.AddQueryParameters("max", max); } if (type != null) { request.AddQueryParameters("type", type.ToString().ToLower()); } request.Execute <List <Room> >(completionHandler); }
private List <Room> ListRooms(string teamId = null, int?max = null, RoomType?roomType = null) { var completion = new ManualResetEvent(false); var response = new SparkApiEventArgs <List <Room> >(); room.List(teamId, max, roomType, rsp => { response = rsp; completion.Set(); }); if (false == completion.WaitOne(30000)) { return(null); } if (response.IsSuccess == true) { return(response.Data); } return(null); }
/// <summary> /// updating room by parameters /// </summary> /// <param name="ID">room's ID</param> /// <param name="Beds">Beds - optional</param> /// <param name="Type">Room Type - optional</param> /// <param name="Price">Price - optional</param> /// <returns>true if success, false else</returns> public bool UpdateRoom(uint ID, uint Beds = 0, RoomType?Type = null, uint Price = 0) { var Room = Rooms.Where(item => item.RoomID == ID); if (Room.Count() != 1) { return(false); } Room.Update(item => { if (Beds > 0) { item.Beds = Beds; } if (Type.HasValue) { item.Type = Type.Value; } if (Price > 0) { item.Price = Price; } }); return(true); }
private IQueryable <HotelRoom> FilterSearch(IQueryable <HotelRoom> query, string term, DateTime?from, DateTime?to, int?capacity, RoomType?type, decimal?start, decimal?end) { if (from.HasValue && to.HasValue) { query = query.Where(f => !f.Reservations.Any(f => f.ReservedForDate < to.Value && from.Value < f.ReservedUntilDate)); } if (!string.IsNullOrWhiteSpace(term)) { query = query.Where(f => f.Name == term); } if (capacity.HasValue) { query = query.Where(f => f.Capacity >= capacity); } if (type.HasValue) { query = query.Where(f => f.RoomType == type); } if (start.HasValue) { query = query.Where(f => (f.RoomPrice ?? f.PriceForAdults).Value >= start.Value); } if (end.HasValue) { query = query.Where(f => (f.RoomPrice ?? f.PriceForAdults).Value <= end.Value); } return(query); }
public Task <List <HotelRoomShortVm> > SearchHotelRooms(string term, decimal conversionRate, DateTime?from, DateTime?to, int?capacity, int page, int pageCount, RoomType?type, decimal?start, decimal?end, SortBy sort, CancellationToken token) { var query = Query.Where(f => f.DeletedOn == null); query = query.Include(f => f.Reservations); query = FilterSearch(query, term, from, to, capacity, type, start, end); switch (sort) { case SortBy.New: query = query.OrderBy(f => f.CreatedOn); break; case SortBy.Popular: query = query.OrderBy(f => f.Reservations.Count); break; case SortBy.LowerPrice: query = query.OrderBy(f => f.PriceForAdults ?? f.RoomPrice); break; case SortBy.HigherPrice: query = query.OrderByDescending(f => f.PriceForAdults ?? f.RoomPrice); break; } if (page > 0) { query = query.Skip(pageCount * page); } query = query.Take(pageCount); return(query.ProjectTo <HotelRoomShortVm>(_mapper.ConfigurationProvider, new { conversionRate }) .ToListAsync(token)); }
public Task <int> SearchedHotelRoomsCount(string term, DateTime?from, DateTime?to, int?capacity, RoomType?type, decimal?start, decimal?end, CancellationToken token) { var query = Query.Where(f => f.DeletedOn == null); query = query.Include(f => f.Reservations); query = FilterSearch(query, term, from, to, capacity, type, start, end); return(query.CountAsync(token)); }
public Task <decimal> HighestPricesRoomSearch(string term, DateTime?from, DateTime?to, int?capacity, RoomType?type, decimal?start, decimal?end, CancellationToken token) { var query = Query.Where(f => f.DeletedOn == null); query = query.Include(f => f.Reservations); query = FilterSearch(query, term, from, to, capacity, type, start, end); return(query.MaxAsync(f => (f.PriceForAdults ?? f.RoomPrice).Value, token)); }
public async Task <IActionResult> Search(string term, DateTime?from, DateTime?to, int?capacity, int?page, RoomType?type, decimal?start, decimal?end, SortBy sort = default) => View(await Mediator.Send(new SearchHotelRoomsQuery { Term = term, AvailableFrom = from, AvailableTo = to, Capacity = capacity, Page = page ?? 0, RoomType = type, Start = start, End = end, SortBy = sort }));
public void UpdateCurrentRoom(RoomType?currentRoom) { CurrentRoom = currentRoom; }
public List <IAvaliableRoom> GetAvailableRooms(RoomType?roomtype, DateTime?startdate, DateTime?enddate) { return(hotelCon.GetAvailableRooms(roomtype, startdate, enddate)); }
public RoomData(bool init, RoomType room, Direction[] dirs) { initialized = init; roomType = room; roomDirections = dirs; }
public RoomData(bool init) { initialized = init; roomType = null; roomDirections = null; }
public CallbackEventRequestBuilder ToRoomType(RoomType?roomType) { _request.With(x => x.TransferTo = roomType); return(this); }
public static RoomTypeEnumeration ConvertToEnumeration(this RoomType?roomType) { return(!roomType.HasValue ? null : EnumerationBase.GetAll <RoomTypeEnumeration>().SingleOrDefault(x => x.DisplayName.ToLower().Equals(roomType.ToString().ToLower()))); }
//Return a list of available room types internal List <IAvaliableRoom> GetAvailableRooms(RoomType?roomtype, DateTime?startdate, DateTime?enddate) { List <IBooking> bookings = dbCon.GetBookings(); List <IRoom> rooms = GetRooms(); List <IAvaliableRoom> avaliablerooms = new List <IAvaliableRoom>(), temp; foreach (IRoom room in rooms) { bool foundroom = false; foreach (AvaliableRoom avaliroom in avaliablerooms) { if (avaliroom.RType == room.RType) { foundroom = true; avaliroom.Add(); } } if (foundroom == false) { IRoomPrice rmp = dbCon.GetRoomPrice(room.RType); if (rmp == null) { MessageBox.Show("房间价格未初始化!", "查询价格错误"); return(avaliablerooms); } avaliablerooms.Add(new AvaliableRoom(room.RType, rmp.Price)); } } if (roomtype != null) { temp = new List <IAvaliableRoom>(); foreach (IAvaliableRoom avaliroom in avaliablerooms) { if (avaliroom.RType == roomtype) { temp.Add(avaliroom); } } avaliablerooms = temp; } if (startdate != null && enddate != null) { foreach (AvaliableRoom avaliroom in avaliablerooms) { foreach (IBooking booking in bookings) { if (booking.Roomtype == avaliroom.RType) { bool overlap = startdate <booking.EndDate && enddate> booking.StartDate; if (overlap) { avaliroom.Reduce(); } } } } } return(avaliablerooms); }
public void Should_throw_exception_when_transfer_to_is_not_a_consultation_room(RoomType?transferTo) { _eventHandler = new VhOfficerCallEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual); var callbackEvent = new CallbackEvent { EventType = EventType.Transfer, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, ParticipantId = participantForEvent.Id, TransferTo = transferTo?.ToString(), TimeStampUtc = DateTime.UtcNow }; var exception = Assert.ThrowsAsync <ArgumentException>(async() => await _eventHandler.HandleAsync(callbackEvent)); exception.Message.Should().Be("No consultation room provided"); }