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));
        }
Ejemplo n.º 3
0
        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());
            }
        }
Ejemplo n.º 4
0
        /// <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();
        }
Ejemplo n.º 5
0
        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));
            }
        }
Ejemplo n.º 6
0
        /// <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));
        }
Ejemplo n.º 8
0
 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));
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
        public async Task <Booking> GetBooking(int id)
        {
            var entity = await _bookinRepository.Get(id);

            return(BookingMapper.Map(entity));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> UpdateBooking([FromBody] BookingModel booking)
        {
            var updatedBooking = await _bookingService.UpdateBooking(BookingMapper.Map(booking));

            return(Ok(updatedBooking));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> AddBooking([FromBody] BookingModel booking)
        {
            var newBooking = await _bookingService.AddBooking(BookingMapper.Map(booking));

            return(Ok(newBooking));
        }
Ejemplo n.º 14
0
 public async Task <Unit> RemoveBooking([FromBody] RemoveBookingDto APayLoad)
 => await FMediator.Send(BookingMapper.MapToRemoveBookingCommand(APayLoad));
Ejemplo n.º 15
0
 public async Task <AddBookingCommandResult> AddBooking([FromBody] AddBookingDto APayLoad)
 => await FMediator.Send(BookingMapper.MapToAddBookingCommand(APayLoad));
Ejemplo n.º 16
0
 public ImplementingServiceHotel() : base()
 {
     bookingMapper = new BookingMapper();
     hotelMapper   = new HotelMapper();
     roomMapper    = new RoomMapper();
 }
Ejemplo n.º 17
0
        public async Task <IActionResult> Add([FromBody] BookingModel data)
        {
            var dataEntity = await _bookingService.Add(BookingMapper.Map(data));

            return(Ok(dataEntity));
        }
Ejemplo n.º 18
0
 public async Task <IEnumerable <BookingDTO> > GetByCategory(Guid id)
 {
     return((await _bookingRepository.GetByCategory(id)).Select(booking => BookingMapper.Map(booking)).ToList());
 }
Ejemplo n.º 19
0
 public BookingProcessor()
 {
     _booking = new BookingAccess();
     _bmapper = new BookingMapper();
 }
Ejemplo n.º 20
0
 public BookingView GetBookingByID(int bookingID)
 {
     return(BookingMapper.ToViewEntity(_unitOfWork.BookingRepository.GetById(bookingID)));
 }
Ejemplo n.º 21
0
        public async Task <Booking> Update(Booking booking)
        {
            var data = await _bookingRepository.Update(BookingMapper.Map(booking));

            return(booking);
        }
Ejemplo n.º 22
0
        public async Task <Booking> Get(int id)
        {
            var data = await _bookingRepository.Get(id);

            return(BookingMapper.Map(data));
        }
Ejemplo n.º 23
0
 public void MakeBooking(BookingView booking)
 {
     booking.LastDayOfBooking = booking.DataOfBooking.AddDays(_unitOfWork.BookingDurationRepository.GetById(1).AmountOfDays);
     _unitOfWork.BookingRepository.Create(BookingMapper.ToDataEntity(booking));
     _unitOfWork.Save();
 }
Ejemplo n.º 24
0
        public async Task <Booking> AddBooking(Booking booking)
        {
            var addedEntity = await _bookinRepository.Add(BookingMapper.Map(booking));

            return(BookingMapper.Map(addedEntity));
        }
Ejemplo n.º 25
0
        public async Task <Booking> UpdateBooking(Booking booking)
        {
            var updated = await _bookinRepository.Update(BookingMapper.Map(booking));

            return(BookingMapper.Map(updated));
        }
Ejemplo n.º 26
0
        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)));
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> Update([FromBody] BookingModel data)
        {
            var dataUpdate = await _bookingService.Update(BookingMapper.Map(data));

            return(Ok());
        }
Ejemplo n.º 28
0
 public IEnumerable <BookingView> GetAllBookings()
 {
     return(_unitOfWork.BookingRepository.GetAll().Select(obj => BookingMapper.ToViewEntity(obj)));
 }