예제 #1
0
        public async Task <HotelPrice> CreatePriceAsync(decimal amount, DateTime date, int roomTypeId)
        {
            var roomType = await Context.RoomTypes.SingleOrDefaultAsync(a => a.Id == roomTypeId);

            if (roomType == null)
            {
                throw new InvalidActionException("Roomtype does not exist");
            }

            if (amount < 0)
            {
                throw new InvalidActionException("Amount cannot be below zero");
            }

            var price = new HotelPrice
            {
                Amount     = amount,
                Date       = date,
                RoomTypeId = roomTypeId
            };

            Context.Prices.Add(price);
            await Context.SaveChangesAsync();

            return(price);
        }
예제 #2
0
 private void initPrices(HotelPrice price)
 {
     PriceQ1 = price.PriceQ1;
     PriceQ2 = price.PriceQ2;
     PriceQ3 = price.PriceQ3;
     PriceQ4 = price.PriceQ4;
     PriceQ5 = price.PriceQ5;
 }
예제 #3
0
        public static decimal?GetRoomPrice(this HotelPrice price, int quality)
        {
            switch (quality)
            {
            case 1:
                return(price.PriceQ1);

            case 2:
                return(price.PriceQ2);

            case 3:
                return(price.PriceQ3);

            case 4:
                return(price.PriceQ4);

            case 5:
                return(price.PriceQ5);
            }
            throw new NotImplementedException();
        }
예제 #4
0
 public HotelPricesViewModel(HotelPrice price, HotelInfo info)
 {
     Info = new HotelInfoViewModel(info);
     initPrices(price);
 }