Exemplo n.º 1
0
        public ActionResult <IEnumerable <CalculatedTax> > Get()
        {
            var query  = new GetAllCalculatedTaxQuery();
            var result = _mediator.Dispatch(query);

            return(Ok(result));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get()
        {
            var plans = await mediator.Dispatch <GetAllSubscriptionPlansQuery, List <SubscriptionPlanReadModel> >(
                new GetAllSubscriptionPlansQuery(),
                User
                );

            return(Ok(plans));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetCustomer()
        {
            var sub = await mediator.Dispatch <GetCustomerQuery, CustomerReadModel>(
                new GetCustomerQuery(),
                User.GetUserId()
                );

            return(Ok(sub));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetServices()
        {
            List <ServiceView> services = await mediator.Dispatch <GetServicesQuery, List <ServiceView> >(
                new GetServicesQuery(),
                User.GetUserId()
                );

            return(Ok(services));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> GetVehicleCategories()
        {
            List <VehicleCategoryView> categories = await mediator.Dispatch <GetVehicleCategoriesQuery, List <VehicleCategoryView> >(
                new GetVehicleCategoriesQuery(),
                User.GetUserId()
                );

            return(Ok(categories));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> GetAll([FromQuery] int pageNumber, [FromQuery] int pageSize)
        {
            var pads = await mediator.Dispatch <GetAllPadSeriesQuery, PagedCollection <PadSeriesReadModel> >(
                new GetAllPadSeriesQuery(new PagingOptions(pageNumber, pageSize)),
                User
                );

            return(Ok(pads));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Event(Models.QueryMiddlewareModel model, CancellationToken cancellationToken)
        {
            SampleEvent @event = new SampleEvent()
            {
                EventData = model.Name
            };

            await _mediator.Dispatch(@event, cancellationToken);

            return(View());
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Get([FromQuery] string range, [FromQuery] DateTime date)
        {
            AppointmentRange appointmentRange;

            if (!Enum.TryParse(range, true, out appointmentRange))
            {
                return(BadRequest("Invalid range specified"));
            }

            var appointments = await mediator.Dispatch <GetAppointmentsQuery, List <AppointmentView> >(
                new GetAppointmentsQuery()
            {
                Range = appointmentRange, Date = date
            },
                User.GetUserId()
                );

            return(Ok(appointments));
        }
Exemplo n.º 9
0
        public void BasicTest()
        {
            var request = new PreActionHandler.Request {
                Value = "Hello!"
            };

            var result = _mediator.Dispatch(request);

            Assert.AreEqual(nameof(PreActionHandler.RequestRequestPreProcessor), result.Value);
        }
Exemplo n.º 10
0
        public void BasicTest()
        {
            var request = new BasicHandler.Request {
                Value = "Hello!"
            };

            var result = _mediator.Dispatch(request);

            Assert.AreEqual(request.Value, result.Value);
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create(ReviewCreateCommand create)
        {
            var id = await mediator.Dispatch <ReviewCreateCommand, Guid>(
                create,
                User
                );

            var r = await mediator.Dispatch <GetReviewByIdQuery, ReviewReadModel>(new(id));

            return(Ok(r));
        }
        public async Task <Response> Handle(CreateUserCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var newUser = new User(request.Name, request.Surname, request.Birthday, request.Cpf);
                var userId  = await _userRepository.Create(newUser);

                await _mediator.Dispatch(newUser.DomainEvents, cancellationToken);

                var address = new Address(userId, request.StreetName, request.StreetNumber, request.Complement,
                                          request.Cep, request.City, request.State, request.AddressName);
                await _addressRepository.Create(address);

                await _mediator.Dispatch(address.DomainEvents, cancellationToken);

                return(Response.Ok(HttpStatusCode.Created, userId));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Erro ao cadastrar usuário");
                return(Response.Fail(HttpStatusCode.InternalServerError, "Erro ao cadastrar usuário"));
            }
        }
Exemplo n.º 13
0
        public async Task <IActionResult> GetAllPermissions()
        {
            List <PermissionReadModel> perms = await mediator.Dispatch <GetAllPermissionsQuery, List <PermissionReadModel> >(User);

            return(Ok(perms));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> GetClients()
        {
            var clients = await mediator.Dispatch <GetClientsQuery, List <ClientView> >(new GetClientsQuery(), User.GetUserId());

            return(Ok(clients));
        }
 public async Task <IActionResult> Get()
 {
     return(Ok(_mapper.Map <IEnumerable <ValueDTO> >(await _mediator.Dispatch <ValuesQuery, IEnumerable <ValueModel> >())));
 }
Exemplo n.º 16
0
        public async Task <IActionResult> GetAll()
        {
            var brands = await mediator.Dispatch <GetAllBrandsQuery, List <BrandReadModel> >(User);

            return(Ok(brands));
        }
Exemplo n.º 17
0
        public async Task <IActionResult> GetFilter()
        {
            var filter = await mediator.Dispatch <GetPadFilterQuery, PadFilterReadModel>();

            return(Ok(filter));
        }
Exemplo n.º 18
0
 /// <summary>
 /// Dispatch a command or query that has an input, and return value.
 /// </summary>
 public async static Task <TOutput> Dispatch <TInput, TOutput>(this IMediator mediator, TInput input, ClaimsPrincipal?user = null) where TInput : class, IAction
 {
     return(await mediator.Dispatch <TInput, TOutput>(input, user?.GetUserId()));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Dispatch a command or query that doesn't need any input.
 /// </summary>
 public async static Task Dispatch <TInput>(this IMediator mediator, ClaimsPrincipal?user = null) where TInput : class, IAction, new()
 {
     await mediator.Dispatch <TInput>(user?.GetUserId());
 }
Exemplo n.º 20
0
        public async Task <IActionResult> GetBusiness()
        {
            BusinessView b = await mediator.Dispatch <GetBusinessQuery, BusinessView>(new GetBusinessQuery(), User.GetUserId());

            return(Ok(b));
        }
Exemplo n.º 21
0
        public async Task <IActionResult> GetAll()
        {
            var roles = await mediator.Dispatch <GetAllRolesQuery, List <RoleReadModel> >(User);

            return(Ok(roles));
        }
Exemplo n.º 22
0
        public async Task <IActionResult> GetHoursOfOperation()
        {
            HoursOfOperationView?hours = await mediator.Dispatch <GetHoursOfOperationQuery, HoursOfOperationView>(new GetHoursOfOperationQuery(), User.GetUserId());

            return(Ok(hours));
        }
Exemplo n.º 23
0
        public async Task <IActionResult> GetUser()
        {
            var user = await mediator.Dispatch <GetUserByAuth0IdQuery, UserReadModel>(User);

            return(Ok(user));
        }