コード例 #1
0
        public async Task <ActionResult <CustomerCommentGetPagedListResponse> > GetPagedList(
            CustomerCommentGetPagedListRequest request,
            CancellationToken ct = default)
        {
            var customer = await _customersService.GetAsync(request.CustomerId, false, ct);

            var response = await _customerCommentsService.GetPagedListAsync(request, ct);

            return(ReturnIfAllowed(response, Roles.Customers, customer.AccountId));
        }
コード例 #2
0
        public async Task <ActionResult <Customer> > Get([Required] Guid id, CancellationToken ct = default)
        {
            var customer = await _customersService.GetAsync(id, false, ct);

            if (customer == null)
            {
                return(NotFound(id));
            }

            return(ReturnIfAllowed(customer, Roles.Customers, customer.AccountId));
        }
コード例 #3
0
        public async Task <IActionResult> SearchAsync(string customerId)
        {
            if (string.IsNullOrWhiteSpace(customerId))
            {
                return(BadRequest());
            }

            try
            {
                var customer = await customersService.GetAsync(customerId);

                var sales = await salesService.GetAsync(customerId);

                foreach (var sale in sales)
                {
                    foreach (var item in sale.Items)
                    {
                        var product = await productsService.GetAsync(item.ProductId);

                        item.Product = product;
                    }
                }

                var result = new
                {
                    Customer = customer,
                    Sales    = sales
                };
                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        public async Task HandleAsync(OrderCreatedEvent @event, ICorrelationContext context)
        {
            var orderId  = @event.Id.ToString("N");
            var customer = await _customersService.GetAsync(@event.CustomerId);

            var message = MessageBuilder
                          .Create()
                          .WithReceiver(customer.Email)
                          .WithSender(_options.Email)
                          .WithSubject(MessageTemplates.OrderCreatedSubject, orderId)
                          .WithBody(MessageTemplates.OrderCreatedBody, customer.FirstName, customer.LastName, orderId)
                          .Build();
            await _messagesService.SendAsync(message);
        }
コード例 #5
0
        public async Task <IActionResult> SearchAsync(string customerId)
        {
            if (string.IsNullOrEmpty(customerId))
            {
                return(BadRequest());
            }

            try
            {
                var customer = await customersService.GetAsync(customerId);

                var sales = await salesService.GetAsync(customerId);

                //para revolver usamos un objeto dinamico podriamos igual hacer una clase response

                foreach (var sale in sales)
                {
                    foreach (var item in sale.Items)
                    {
                        var product = await productsService.GetAsync(item.ProductId);

                        item.product = product;
                    }
                }

                var result = new
                {
                    Customer = customer,
                    Sales    = sales
                };

                return(Ok(result));
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #6
0
        public async Task <IActionResult> SearchAsync(string customerId)
        {
            if (string.IsNullOrEmpty(customerId))
            {
                return(BadRequest());
            }

            try
            {
                var customer = await _customersService.GetAsync(customerId);

                var sales = await _salesService.GetAsync(customerId);

                //aquí utilizamos la creación de un objeto en tipo dinámico
                var result = new
                {
                    Customer = customer,
                    Sales    = sales
                };

                foreach (var sale in sales)
                {
                    foreach (var item in sale.Items)
                    {
                        var product = await _productsService.GetAsync(item.ProductId);

                        item.Product = product;
                    }
                }

                return(Ok(result));
            }
            catch (Exception)
            {
            }
            return(NotFound());
        }
コード例 #7
0
 public async Task <IActionResult> Get(Guid id)
 => Single(await _customersService.GetAsync(id), x => x.Id == UserId || IsAdmin);
コード例 #8
0
 public async Task <IActionResult> Get(Guid id)
 => Ok(await _customersService.GetAsync(id));
コード例 #9
0
 public async Task <IActionResult> Index()
 {
     return(View(await _customersService.GetAsync()));
 }
コード例 #10
0
 public async Task <IActionResult> GetAsync()
 {
     return(Ok(await _customerService.GetAsync()));
 }
コード例 #11
0
 public async void LoadAsync()
 {
     Customers = new ObservableCollection <Customer>(await customersService.GetAsync());
 }
コード例 #12
0
 public async Task OnGetAsync()
 {
     Customers = (await _customersService.GetAsync()).ToList();
 }
コード例 #13
0
 public OrderFaker(ICustomersService customersService, IProductsService productsService)
 {
     RuleFor(x => x.Customer, f => f.PickRandom(customersService.GetAsync().Result));
     RuleFor(x => x.Products, f => f.PickRandom(productsService.GetAsync().Result, f.Random.Number(1, 10)).ToList());
 }
コード例 #14
0
 public async Task <IActionResult> Get()
 => Single(await _customersService.GetAsync(UserId));
コード例 #15
0
 public async Task<IActionResult> Get()
 {
     return Ok(await customersService.GetAsync());
 }
コード例 #16
0
 public async Task <Customer> Get(int id)
 {
     return(await _customersService.GetAsync(id));
 }