示例#1
0
        /// <summary>
        /// Adds the reservation.
        /// </summary>
        /// <param name="model">CustomerReservation model from ViewModel in which are customer and reservation to save.</param>
        /// <returns>Returns true if command succeed.</returns>
        public bool Post(CustomerReservation model)
        {
            var customer = _customerService.GetOrAddByData(new CustomerDto()
            {
                CustomerName    = model.Customer.CustomerName,
                CustomerSurname = model.Customer.CustomerSurname,
                Email           = model.Customer.Email,
                Phone           = model.Customer.Phone
            });

            var result = _reservationService.InsertOrUpdate(new ReservationDto()
            {
                ShowingId  = model.Reservation.ShowingId,
                RowSeatId  = model.Reservation.RowSeatId,
                CustomerId = customer.Id,
                Status     = model.Reservation.Status
            });

            if (model.Reservation.Status == 1 && result > 0)
            {
                new TicketController().GetTicket(model.Reservation);
            }

            return(result > 0 ? true : false);
        }
示例#2
0
 public TicketViewModel(CustomerReservation model) : base(model)
 {
     SaveCommand = new SaveReservationCommand(this);
     Reservation.Customer.CustomerName    = "Unknown";
     Reservation.Customer.CustomerSurname = "Unknown";
     Reservation.Reservation.Status       = 1;
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the ReservationViewModel class with existing movie.
 /// </summary>
 /// <param name="model">Reservation to edit.</param>
 public TicketReservationViewModel(CustomerReservation model)
 {
     Reservation = model;
     Controller  = new ReservationController();
     Seats       = Controller.GetSeats(model.Reservation.ShowingId);
     SeatError   = "Wybierz miejsce.";
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the ReservationViewModel class with existing movie.
 /// </summary>
 /// <param name="model">Reservation to edit.</param>
 public ReservationViewModel(CustomerReservation model)
 {
     Reservation = model;
     SaveCommand = new SaveReservationCommand(this);
     Controller  = new ReservationController();
     Seats       = Controller.GetSeats(model.Reservation.ShowingId);
     SeatError   = "Wybierz miejsce.";
 }
示例#5
0
 /// <summary>
 /// Initializes an instance of ChooseShowingModel class.
 /// </summary>
 public ChooseShowingViewModel()
 {
     Controller  = new ShowingController();
     Showings    = Controller.GetActuall(14);
     Reservation = new CustomerReservation();
     //AddReservation = new RelayCommand<object>(AddReservationExecute, AddReservationCanExecute);
     ContinueReservation = new RelayCommand <object>(ContinueReservationExecute, ContinueReservationCanExecute);
 }
        /// <summary>
        /// Confirms the reservation. Changes status from '0' to '1'.
        /// </summary>
        /// <param name="model">with information which reservation should be confirmed.</param>
        /// <returns>Returns true if command succeed.</returns>
        public bool Confirm(CustomerReservation model)
        {
            var result = _reservationService.InsertOrUpdate(new ReservationDto()
            {
                Id         = model.Reservation.Id,
                CustomerId = model.Reservation.CustomerId,
                Status     = 1,
                RowSeatId  = model.Reservation.RowSeatId,
                ShowingId  = model.Reservation.ShowingId
            });

            return(result > 0 ? true : false);
        }
        private async Task UpdatePriceInCustomerReservation(Guid carId, decimal newPrice,
                                                            decimal oldPrice, CustomerReservation reservation)
        {
            if (carId == reservation.Car.Id)
            {
                _logger.LogInformation($"{nameof(CarPricePerDayChangedIntegrationEventHandler)} - Updating car price in reservation for the customer: {reservation.CustomerId}", reservation.CustomerId);

                if (reservation.Car.PricePerDay == oldPrice)
                {
                    reservation.Car.PricePerDay = newPrice;
                }
                await _reservationRepository.UpdateReservationAsync(reservation);
            }
        }
        public async Task <CustomerReservation> UpdateReservationAsync(CustomerReservation reservation)
        {
            var created = await _database.StringSetAsync(reservation.CustomerId.ToString(),
                                                         JsonConvert.SerializeObject(reservation));

            if (!created)
            {
                _logger.LogInformation("Problem occur persisting the reservation.");
                return(null);
            }

            _logger.LogInformation("Reservation persisted succesfully.");

            return(await GetReservationAsync(reservation.CustomerId.ToString()));
        }
示例#9
0
        /// <summary>
        /// Confirms the reservation. Changes status from '0' to '1'.
        /// </summary>
        /// <param name="model">with information which reservation should be confirmed.</param>
        /// <returns>Returns true if command succeed.</returns>
        public bool Confirm(CustomerReservation model)
        {
            var result = _reservationService.InsertOrUpdate(new ReservationDto()
            {
                Id         = model.Reservation.Id,
                CustomerId = model.Reservation.CustomerId,
                Status     = 1,
                RowSeatId  = model.Reservation.RowSeatId,
                ShowingId  = model.Reservation.ShowingId
            });

            if (result > 0)
            {
                new TicketController().GetTicket(model.Reservation);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#10
0
 /// <summary>
 /// Deletes the reservation.
 /// </summary>
 /// <param name="model">ith information which reservation shoud be removed.</param>
 public void Delete(CustomerReservation model)
 {
     _reservationService.Remove(model.Reservation.Id);
 }
示例#11
0
 /// <summary>
 /// Initialize an instance of TicketView class.
 /// </summary>
 /// <param name="model">Model of CustomerReservation Class.</param>
 public TicketView(CustomerReservation model)
 {
     InitializeComponent();
     DataContext = new TicketViewModel(model);
     _this       = this;
 }
示例#12
0
 public void SetUp()
 {
     customerReservation = new CustomerReservation();
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the ReservationViewModel class with existing movie.
 /// </summary>
 /// <param name="model">Reservation to edit.</param>
 public ReservationViewModel(CustomerReservation model) : base(model)
 {
     SaveCommand = new SaveReservationCommand(this);
     Reservation.Reservation.Status = 0;
 }