private async Task <Notification> EditHotelRoomRate(HotelRoomRate hotelRoomRate, IdentityUser user) { try { var record = await _hotelRoomRateCrudService.GetAsync(hotelRoomRate.Id); record.HotelId = hotelRoomRate.HotelId; record.SingleBed = hotelRoomRate.SingleBed; record.DoubleBed = hotelRoomRate.DoubleBed; record.ExtraBed = hotelRoomRate.ExtraBed; record.AP = hotelRoomRate.AP; record.MAP = hotelRoomRate.MAP; record.ModifiedBy = user.Id; record.ModifiedDate = DateTime.Now; _hotelRoomRateCrudService.Update(record); return(new Notification("success", "Hotel Room Rate updated successfully.")); } catch (Exception exception) { Console.WriteLine(exception.Message); return(new Notification("error", "Hotel Room Rate update failed.")); } }
public Task <List <HotelRoomRate> > Get() { return(Task.Factory.StartNew(() => { var rates = new List <HotelRoomRate>(); var seaViewFirstHalf = new HotelRoomRate { ID = 1, Name = "Sea View", CostPerNight = 300, MaxAdults = 3, ValidFrom = new DateTime(2018, 1, 1), ValidTo = new DateTime(2018, 6, 31) }; rates.Add(seaViewFirstHalf); var seaViewSecondHalf = new HotelRoomRate { ID = 2, Name = "Sea View", CostPerNight = 400, MaxAdults = 3, ValidFrom = new DateTime(2018, 7, 1), ValidTo = new DateTime(2018, 12, 31) }; rates.Add(seaViewSecondHalf); var rubbishTipViewFirstHalf = new HotelRoomRate { ID = 3, Name = "Rubbish Tip View", CostPerNight = 40, MaxAdults = 2, ValidFrom = new DateTime(2018, 1, 1), ValidTo = new DateTime(2018, 4, 31) }; rates.Add(rubbishTipViewFirstHalf); var rubbishTipViewSecondHalf = new HotelRoomRate { ID = 4, Name = "Rubbish Tip View", CostPerNight = 40, MaxAdults = 2, ValidFrom = new DateTime(2018, 9, 1), ValidTo = new DateTime(2018, 12, 31) }; rates.Add(rubbishTipViewSecondHalf); return rates; })); }
public async Task <IActionResult> SaveHotelRoomRate(HotelRoomRate hotelRoomRate) { try { var user = _userManager.GetUserAsync(HttpContext.User).Result; notification = new Notification(); if (hotelRoomRate.Id > 0) { notification = await EditHotelRoomRate(hotelRoomRate, user); } else { await _hotelRoomRateCrudService.InsertAsync(new HotelRoomRate { HotelId = hotelRoomRate.HotelId, SingleBed = hotelRoomRate.SingleBed, DoubleBed = hotelRoomRate.DoubleBed, ExtraBed = hotelRoomRate.ExtraBed, AP = hotelRoomRate.AP, MAP = hotelRoomRate.MAP, CreatedBy = user.Id }); notification.Type = "success"; notification.Message = "Hotel Room Rate created successfully."; } return(Json(notification)); } catch (Exception exception) { notification.Type = "error"; notification.Message = "Hotel Room Rate creation failed."; return(Json(notification)); } }