Ejemplo n.º 1
0
 public async Task AppointmentHandler_Create_SaveAsync()
 {
     //Arrange
     var dateTimeNow = DateTime.Now;
     var command = new CreateAppointmentCommand
     {
         Title = "testTitle",
         Description = "testDescription",
         Latitude = 50.9761276,
         Longitude = 5.8207892,
         Start = dateTimeNow,
         End = dateTimeNow,
         ClientId = 9,
         TenantId = 1
     };
     var mockAppointmentRepository = new Mock<AppointmentRepository>(null);
     //Act
     
     var sut = new CreateAppointmentCommandHandler(mockAppointmentRepository.Object);
     var result = await sut.Handle(command, CancellationToken.None);
     //Assert
     Assert.IsType<int>(result);
     mockAppointmentRepository.Verify(x => x.SaveAsync(It.Is<Appointment>(a => a.Title == command.Title &&
                                                                               a.Description == command.Description &&
                                                                               a.Latitude == command.Latitude &&
                                                                               a.Longitude == command.Longitude &&
                                                                               a.Start == command.Start &&
                                                                               a.End == command.End &&
                                                                               a.ClientId == command.ClientId &&
                                                                               a.TenantId == command.TenantId), It.IsAny<CancellationToken>()), Times.Once);
     mockAppointmentRepository.VerifyNoOtherCalls();
 }
Ejemplo n.º 2
0
        public async Task <JsonResult> GetAvailableAppointments([FromForm] CreateAppointmentCommand command)
        {
            var result = await Mediator.Send(new GetAvailableAppointmentsQuery { Command = command });

            List <SelectListItem> resultlist = result.AvailableAppointments;

            return(Json(resultlist));
        }
        public async Task <IActionResult> Create([FromBody] AppointmentViewModel viewModel)
        {
            var command = new CreateAppointmentCommand(viewModel);
            var result  = await mediator.Send(command);

            var locationUri = uriService.GetAppointmentUri(ApiRoutes.Appointments.Get, result.AppointmentId.ToString());

            return(CreatedAtAction("locationUri", result));
        }
 public GetAvailableAppointmentsQueryHandlerTests()
 {
     ids        = CommandArrangeHelper.GetEmployeeServiceIds(context);
     employeeId = ids[0];
     serviceId  = ids[1];
     userId     = CommandArrangeHelper.GetUserId(context);
     sut        = new GetAvailableAppontmentsQueryHandler(context);
     command    = new CreateAppointmentCommand {
         UserId = userId, ServiceId = serviceId, EmployeeId = employeeId, ReservationDate = new DateTime(2019, 12, 2), TimeBlockHelper = "10:00"
     };
 }
        public async Task <IActionResult> Post([FromHeader] Guid userId, [FromBody] CreateAppointmentCommand command)
        {
            var appointmentId = await appointmentLogic.SaveAppointment(command);

            if (appointmentId == Guid.Empty)
            {
                return(BadRequest());
            }

            return(CreatedAtAction(nameof(GetAppointment), new { id = appointmentId }, appointmentId));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Put(int id, [FromBody] CreateAppointmentCommand command, [FromHeader(Name = "x-requestid")] string requestId)
        {
            bool commandResult = false;

            if (Guid.TryParse(requestId, out Guid guid) && guid != Guid.Empty)
            {
                var requestCancelOrder = new IdentifiedCommand <CreateAppointmentCommand, bool>(command, guid);
                commandResult = await _mediator.Send(requestCancelOrder);
            }
            return(Ok(commandResult));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Workspace(int id)
        {
            var employee = await Mediator.Send(new GetEmployeeProfileByIdQuery { Id = id });

            var command = new CreateAppointmentCommand();
            var employeeAppointmentDto = new EmployeeAppointmentDto
            {
                EmployeeProfileViewModel = employee,
                CreateAppointmentCommand = command
            };

            return(this.View(employeeAppointmentDto));
        }
        public async Task <Guid> SaveAppointment(CreateAppointmentCommand command)
        {
            var appointment = mapper.Map <Entities.Appointment>(command);

            appointment.Id        = Guid.NewGuid();
            appointment.IsActive  = true;
            appointment.Created   = DateTime.UtcNow;
            appointment.CreatedBy = command.CreatedBy;
            appointment.Updated   = DateTime.UtcNow;
            appointment.UpdatedBy = command.CreatedBy;

            await context.Appointment.AddAsync(appointment);

            var rowChanged = await context.SaveChangesAsync();

            if (rowChanged == 0)
            {
                return(Guid.Empty);
            }

            return(appointment.Id);
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([FromForm] CreateAppointmentCommand command)
        {
            await Mediator.Send(command);

            return(this.Redirect("/Appointment/Success"));
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> CreateAppointment([FromBody] CreateAppointmentCommand command)
        {
            var appointment = await Mediator.Send(command);

            return(CreatedAtAction("GetAppointment", new { id = appointment.Id }, appointment));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Add([FromBody] CreateAppointmentCommand command)
        {
            var result = await Mediator.Send(command);

            return(Ok(result));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> CreateAppointment(CreateAppointmentCommand command)
        {
            var createdAppointmentId = await mediator.Send(command);

            return(Created(new Uri("https://localhost:5001/api/Appointments/" + createdAppointmentId), createdAppointmentId));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Create(CreateAppointmentCommand command)
        {
            AppointmentView appointment = await mediator.Dispatch <CreateAppointmentCommand, AppointmentView>(command, User.GetUserId());

            return(Ok(appointment));
        }
 public CreateAppointmentCommandValidatorTests()
 {
     this.createValidator = new CreateAppointmentCommandValidator();
     this.createCommand   = new CreateAppointmentCommand();
 }
Ejemplo n.º 15
0
 public async Task <IActionResult> Post(CreateAppointmentCommand command)
 {
     return(Ok(await bus.Send(command)));
 }