Esempio n. 1
0
        private bool ParseResult(IReservationRequest request, SqlMapper.GridReader reader)
        {
            if ((request == null) || (reader == null))
            {
                return(false);
            }
            if (request.Value == null)
            {
                return(false);
            }
            try
            {
                request.ResquestReasonDto = SelectionHelpers.WrappedSelectedDto <MOPETI, RequestReasonDto>(request.Value.MOPETI, _mapper, reader);
                request.OfficeDto         = SelectionHelpers.WrappedSelectedDto <OFICINAS, OfficeDtos>(request.Value.OFICINA, _mapper, reader);
                request.ClientDto         = SelectionHelpers.WrappedSelectedDto <ClientSummaryExtended, ClientSummaryExtended>(request.Value.CLIENTE, _mapper, reader);
                request.ResellerDto       = SelectionHelpers.WrappedSelectedDto <VENDEDOR, ResellerDto>(request.Value.VENDEDOR, _mapper, reader);
                request.FareDto           = SelectionHelpers.WrappedSelectedDto <NTARI, FareDto>(request.Value.TARIFA, _mapper, reader);
                request.CompanyDto        = SelectionHelpers.WrappedSelectedDto <SUBLICEN, CompanyDto>(request.Value.SUBLICEN, _mapper, reader);
                request.GroupDto          = SelectionHelpers.WrappedSelectedDto <GRUPOS, VehicleGroupDto>(request.Value.CATEGO, _mapper, reader);
                request.OriginDto         = SelectionHelpers.WrappedSelectedDto <ORIGEN, OrigenDto>(request.Value.ORIGEN, _mapper, reader);
                request.VehicleDto        = SelectionHelpers.WrappedSelectedDto <VehicleSummaryDto, VehicleSummaryDto>(request.Value.OTRO_VEHI, _mapper, reader);


#pragma warning disable CS0168 // Variable is declared but never used
            }
            catch (System.Exception ex)
#pragma warning restore CS0168 // Variable is declared but never used
            {
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        public NewReservationSummery New(IReservationRequest reservationReq)
        {
            string       newGuid     = Guid.NewGuid().ToString("N").Substring(0, 5);
            IReservation reservation = reservationRepo.GetRestInfo(reservationReq.ProjectionId);

            bool isActive = true;

            IReservation newReservetion = reservationRepo.Insert(new Reservation(
                                                                     reservationReq.ProjectionId,
                                                                     newGuid,
                                                                     reservation.ProjectionStartDate,
                                                                     reservation.MovieName,
                                                                     reservation.CinemaName,
                                                                     reservation.RoomNum,
                                                                     reservationReq.Row,
                                                                     reservationReq.Column,
                                                                     isActive));

            IReservationTicket reservetionTicket = new ReservationTicketModel(
                newGuid,
                reservation.ProjectionStartDate,
                reservation.MovieName,
                reservation.CinemaName,
                reservation.RoomNum,
                reservationReq.Row,
                reservationReq.Column
                );

            return(new NewReservationSummery(true, reservetionTicket));
        }
Esempio n. 3
0
        public async Task <bool> SaveAsync(IReservationRequest bookingData)
        {
            if (!bookingData.Valid)
            {
                return(false);
            }
            var savedReservation = await _dataSaver.SaveAsync(bookingData.Value).ConfigureAwait(false);

            return(savedReservation);
        }
        public NewReservationSummery New(IReservationRequest reservation)
        {
            IRoom room = roomRepo.GetRowsAndSeatsPerRow(reservation.ProjectionId);

            if (reservation.Row <= 0 || reservation.Column <= 0 || reservation.Row > room.Rows || reservation.Column > room.SeatsPerRow)
            {
                return(new NewReservationSummery(false, $"This seat doesn`t exist. This room has Rows: {room.Rows} and Seats per row: {room.SeatsPerRow}"));
            }

            return(newReserv.New(reservation));
        }
Esempio n. 5
0
        public async Task <bool> DeleteAsync(IReservationRequest booking)
        {
            if (!booking.Valid)
            {
                return(false);
            }
            var dto    = booking.Value;
            var result = await _dataDeleter.DeleteAsync(dto).ConfigureAwait(false);

            return(result);
        }
Esempio n. 6
0
        public NewReservationSummery New(IReservationRequest reservation)
        {
            IEnumerable <IReservation> reservationsSits = reservationRepo.GetRowsColsById(reservation.ProjectionId);

            foreach (var reserv in reservationsSits)
            {
                if (reservation.Row == reserv.Row && reservation.Column == reserv.Column)
                {
                    return(new NewReservationSummery(false, "This seat is already taken!"));
                }
            }

            return(newReserv.New(reservation));
        }
        public NewReservationSummery New(IReservationRequest reservation)
        {
            IProjection projection = projectionRepo.GetById(reservation.ProjectionId);
            var         now        = DateTime.UtcNow;

            if (projection == null)
            {
                return(new NewReservationSummery(false, $"Projection with id {reservation.ProjectionId} does not exist"));
            }
            var tenMinBeforStart = projection.StartDate.AddMinutes(-10);

            if (projection.StartDate <= now || now > tenMinBeforStart)
            {
                return(new NewReservationSummery(false, $"You can not make reservation for projection that is already started or there is less then 10 minutes to start."));
            }

            return(newReserv.New(reservation));
        }
Esempio n. 8
0
        public async Task <GlobalRule> CheckReservationAgainstRules(IReservationRequest request)
        {
            var resultsList = await _repository.FindActive(request.CreatedDate);

            resultsList = resultsList
                          .Where(r => r.RuleType != (byte)GlobalRuleType.DynamicPause || r.ActiveTo > request.StartDate)
                          .Where(r => !r.GlobalRuleAccountExemptions?.Any(e => e.AccountId == request.AccountId) ?? true)
                          .ToList();

            if (resultsList == null || !resultsList.Any())
            {
                return(await CheckAccountReservationLimit(request.AccountId, request.IsLevyAccount));
            }

            foreach (var result in resultsList)
            {
                var globalRule  = new GlobalRule(result);
                var reservation = new Reservation(
                    request.Id,
                    request.AccountId,
                    request.StartDate,
                    _options.ExpiryPeriodInMonths,
                    request.AccountLegalEntityName,
                    request.CourseId,
                    request.ProviderId,
                    request.AccountLegalEntityId,
                    request.IsLevyAccount,
                    request.TransferSenderAccountId);

                switch (globalRule.Restriction)
                {
                case AccountRestriction.All:
                    return(globalRule);

                case AccountRestriction.NonLevy when !reservation.IsLevyAccount:
                    return(globalRule);

                case AccountRestriction.Levy when reservation.IsLevyAccount:
                    return(globalRule);
                }
            }

            return(null);
        }
Esempio n. 9
0
        public async Task <Reservation> CreateAccountReservation(IReservationRequest command)
        {
            var reservation = new Reservation(
                command.Id,
                command.AccountId,
                command.StartDate,
                _options.Value.ExpiryPeriodInMonths,
                command.AccountLegalEntityName,
                command.CourseId,
                command.ProviderId,
                command.AccountLegalEntityId,
                command.IsLevyAccount,
                command.TransferSenderAccountId,
                command.UserId);

            var entity = await _reservationRepository.CreateAccountReservation(MapReservation(reservation));

            var result = MapReservation(entity);

            return(result);
        }
Esempio n. 10
0
 /// <summary>
 ///  when i shall show or insert.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="payload"></param>
 /// <param name="insertion"></param>
 protected void Init(string value, DataPayLoad payload, bool insertion)
 {
     if (payload.DataObject == null)
     {
         return;
     }
     if (!(payload.DataObject is IReservationRequest))
     {
         return;
     }
     _reservationRequest = payload.DataObject as IReservationRequest;
     DataObject          = _reservationRequest.Value;
     ClientDto           = _reservationRequest.ClientDto;
     GroupDto            = _reservationRequest.GroupDto;
     ResellerDto         = _reservationRequest.ResellerDto;
     RequestReasonDto    = _reservationRequest.ResquestReasonDto;
     OfficeDto           = _reservationRequest.OfficeDto;
     CompanyDto          = _reservationRequest.CompanyDto;
     OriginDto           = _reservationRequest.OriginDto;
     FareDto             = _reservationRequest.FareDto;
     VehicleSummaryDto   = _reservationRequest.VehicleDto;
     RegisterToolBar();
     ActiveSubSystem();
 }