public async Task can_access_room_data_from_response()
        {
            Room responseData;
            var  fakeRepository   = new Mock <IPsi2000Api>();
            var  fakeRoomResponse = new RoomResponse()
            {
                Data = new Room()
                {
                    Id          = fakeId,
                    Description = fakeDescription
                }
            };

            fakeRepository
            .Setup(m => m.GetRoom(It.IsAny <string>()))
            .Returns(Task.FromResult(fakeRoomResponse));

            asbestosService = new AsbestosService(fakeRepository.Object, fakeLogger.Object);
            responseData    = await asbestosService.GetRoom(fakeId.ToString());

            Assert.Equal(fakeId, responseData.Id);
            Assert.Equal(fakeDescription, responseData.Description);
        }
        public async Task <GenericObjectResponse <RoomResponse> > ChangeRoomData(CreateRoomPayload payload, long roomId)
        {
            RoomValidationService service            = new RoomValidationService();
            GenericStatusMessage  validationResponse = service.ValidateRoomData(payload, false);
            RoomResponse          roomResponse       = null;

            if (validationResponse.Success)
            {
                using (ReservationDataContext context = new ReservationDataContext())
                {
                    Room room = context.Rooms.Include(x => x.WorkingHours).Single(x => x.Id == roomId);
                    room.Name = payload.Name ?? room.Name;
                    room.Size = payload.Size ?? room.Size;
                    room.MaxNumberOfPeople = payload.MaxNumberOfPeople ?? room.MaxNumberOfPeople;
                    room.Country           = payload.Country ?? room.Country;
                    room.City           = payload.City ?? room.City;
                    room.Street         = payload.Street ?? room.Street;
                    room.BuildingNumber = payload.BuildingNumber ?? room.BuildingNumber;
                    context.SaveChanges();
                    roomResponse = ConvertRoomToResponse(room, room.OwnerId);
                }

                LatLon latLon = await AddLatLonForRoom(roomResponse.Id);

                if (latLon != null)
                {
                    roomResponse.Lat = latLon.Lat;
                    roomResponse.Lon = latLon.Lon;
                }

                return(new GenericObjectResponse <RoomResponse>(roomResponse));
            }
            else
            {
                return(new GenericObjectResponse <RoomResponse>(validationResponse.Message));
            }
        }
Пример #3
0
        public async Task <ActionResult> Join(int id)
        {
            try
            {
                string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                await _chatHub.Groups.AddToGroupAsync(userId, id.ToString());

                RoomResponse res = new RoomResponse()
                {
                    Type    = "success",
                    Message = "Joined a room."
                };
                return(new JsonResult(res));
            }
            catch
            {
                RoomResponse res = new RoomResponse()
                {
                    Type    = "error",
                    Message = "Something went wrong with joining the room."
                };
                return(new JsonResult(res));
            }
        }
Пример #4
0
 public Discussion(RoomResponse room) : base(room)
 {
     Topic    = room.topic;
     Name     = room.fname;
     ParentId = room.prid;
 }
Пример #5
0
 public PrivateGroup(RoomResponse room) : base(room)
 {
 }
 public DirectConversation(RoomResponse room) : base(room)
 {
     Usernames = room.usernames;
     UserIds   = room.uids;
 }
Пример #7
0
        public async Task <IActionResult> GetRoomByContact(GetRoomByContactRequest request)
        {
            RoomResponse response = await _roomService.GetRoomByContact(request);

            return(Ok(response));
        }
Пример #8
0
        public async Task <IActionResult> CreateFromContact(CreateRoomFromContactRequest model)
        {
            RoomResponse response = await _roomService.CreateFromContact(model);

            return(Ok(response));
        }
Пример #9
0
 public RoomScene(RoomResponse room)
 {
     this.room = room;
 }
Пример #10
0
 public Channel(RoomResponse room) : base(room)
 {
 }
Пример #11
0
        public List <RoomResponse> GetRoomFromFloor(int floorNo, int status)
        {
            List <RoomResponse> listRoomResponse = new List <RoomResponse>();

            //lấy những phòng chưa có event và topic
            if (status == (int)RoomStatus.Status.Ready)
            {
                var listRoomReadyFromFloor = _unitOfWork.Repository <Room>().GetAll()
                                             .Where(r => r.Status == (int)RoomStatus.Status.Ready &&
                                                    r.FloorNavigation.FloorNo == floorNo &&
                                                    r.Floor == r.FloorNavigation.Id &&
                                                    r.FloorNavigation.MapId == r.FloorNavigation.Map.Id &&
                                                    r.FloorNavigation.Map.Status == true).ToList();

                if (listRoomReadyFromFloor.Count() > 0)
                {
                    foreach (var item in listRoomReadyFromFloor)
                    {
                        RoomResponse roomResponse = new RoomResponse()
                        {
                            Id     = item.Id,
                            No     = (int)item.No,
                            Floor  = (int)item.Floor,
                            Status = (int)item.Status
                        };
                        listRoomResponse.Add(roomResponse);
                    }
                }
            }

            //lấy những phòng đã có event hoặc topic
            if (status == (int)RoomStatus.Status.Added)
            {
                var listRoomAddedFromFloor = _unitOfWork.Repository <Room>().GetAll()
                                             .Where(r => r.Status == (int)RoomStatus.Status.Added &&
                                                    r.FloorNavigation.FloorNo == floorNo &&
                                                    r.Floor == r.FloorNavigation.Id &&
                                                    r.FloorNavigation.MapId == r.FloorNavigation.Map.Id &&
                                                    r.FloorNavigation.Map.Status == true).ToList();

                if (listRoomAddedFromFloor.Count() > 0)
                {
                    foreach (var item in listRoomAddedFromFloor)
                    {
                        RoomResponse roomResponse = new RoomResponse()
                        {
                            Id     = item.Id,
                            No     = (int)item.No,
                            Floor  = (int)item.Floor,
                            Status = (int)item.Status
                        };
                        listRoomResponse.Add(roomResponse);
                    }
                }
            }


            //lấy tất cả
            if (status == 2)
            {
                var listRoomFromFloor = _unitOfWork.Repository <Room>().GetAll()
                                        .Where(r => r.FloorNavigation.FloorNo == floorNo &&
                                               r.Floor == r.FloorNavigation.Id &&
                                               r.FloorNavigation.MapId == r.FloorNavigation.Map.Id &&
                                               r.FloorNavigation.Map.Status == true).ToList();

                if (listRoomFromFloor.Count() > 0)
                {
                    foreach (var item in listRoomFromFloor)
                    {
                        RoomResponse roomResponse = new RoomResponse()
                        {
                            Id     = item.Id,
                            No     = (int)item.No,
                            Floor  = (int)item.Floor,
                            Status = (int)item.Status
                        };
                        listRoomResponse.Add(roomResponse);
                    }
                }
            }
            return(listRoomResponse.ToList());
        }
Пример #12
0
        public async Task <List <RoomResponse> > GetRoomFromListExhibit(List <int> exhibitId)
        {
            //Check ở nhánh Event
            //Get List ExhibitInEvent vs ExhibitId truyền vào
            List <eTourGuide.Data.Entity.ExhibitInEvent> listExhibitInEvent = new List <eTourGuide.Data.Entity.ExhibitInEvent>();

            foreach (int item in exhibitId)
            {
                var exhibitInEvent = await _unitOfWork.Repository <eTourGuide.Data.Entity.ExhibitInEvent>()
                                     .GetAll().Where(x => x.ExhibitId == item && x.Status == true && x.Event.Status == (int)EventStatus.Status.Active).FirstOrDefaultAsync();

                if (exhibitInEvent != null)
                {
                    listExhibitInEvent.Add(exhibitInEvent);
                }
            }

            //Get Room
            Dictionary <int, object> hash     = new Dictionary <int, object>();
            List <RoomResponse>      listRoom = new List <RoomResponse>();

            if (listExhibitInEvent != null)
            {
                foreach (var item in listExhibitInEvent)
                {
                    var          room   = _unitOfWork.Repository <Room>().GetAll().Where(x => x.Id == item.Event.RoomId).FirstOrDefault();
                    RoomResponse roomRs = new RoomResponse()
                    {
                        Id     = room.Id,
                        Floor  = (int)room.Floor,
                        No     = (int)room.No,
                        Status = (int)room.Status
                    };
                    if (!hash.ContainsKey(roomRs.Id))
                    {
                        hash.Add(roomRs.Id, roomRs);
                    }
                }
            }


            //Check ở nhánh Topic
            //Get List ExhibitInTopic vs ExhibitId truyền vào
            List <eTourGuide.Data.Entity.ExhibitInTopic> listExhibitInTopic = new List <eTourGuide.Data.Entity.ExhibitInTopic>();

            foreach (int item in exhibitId)
            {
                var exhibitInTopic = await _unitOfWork.Repository <eTourGuide.Data.Entity.ExhibitInTopic>().GetAll().Where(x => x.ExhibitId == item && x.Status == true && x.Topic.Status == (int)TopicStatus.Status.Active).FirstOrDefaultAsync();

                if (exhibitInTopic != null)
                {
                    listExhibitInTopic.Add(exhibitInTopic);
                }
            }

            //Get Room
            if (listExhibitInTopic != null)
            {
                foreach (var item in listExhibitInTopic)
                {
                    var          room   = _unitOfWork.Repository <Room>().GetAll().Where(x => x.Id == item.Topic.RoomId).FirstOrDefault();
                    RoomResponse roomRs = new RoomResponse()
                    {
                        Id     = room.Id,
                        Floor  = (int)room.Floor,
                        No     = (int)room.No,
                        Status = (int)room.Status
                    };
                    if (!hash.ContainsKey(roomRs.Id))
                    {
                        hash.Add(roomRs.Id, roomRs);
                    }
                }
            }

            foreach (KeyValuePair <int, object> r in hash)
            {
                listRoom.Add((RoomResponse)r.Value);
            }

            return(listRoom.ToList());
        }