示例#1
0
        public IActionResult AvailableCars(
            int id,
            string receptionDate,
            string returnDate,
            int receptionCityId,
            int receptionLocationId,
            int returnCityId,
            int returnLocationId
            )
        {
            var model = new ConfirmReservation
            {
                Car             = _carRepository.GetById(id),
                ReservationForm = new ReservationForm
                {
                    ReceptionDate       = Convert.ToDateTime(receptionDate),
                    ReturnDate          = Convert.ToDateTime(returnDate),
                    ReceptionCityId     = receptionCityId,
                    ReceptionLocationId = receptionLocationId,
                    ReturnCityId        = returnCityId,
                    ReturnLocationId    = returnLocationId
                },
                ReservationDetails = new ReservationDetails
                {
                    ReceptionCity     = _cityRepository.GetById(receptionCityId).Name,
                    ReceptionLocation = _locationRepository.GetById(receptionLocationId).Name,
                    ReturnCity        = _cityRepository.GetById(returnCityId).Name,
                    ReturnLocation    = _locationRepository.GetById(returnLocationId).Name,
                }
            };

            return(View("ConfirmReservation", model));
        }
示例#2
0
        public void ConfirmReservation_TrueGuid_ConfirmReservation()
        {
            var confirmReservation = new ConfirmReservation
            {
                Id         = 1,
                Guid       = Guid.Parse("11111111-1111-1111-1111-111111111111"),
                ExpireDate = new DateTime(2008, 11, 11, 8, 0, 0, DateTimeKind.Unspecified),
                IsConfirm  = false
            };
            // arrange
            var confirmReservationManagerMock = new Mock <IConfirmReservation>();

            confirmReservationManagerMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(confirmReservation);
            confirmReservationManagerMock.Setup(m => m.Update(It.IsAny <ConfirmReservation>())).Verifiable();

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(m => m.ConfirmReservationManager).Returns(confirmReservationManagerMock.Object);
            var clockMock = new Mock <IClock>();

            clockMock.Setup(m => m.CurentUtcDateTime()).Returns(new DateTime(2008, 11, 11, 8, 0, 0, DateTimeKind.Utc));

            var reservationService = new ReservationService(unitOfWorkMock.Object, clockMock.Object);

            // act
            var actual = reservationService.Confirm(Guid.Parse("11111111-1111-1111-1111-111111111111"));

            // assert
            actual.Should().NotBeNull();
            confirmReservationManagerMock.VerifyAll();
            actual.Succedeed.Should().BeTrue();
        }
示例#3
0
        public static bool ConfirmReservation(Reservation reservation, ConfirmReservation confirmReservation)
        {
            //Intialise Parameters
            SmtpClient client = new SmtpClient();

            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.EnableSsl      = true;
            client.Host           = "smtp.gmail.com";
            client.Port           = 587;
            // setup Smtp authentication
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential("*****@*****.**", "12345Qaz");
            client.UseDefaultCredentials = false;
            client.Credentials           = credentials;
            //can be obtained from your model
            MailMessage msg = new MailMessage();

            msg.From = new MailAddress("*****@*****.**");
            msg.To.Add(new MailAddress(reservation.ApplicationUser.Email));

            msg.Subject    = "Confirm reservation";
            msg.IsBodyHtml = true;
            msg.Body       = string.Format("<html><head></head><body>Зы забранировали место на время {1} - {2} у мастера {3}. Для подтверждения бронирования перейдите по ссылке <a href='http://localhost:8080/confirm/{0}'>Подтвердить<a/></body>", confirmReservation.Guid, reservation.DateStart.ToLocalTime().ToString("MM/dd/yyyy H:mm:ss"), reservation.DateEnd.ToLocalTime().ToString("MM/dd/yyyy H:mm:ss"), reservation.Worker.FirstName + " " + reservation.Worker.SurName);
            try
            {
                client.Send(msg);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
示例#4
0
        public void ConfirmReservation_ExpireConfirmDate_FalseResult()
        {
            var confirmReservation = new ConfirmReservation
            {
                Id         = 1,
                Guid       = Guid.Parse("11111111-1111-1111-1111-111111111111"),
                ExpireDate = new DateTime(2008, 11, 11, 8, 0, 0, DateTimeKind.Unspecified),
                IsConfirm  = false
            };
            // arrange
            var confirmReservationManagerMock = new Mock <IConfirmReservation>();

            confirmReservationManagerMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(confirmReservation);

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(m => m.ConfirmReservationManager).Returns(confirmReservationManagerMock.Object);
            var clockMock = new Mock <IClock>();

            clockMock.Setup(m => m.CurentUtcDateTime()).Returns(new DateTime(2008, 11, 11, 8, 0, 0, DateTimeKind.Utc).AddMinutes(1));

            var reservationService = new ReservationService(unitOfWorkMock.Object, clockMock.Object);

            // act
            var actual = reservationService.Confirm(Guid.Parse("11111111-1111-1111-1111-111111111111"));

            // assert
            actual.Should().NotBeNull();
            actual.Succedeed.Should().BeFalse();
            actual.Message.Should().Be("Error guid or time extire");
        }
示例#5
0
        public async Task <BaseResponseMessage> ConfirmReservationService(RequestConfirmReservation request)
        {
            ConfirmReservation op = new ConfirmReservation(request);

            op.Execute();

            return(op.baseResponseMessage);
        }
示例#6
0
        public void ReservationTimes_DateWithUnspecifiedKind_ReturnDateWithUTCKind()
        {
            // arrange
            var worker = new Worker {
                FirstName = "Ivan", SurName = "Ivanov", Id = 1, Email = "*****@*****.**", Telephone = "+375251234567"
            };


            var confirm = new ConfirmReservation {
                IsConfirm = true
            };

            var workers = new List <Worker>();

            workers.AddRange(new Worker[] {
                worker
            });
            var worker1reservation1 = new Reservation
            {
                Worker             = worker,
                DateStart          = new DateTime(2008, 09, 2, 22, 0, 0, DateTimeKind.Unspecified),
                DateEnd            = new DateTime(2008, 09, 3, 2, 0, 0, DateTimeKind.Unspecified),
                ConfirmReservation = confirm
            };
            var reservation = new List <Reservation>();

            reservation.AddRange(new Reservation[] {
                worker1reservation1
            });
            var workerManagerMock = new Mock <IWorkerManager>();

            workerManagerMock.Setup(m => m.Get()).Returns(workers);

            var reservationManagerMock = new Mock <IReservationManager>();

            reservationManagerMock.Setup(m => m.Get()).Returns(reservation);

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(m => m.WorkerManager).Returns(workerManagerMock.Object);
            unitOfWorkMock.Setup(m => m.ReservationManager).Returns(reservationManagerMock.Object);

            var clockMock = new Mock <IClock>();

            clockMock.Setup(m => m.CurentUtcDateTime()).Returns(new DateTime(2008, 09, 3, 12, 0, 0).ToUniversalTime());

            var workerService = new WorkerService(unitOfWorkMock.Object, clockMock.Object);

            // act
            var actual = workerService.ReservationTimes(worker.Id);

            // assert
            actual.Should().NotBeNull();
            actual.Times.First().EndTime.Kind.Should().Be(DateTimeKind.Utc);
            actual.Times.First().StartTime.Kind.Should().Be(DateTimeKind.Utc);
        }
    public async Task <IActionResult> Confirm(Guid id)
    {
        var command = ConfirmReservation.Create(
            id
            );

        await commandBus.Send(command);

        return(Ok());
    }
        public void ShowReservationDialog()
        {
            ReservationDialog          = new ConfirmReservation();
            ReservationDialog.IsActive = true;
            Task.Run(() => {
                LiveInstance.ConfirmReservation(Content.Id, ReservationDialog);
                ReservationDialog.IsActive = false;

                App.ViewModelRoot.Messenger.Raise(new TransitionMessage(typeof(Views.Contents.Live.ReservationDialog), this, TransitionMode.Modal));
            });
        }
        public async Task <Unit> Handle(ConfirmReservation command, CancellationToken cancellationToken)
        {
            Guard.Against.Null(command, nameof(command));

            var reservation = await repository.Find(command.ReservationId, cancellationToken);

            reservation.Confirm();

            await repository.Update(reservation, cancellationToken);

            return(Unit.Value);
        }
        public async Task <OperationDetails> Create(ReservationDTO model, string curentUserId, string pathFolder)
        {
            var curentUser = await _database.UserManager.FindByIdAsync(curentUserId);

            var reservation = new Reservation
            {
                ApplicationUser  = curentUser,
                Worker           = _database.WorkerManager.Get().Find(s => s.Id == model.WorkerId),
                Purpose          = model.Purpose,
                BreakdownDetails = model.BreakdownDetails,
                DesiredDiagnosis = model.DesiredDiagnosis,
            };
            var isVerify = await verifyCaptcha(model.Captcha);

            if (!isVerify)
            {
                return(new OperationDetails(false, "Error captcha", ""));
            }
            else if (model.IsEmergency)
            {
                DateTime startTime;
                DateTime endTime;
                var      worker = GetEmergencyTime(out startTime, out endTime);
                reservation.DateStart = startTime;
                reservation.DateEnd   = endTime;
                reservation.Worker    = _database.WorkerManager.Get().Find(s => s.Id == worker);
            }
            else
            {
                if (await verifyTime(model.WorkerId, model.StartTime, model.EndTime))
                {
                    reservation.DateStart = model.StartTime;
                    reservation.DateEnd   = model.EndTime;
                }
                else
                {
                    return(new OperationDetails(false, "Error date", ""));
                }
            }
            _database.ReservationManager.Create(reservation);
            await UploadImage(model.File, reservation, pathFolder);

            var confirmReservation = new ConfirmReservation {
                Id = reservation.Id, Guid = Guid.NewGuid(), Reservation = reservation, IsConfirm = false, ExpireDate = _clock.CurentUtcDateTime().AddMinutes(5)
            };

            _database.ConfirmReservationManager.Create(confirmReservation);
            SendEmail.ConfirmReservation(reservation, confirmReservation);
            return(new OperationDetails(true, "", ""));
        }
        public void RaisesReservationConfirmed()
        {
            var reservationId = Guid.NewGuid();
            var history       = new object[]
            {
                new TicketsRequested(reservationId, Guid.NewGuid(), 4, DateTime.UtcNow.AddMinutes(-2)),
            };

            var state   = ReservationState.Apply(history);
            var command = new ConfirmReservation(reservationId);
            var events  = Reservation.Handle(state, command).ToList();

            Assert.Single(events);
            Assert.IsType <ReservationConfirmed>(events.Single());
        }
示例#12
0
 private static void ConfirmarReserva(object sender, EventArgs e)
 {
     if (asientosReserva.Count > 0)
     {
         ConfirmReservation info = new ConfirmReservation(formTemp, reservaTemp, span);
         info.listaAsientoPrecio = Clonar(asientosReserva);
         info.listaAsientoPrecio.ForEach(ap => {
             lAsientoTotal.ForEach(a =>
             {
                 if (a.Asiento.IdAsiento == ap.Asiento.IdAsiento)
                 {
                     ap.Zona = a.Zona;
                 }
             });
         });
         info.ShowDialog();
     }
     else
     {
         MessageBox.Show("Debe seleccionar al menos un asiento", "Aviso");
     }
 }
示例#13
0
 public void Handle(ICommandContext context, ConfirmReservation command)
 {
     context.Get <Order>(command.AggregateRootId).ConfirmReservation(command.IsReservationSuccess);
 }
示例#14
0
 // Dependency example
 public void When(ConfirmReservation command, Emailer emailer)
 {
     Console.WriteLine($"\t---Handling {command.GetType().Name}---");
     emailer.Send();
 }
示例#15
0
 public void Create(ConfirmReservation item)
 {
     _db.ConfirmReservation.Add(item);
     _db.SaveChanges();
 }
        public static IEnumerable <object> Handle(ReservationState state, ConfirmReservation _)
        {
            var confirmedOn = DateTime.UtcNow;

            yield return(new ReservationConfirmed(state.Id, state.TicketId, state.QuantityReserved, confirmedOn));
        }
示例#17
0
 public void Update(ConfirmReservation item)
 {
     _db.Entry(item).State = EntityState.Modified;
     _db.SaveChanges();
 }
示例#18
0
        public void ReservationTimes_DataList_ReturnListTimesDTO()
        {
            // arrange
            var worker = new Worker {
                FirstName = "Ivan", SurName = "Ivanov", Id = 1, Email = "*****@*****.**", Telephone = "+375251234567"
            };
            var worker2 = new Worker {
                FirstName = "Sergeev", SurName = "Sergey", Id = 2, Email = "*****@*****.**", Telephone = "+375251234568"
            };

            var confirm = new ConfirmReservation {
                IsConfirm = true
            };

            var workers = new List <Worker>();

            workers.AddRange(new Worker[] {
                worker
            });
            var worker1reservation1 = new Reservation
            {
                Worker             = worker,
                DateStart          = new DateTime(2008, 09, 2, 22, 0, 0, DateTimeKind.Unspecified),
                DateEnd            = new DateTime(2008, 09, 3, 2, 0, 0, DateTimeKind.Unspecified),
                ConfirmReservation = confirm
            };
            var reservation = new List <Reservation>();

            reservation.AddRange(new Reservation[] {
                worker1reservation1
            });
            var workerManagerMock = new Mock <IWorkerManager>();

            workerManagerMock.Setup(m => m.Get()).Returns(workers);

            var reservationManagerMock = new Mock <IReservationManager>();

            reservationManagerMock.Setup(m => m.Get()).Returns(reservation);

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(m => m.WorkerManager).Returns(workerManagerMock.Object);
            unitOfWorkMock.Setup(m => m.ReservationManager).Returns(reservationManagerMock.Object);

            var clockMock = new Mock <IClock>();

            clockMock.Setup(m => m.CurentUtcDateTime()).Returns(new DateTime(2008, 09, 3, 12, 0, 0).ToUniversalTime());

            var workerService = new WorkerService(unitOfWorkMock.Object, clockMock.Object);

            // act
            var actual = workerService.ReservationTimes(worker.Id);

            // assert
            var expectedTimeResult = reservation.Select(s => {
                return(new TimeDTO
                {
                    StartTime = DateTime.SpecifyKind(s.DateStart, DateTimeKind.Utc),
                    EndTime = DateTime.SpecifyKind(s.DateEnd, DateTimeKind.Utc)
                });
            }).ToList <TimeDTO>();

            actual.ShouldBeEquivalentTo(new TimesDTO
            {
                WorkerId = worker.Id,
                Times    = expectedTimeResult
            });
        }
示例#19
0
        public void WorkerTimes_DateBeforAndAfterCurentDate_ReturnDatesOnlyAfterCurentDate()
        {
            // arrange
            var worker = new Worker {
                FirstName = "Ivan", SurName = "Ivanov", Id = 1, Email = "*****@*****.**", Telephone = "+375251234567"
            };


            var confirm = new ConfirmReservation {
                IsConfirm = true
            };

            var workers = new List <Worker>();

            workers.AddRange(new Worker[] {
                worker
            });
            var worker1time1 = new WorkTime
            {
                Worker    = worker,
                DateStart = new DateTime(2008, 09, 3, 6, 0, 0, DateTimeKind.Unspecified),
                DateEnd   = new DateTime(2008, 09, 3, 10, 0, 0, DateTimeKind.Unspecified)
            };
            var worker1time2 = new WorkTime
            {
                Worker    = worker,
                DateStart = new DateTime(2008, 09, 4, 10, 0, 0, DateTimeKind.Unspecified),
                DateEnd   = new DateTime(2008, 09, 4, 20, 0, 0, DateTimeKind.Unspecified)
            };

            var workTime = new List <WorkTime>();

            workTime.AddRange(new WorkTime[] {
                worker1time1,
                worker1time2
            });
            var workerManagerMock = new Mock <IWorkerManager>();

            workerManagerMock.Setup(m => m.Get()).Returns(workers);

            var workTimeManagerMock = new Mock <IWorkTimeManager>();

            workTimeManagerMock.Setup(m => m.Get()).Returns(workTime);

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(m => m.WorkerManager).Returns(workerManagerMock.Object);
            unitOfWorkMock.Setup(m => m.WorkTimeManager).Returns(workTimeManagerMock.Object);

            var curentDate = new DateTime(2008, 09, 4, 12, 0, 0).ToUniversalTime();
            var clockMock  = new Mock <IClock>();

            clockMock.Setup(m => m.CurentUtcDateTime()).Returns(curentDate);

            var workerService = new WorkerService(unitOfWorkMock.Object, clockMock.Object);

            // act
            var actual = workerService.WorkerTimes(worker.Id);

            // assert
            var expectedTimeResult = workTime.Where(s => DateTime.SpecifyKind(s.DateEnd, DateTimeKind.Utc) >= curentDate).Select(s => {
                return(new TimeDTO
                {
                    StartTime = DateTime.SpecifyKind(s.DateStart, DateTimeKind.Utc),
                    EndTime = DateTime.SpecifyKind(s.DateEnd, DateTimeKind.Utc)
                });
            }).ToList <TimeDTO>();

            actual.ShouldBeEquivalentTo(new TimesDTO
            {
                WorkerId = worker.Id,
                Times    = expectedTimeResult
            });
        }
示例#20
0
        public async Task HandleAsync(ICommandContext context, ConfirmReservation command)
        {
            var order = await context.GetAsync <Order>(command.AggregateRootId);

            order.ConfirmReservation(command.IsReservationSuccess);
        }
示例#21
0
        public void WorkerTimes_ErrorIdParams_ReturnNull()
        {
            // arrange
            var worker = new Worker {
                FirstName = "Ivan", SurName = "Ivanov", Id = 1, Email = "*****@*****.**", Telephone = "+375251234567"
            };


            var confirm = new ConfirmReservation {
                IsConfirm = true
            };

            var workers = new List <Worker>();

            workers.AddRange(new Worker[] {
                worker
            });
            var worker1time1 = new WorkTime
            {
                Worker    = worker,
                DateStart = new DateTime(2008, 09, 3, 6, 0, 0, DateTimeKind.Unspecified),
                DateEnd   = new DateTime(2008, 09, 3, 10, 0, 0, DateTimeKind.Unspecified)
            };
            var worker1time2 = new WorkTime
            {
                Worker    = worker,
                DateStart = new DateTime(2008, 09, 4, 10, 0, 0, DateTimeKind.Unspecified),
                DateEnd   = new DateTime(2008, 09, 4, 20, 0, 0, DateTimeKind.Unspecified)
            };

            var workTime = new List <WorkTime>();

            workTime.AddRange(new WorkTime[] {
                worker1time1,
                worker1time2
            });
            var workerManagerMock = new Mock <IWorkerManager>();

            workerManagerMock.Setup(m => m.Get()).Returns(workers);

            var workTimeManagerMock = new Mock <IWorkTimeManager>();

            workTimeManagerMock.Setup(m => m.Get()).Returns(workTime);

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(m => m.WorkerManager).Returns(workerManagerMock.Object);
            unitOfWorkMock.Setup(m => m.WorkTimeManager).Returns(workTimeManagerMock.Object);

            var clockMock = new Mock <IClock>();

            clockMock.Setup(m => m.CurentUtcDateTime()).Returns(new DateTime(2008, 09, 3, 12, 0, 0).ToUniversalTime());

            var workerService = new WorkerService(unitOfWorkMock.Object, clockMock.Object);

            // act
            var actual = workerService.WorkerTimes(-1);

            // assert

            actual.Should().BeNull();
        }