public IHttpActionResult CreatePartyRoom(PartyRoom newPartyRoom)
        {
            try
            {
                PartyRoom partyRoom = new PartyRoom()
                {
                    Name            = newPartyRoom.Name,
                    AirConditioner  = newPartyRoom.AirConditioner,
                    Description     = newPartyRoom.Description,
                    LuxuryArmchairs = newPartyRoom.LuxuryArmchairs,
                    PricePerHour    = newPartyRoom.PricePerHour,
                    Screens         = newPartyRoom.Screens,
                    Sound           = newPartyRoom.Sound,
                    VideoBeam       = newPartyRoom.VideoBeam,
                    Type            = newPartyRoom.Type
                };

                db.PartyRooms.Add(partyRoom);
                db.SaveChanges();

                return(Ok(partyRoom));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
        protected override void Seed(DatabaseContext context)
        {
            base.Seed(context);

            PartyRoom firstPartyRoom = new PartyRoom()
            {
                Name            = "Salon 1",
                Description     = "Primer salon",
                Type            = Enums.TypePartyRoom.FurnishedRoom,
                Screens         = true,
                Sound           = true,
                AirConditioner  = true,
                LuxuryArmchairs = false,
                VideoBeam       = false,
                PricePerHour    = 350.00
            };

            Customer firstCustomer = new Customer()
            {
                Name = "Daniel Juarez",
                IdentificationNumber = "A123456789",
                CurrentBalance       = 0.0,
                PhoneNumber          = 61412345678
            };

            context.PartyRooms.Add(firstPartyRoom);
            context.Customers.Add(firstCustomer);
            context.SaveChanges();
        }
Beispiel #3
0
        public bool TryGetRoomForUsername(string username, out PartyRoom room)
        {
            var s = _memberRoomCache.TryGetValue(username, out var roomActual);

            room = s ? roomActual : null;
            return(s);
        }
 public IHttpActionResult DeletePartyRoomById(int id)
 {
     try
     {
         PartyRoom partyRoom = db.PartyRooms.FirstOrDefault(q => q.PartyRoomId == id);
         db.PartyRooms.Remove(partyRoom);
         db.SaveChanges();
         return(Ok());
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
 public IHttpActionResult GetPartyRoomById(int id)
 {
     try
     {
         PartyRoom partyRoom = db.PartyRooms.FirstOrDefault(q => q.PartyRoomId == id);
         if (partyRoom == null)
         {
             return(NotFound());
         }
         return(Ok(partyRoom));
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
Beispiel #6
0
        public PartyRoom EnsureRoom(string roomId)
        {
            if (_rooms.ContainsKey(roomId))
            {
                return(_rooms[roomId]);
            }

            var roomLogger = _loggerFactory.CreateLogger(typeof(PartyRoom));
            var room       = new PartyRoom(roomId, roomLogger, _spotifyAccessService);

            room.OnRoomMembersChanged += Room_OnRoomMembersChanged;
            _rooms[roomId]             = room;

            _logger.Log(LogLevel.Information, "Created {Room}", roomId);

            return(_rooms[roomId]);
        }
Beispiel #7
0
        public PartyRoom EnsureRoom(string roomId)
        {
            if (_rooms.ContainsKey(roomId))
            {
                return(_rooms[roomId]);
            }

            var roomLogger = _loggerFactory.CreateLogger <PartyRoom>();
            var room       = new PartyRoom(roomId, roomLogger, _spotifyAccessService, _userScoreService);

            room.OnRoomMembersChanged          += Room_OnRoomMembersChanged;
            room.OnRoomNotification            += Room_OnRoomNotification;
            room.OnRoomCurrentReactionsChanged += Room_OnRoomCurrentReactionsChanged;
            _rooms[roomId] = room;

            _logger.Log(LogLevel.Information, "Created {Room}", roomId);

            return(_rooms[roomId]);
        }
        public IHttpActionResult UpdatePartyRoom(PartyRoom partyRoomToUpdate)
        {
            try
            {
                PartyRoom oldPartyRoom = db.PartyRooms.FirstOrDefault(q => q.PartyRoomId == partyRoomToUpdate.PartyRoomId);
                oldPartyRoom.AirConditioner  = partyRoomToUpdate.AirConditioner;
                oldPartyRoom.Description     = partyRoomToUpdate.Description;
                oldPartyRoom.LuxuryArmchairs = partyRoomToUpdate.LuxuryArmchairs;
                oldPartyRoom.Name            = partyRoomToUpdate.Name;
                oldPartyRoom.PricePerHour    = partyRoomToUpdate.PricePerHour;
                oldPartyRoom.Screens         = partyRoomToUpdate.Screens;
                oldPartyRoom.Sound           = partyRoomToUpdate.Sound;
                oldPartyRoom.Type            = partyRoomToUpdate.Type;
                oldPartyRoom.VideoBeam       = partyRoomToUpdate.VideoBeam;

                db.SaveChanges();

                return(Ok(oldPartyRoom));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }