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); }
private void initPrices(HotelPrice price) { PriceQ1 = price.PriceQ1; PriceQ2 = price.PriceQ2; PriceQ3 = price.PriceQ3; PriceQ4 = price.PriceQ4; PriceQ5 = price.PriceQ5; }
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(); }
public HotelPricesViewModel(HotelPrice price, HotelInfo info) { Info = new HotelInfoViewModel(info); initPrices(price); }