Exemple #1
0
        GetRoomResultVM IDoormanService.GetRoom(int roomId)
        {
            var result = new GetRoomResultVM();

            try
            {
                var dbModel =
                    _context.Rooms.SingleOrDefault(x => x.RoomId == roomId);

                if (dbModel == null)
                {
                    return(null);
                }

                result = Mapper.Map <Room, GetRoomResultVM>(dbModel);

                var dbModels =
                    _context.RoomOccupancySnapshots.Where(x => x.RoomId == dbModel.RoomId);

                if (!dbModels.Any())
                {
                    return(result);
                }

                var snapShot = dbModels.OrderByDescending(x => x.CreateDateTime).First();
                Mapper.Map <RoomOccupancySnapshot, GetRoomResultVM>(snapShot, result);

                return(result);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #2
0
 public async Task Broadcast(string name, GetRoomResultVM roomResult)
 {
     await this.Clients.All.InvokeAsync(name, roomResult);
 }