예제 #1
0
        public ActionResult Decline(UpdateAppointmentCommand command)
        {
            command.SellerUserId = UserId;
            command.NewStatus    = AppointmentStatus.Declined;

            return(UpdateAppointmentStatus(command));
        }
        public async Task <IActionResult> UpdateAppointment(Guid id, UpdateAppointmentModel model)
        {
            if (ModelState.IsValid)
            {
                var cmd    = new UpdateAppointmentCommand(id, model.AppointmentType, model.StartsAt, model.CandidateId, model.VacancyId);
                var result = await _mediator.Send(cmd);

                if (result.IsFailure)
                {
                    ModelState.AddModelError("", result.Error);
                }
                else
                {
                    return(RedirectToAction(nameof(AppointmentController.Index)));
                }
            }

            var candidates = await _mediator.Send(new GetCandidateDropQuery());

            var vacancies = await _mediator.Send(new GetVacanciesDropQuery());

            ViewBag.AppointmentTypes = new SelectList(Enum.GetValues(typeof(AppointmentType)).Cast <AppointmentType>());

            model.Candidates = new SelectList(candidates, "Id", "Text", model.CandidateId);
            model.Vacancies  = new SelectList(vacancies, "Id", "Text", model.VacancyId);

            return(View(model));
        }
        public async Task <IActionResult> Update([FromRoute] long appointmentId, [FromBody] AppointmentViewModel viewModel)
        {
            var query  = new UpdateAppointmentCommand(appointmentId, viewModel);
            var result = await mediator.Send(query);

            return(Ok(result));
        }
예제 #4
0
        public ActionResult Accept(UpdateAppointmentCommand command)
        {
            command.SellerUserId = UserId;
            command.NewStatus    = AppointmentStatus.Accepted;

            return(UpdateAppointmentStatus(command));
        }
예제 #5
0
        private ActionResult UpdateAppointmentStatus(UpdateAppointmentCommand command)
        {
            var handler = new UpdateAppointmentCommandHandler(Context);

            handler.Handle(command);

            return(RedirectToAction("OnProperty", new { id = command.PropertyId }));
        }
        public async void AppointmentShouldThrowNotFoundException()
        {
            var updatedAppointment = new UpdateAppointmentCommand {
                Id = GConst.InvalidId
            };

            var status = await Record.ExceptionAsync(async() => await sut.Handle(updatedAppointment, CancellationToken.None));

            Assert.NotNull(status);
            Assert.Equal(string.Format(GConst.NotFoundExceptionMessage, GConst.Appointment, GConst.InvalidId), status.Message);
        }
        public async void AppointmentShouldThrowReferenceExceptionForInvalidEmployeeId()
        {
            var updatedAppointment = new UpdateAppointmentCommand {
                Id = appointmentId, ServiceId = serviceId, EmployeeId = GConst.InvalidId
            };

            var status = await Record.ExceptionAsync(async() => await sut.Handle(updatedAppointment, CancellationToken.None));

            Assert.NotNull(status);
            Assert.Equal(string.Format(GConst.ReferenceExceptionMessage, GConst.Update, GConst.Appointment, appointmentId, GConst.EmployeeLower, GConst.InvalidId), status.Message);
        }
        public async void AppointmentShouldThrowUpdateExceptionBeforeWorkingHour()
        {
            var updatedAppointment = new UpdateAppointmentCommand
            {
                Id = appointmentId,
                ReservationDate = new DateTime(2019, 09, 09),
                TimeBlockHelper = GConst.InvalidHourBefore,
                EmployeeId      = employeeId,
                ServiceId       = serviceId
            };

            var status = await Record.ExceptionAsync(async() => await sut.Handle(updatedAppointment, CancellationToken.None));

            Assert.NotNull(status);
            Assert.Equal(string.Format(GConst.FailureException, GConst.Update, GConst.Appointment, GConst.InvalidHourBefore, string.Format(GConst.InvalidAppointmentHourException, GConst.ValidStartHour, GConst.ValidEndHour)), status.Message);
        }
        public async void AppointmentShouldUpdateCorrect()
        {
            var updatedAppointment = new UpdateAppointmentCommand
            {
                Id = appointmentId,
                ReservationDate = new DateTime(2019, 09, 09),
                TimeBlockHelper = GConst.ValidHour,
                EmployeeId      = employeeId,
                ServiceId       = serviceId
            };

            var status = Task <Unit> .FromResult(await sut.Handle(updatedAppointment, CancellationToken.None));

            var resultId = context.Appointments.SingleOrDefault(x => x.TimeBlockHelper == GConst.ValidHour).Id;

            Assert.Equal(appointmentId, resultId);
            Assert.Equal(GConst.SuccessStatus, status.Status.ToString());
            Assert.Equal(GConst.ValidCount, context.Appointments.Count());
        }
예제 #10
0
        public async Task <ActionResult> UpdateAppointment([FromBody] UpdateAppointmentCommand command)
        {
            var appointment = await Mediator.Send(command);

            return(Ok(appointment));
        }
예제 #11
0
        public async Task <IActionResult> Update([FromBody] UpdateAppointmentCommand command)
        {
            var updated = await Mediator.Send(command);

            return(updated ? Ok() : NotFound());
        }
 public UpdateAppointmentCommandValidatorTests()
 {
     this.updateValidator = new UpdateAppointmentCommandValidator();
     this.updateCommand   = new UpdateAppointmentCommand();
 }
예제 #13
0
        public async Task <IActionResult> Update(UpdateAppointmentCommand command)
        {
            AppointmentView appointment = await mediator.Dispatch <UpdateAppointmentCommand, AppointmentView>(command, User.GetUserId());

            return(Ok(appointment));
        }
예제 #14
0
 public async Task <IActionResult> Put(UpdateAppointmentCommand command)
 {
     return(Ok(await bus.Send(command)));
 }
 public async Task <ActionResult> Update([FromBody] UpdateAppointmentCommand command)
 => await base.Send(command);