public IEnumerable <BookingVM> GetAllBookings() { var mng = new BookingManager(); var bookings = BookingMapper.MapListOfBookings(mng.GetAllBookings()); return(bookings); }
public IEnumerable <BookingVM> GetBookingFromDateRange(DateTime start, DateTime end, int roomId) { var mng = new BookingManager(); var bookings = BookingMapper.MapListOfBookings(mng.GetBookingInRange(start, end)); return(bookings.Where(b => b.RoomId == roomId)); }
public static async Task <Bookingback> BookingHotel(HotelBookInput Value, string SessionID) { try { Bookingback BackData = new Bookingback(); BookingService bookingService = new BookingService(); var data = await bookingService.HotelBooking(Value, SessionID); var OutPutData = data.Data.hotelX.book.booking; BookingMapper serMap = new BookingMapper(); if (data.Data.hotelX.book.errors == null && data.Data.hotelX.book.warnings == null && data.Data.hotelX.book.booking != null) { BackData = serMap.MapResponseofBooking(OutPutData, SessionID); BookingDataEntry db = new BookingDataEntry(); db.SaveSMRBooking(BackData, SessionID); } else { return(new Bookingback()); } return(BackData); } catch (Exception ex) { var requestData = JsonConvert.SerializeObject(ex); LoggerHelper.WriteToFile("c:/HotelsB2C/Logs/SMLogs/BookingException", "BookingException_" + SessionID, "BookingException", requestData); return(new Bookingback()); } }
/// <summary> /// Initializes a DataAccessFacade for accessing a MS SQL database /// </summary> /// <param name="test">For integration tests, set test = true to use test database</param> public DataAccessFacade(bool test = false) { if (!test) { //take the database information from a textfile. connectionString = File.ReadAllText("C:\\ConnectString.txt"); } else { connectionString = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=LTTEST;Integrated Security=True"; } //Creates a new instance of the mappers with the connection information paymentMapper = new PaymentMapper(connectionString); customerMapper = new CustomerMapper(connectionString); supplierMapper = new SupplierMapper(connectionString); bookingMapper = new BookingMapper(connectionString); paymentRuleMapper = new PaymentRuleMapper(connectionString); PartyMapper partyMapper = new PartyMapper(); partyMapper.CustomerMapper = customerMapper; partyMapper.SupplierMapper = supplierMapper; paymentMapper.PartyMapper = partyMapper; bookingMapper.CustomerMapper = customerMapper; bookingMapper.SupplierMapper = supplierMapper; paymentRuleMapper.CustomerMapper = customerMapper; paymentRuleMapper.SupplierMapper = supplierMapper; customerMapper.ReadAll(); supplierMapper.ReadAll(); }
public async Task <BookingResponse> CreateInView(BookingDTO newBooking, Guid viewId) { var isAdmin = _aadService.IsAdmin(); var booking = BookingMapper.Map(newBooking); if (!await _itemRepository.CheckIfAvailableToBook(booking)) { string errorMessage = "Too many concurrent bookings"; Log.Error(errorMessage); return(new BookingResponse(errorMessage)); } if (!isAdmin && !_viewRepository.CheckIfAllowedToBook(booking.ItemId, viewId)) { string errorMessage = $"Item {booking.Item.Name} can't be booked."; Log.Error(errorMessage); return(new BookingResponse(errorMessage)); } try { await _bookingRepository.Create(booking); await _context.SaveChangesAsync(); var showNames = _aadService.IsAdmin() || _viewRepository.GetShowNamesById(viewId); return(new BookingResponse(BookingMapper.Map(booking, showNames))); } catch (Exception ex) { string errorMessage = $"An error occured when creating the booking: {ex.Message}"; Log.Error <string>(ex, "An error occured when creating the booking: {booking}", JsonSerializer.Serialize(booking)); return(new BookingResponse(errorMessage)); } }
/// <summary> /// Initializes a DataAccessFacade for accessing a MS SQL database /// </summary> /// <param name="test">For integration tests, set test = true to use test database</param> public DataAccessFacade(bool test = false) { if (!test) { //take the database information from a textfile. connectionString = File.ReadAllText("C:\\ConnectString.txt"); } else { connectionString = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=LTTEST;Integrated Security=True"; } //Creates a new instance of the mappers with the connection information paymentMapper = new PaymentMapper(connectionString); customerMapper = new CustomerMapper(connectionString); supplierMapper = new SupplierMapper(connectionString); bookingMapper = new BookingMapper(connectionString); paymentRuleMapper = new PaymentRuleMapper(connectionString); PartyMapper partyMapper = new PartyMapper(); partyMapper.CustomerMapper = customerMapper; partyMapper.SupplierMapper = supplierMapper; paymentMapper.PartyMapper = partyMapper; bookingMapper.CustomerMapper = customerMapper; bookingMapper.SupplierMapper = supplierMapper; paymentRuleMapper.CustomerMapper = customerMapper; paymentRuleMapper.SupplierMapper = supplierMapper; customerMapper.ReadAll(); supplierMapper.ReadAll(); }
public IHttpActionResult CreateBooking(BookingVM res) { var mng = new BookingManager(); mng.AddNewBooking(BookingMapper.MapBookingVM(res)); return(Ok(res)); }
public ActionResult Search(int bookingTypeId, string deviationId) { var bookings = BookingRepository.GetItemsByQuery(item => item.BookingTypeId == bookingTypeId); var bookingMapper = new BookingMapper(); var model = bookings.Select(bookingMapper.MapToModel); model.Select(item => item.DeviationId = deviationId); return View(model); }
public IHttpActionResult GetBooking(int id) { var mng = new BookingManager(); var booking = BookingMapper.MapBooking(mng.GetBookingById(id)); if (booking == null) { return(NotFound()); } return(Ok(booking)); }
public async Task UpdateStatus(Guid id, BookingState newStatus, string declineReason) { var bookingRequest = await GetById(id); if (newStatus == BookingState.Approved) { var booking = BookingMapper.Map(bookingRequest); await _bookingRepository.Create(booking); } else { bookingRequest.DeclineReason = declineReason; } bookingRequest.Status = newStatus; _repository.Update(bookingRequest); await _context.SaveChangesAsync(); }
public async Task <Booking> GetBooking(int id) { var entity = await _bookinRepository.Get(id); return(BookingMapper.Map(entity)); }
public async Task <IActionResult> UpdateBooking([FromBody] BookingModel booking) { var updatedBooking = await _bookingService.UpdateBooking(BookingMapper.Map(booking)); return(Ok(updatedBooking)); }
public async Task <IActionResult> AddBooking([FromBody] BookingModel booking) { var newBooking = await _bookingService.AddBooking(BookingMapper.Map(booking)); return(Ok(newBooking)); }
public async Task <Unit> RemoveBooking([FromBody] RemoveBookingDto APayLoad) => await FMediator.Send(BookingMapper.MapToRemoveBookingCommand(APayLoad));
public async Task <AddBookingCommandResult> AddBooking([FromBody] AddBookingDto APayLoad) => await FMediator.Send(BookingMapper.MapToAddBookingCommand(APayLoad));
public ImplementingServiceHotel() : base() { bookingMapper = new BookingMapper(); hotelMapper = new HotelMapper(); roomMapper = new RoomMapper(); }
public async Task <IActionResult> Add([FromBody] BookingModel data) { var dataEntity = await _bookingService.Add(BookingMapper.Map(data)); return(Ok(dataEntity)); }
public async Task <IEnumerable <BookingDTO> > GetByCategory(Guid id) { return((await _bookingRepository.GetByCategory(id)).Select(booking => BookingMapper.Map(booking)).ToList()); }
public BookingProcessor() { _booking = new BookingAccess(); _bmapper = new BookingMapper(); }
public BookingView GetBookingByID(int bookingID) { return(BookingMapper.ToViewEntity(_unitOfWork.BookingRepository.GetById(bookingID))); }
public async Task <Booking> Update(Booking booking) { var data = await _bookingRepository.Update(BookingMapper.Map(booking)); return(booking); }
public async Task <Booking> Get(int id) { var data = await _bookingRepository.Get(id); return(BookingMapper.Map(data)); }
public void MakeBooking(BookingView booking) { booking.LastDayOfBooking = booking.DataOfBooking.AddDays(_unitOfWork.BookingDurationRepository.GetById(1).AmountOfDays); _unitOfWork.BookingRepository.Create(BookingMapper.ToDataEntity(booking)); _unitOfWork.Save(); }
public async Task <Booking> AddBooking(Booking booking) { var addedEntity = await _bookinRepository.Add(BookingMapper.Map(booking)); return(BookingMapper.Map(addedEntity)); }
public async Task <Booking> UpdateBooking(Booking booking) { var updated = await _bookinRepository.Update(BookingMapper.Map(booking)); return(BookingMapper.Map(updated)); }
public async Task <IEnumerable <BookingDTO> > GetByView(Guid viewId) { var showNames = _aadService.IsAdmin() || _viewRepository.GetShowNamesById(viewId); return((await _bookingRepository.GetByView(viewId)).Select(booking => BookingMapper.Map(booking, showNames))); }
public async Task <IActionResult> Update([FromBody] BookingModel data) { var dataUpdate = await _bookingService.Update(BookingMapper.Map(data)); return(Ok()); }
public IEnumerable <BookingView> GetAllBookings() { return(_unitOfWork.BookingRepository.GetAll().Select(obj => BookingMapper.ToViewEntity(obj))); }