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)); }
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)); }
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; } }
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); }
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; } }
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()); }
public async Task <IActionResult> Get(Guid id) => Single(await _customersService.GetAsync(id), x => x.Id == UserId || IsAdmin);
public async Task <IActionResult> Get(Guid id) => Ok(await _customersService.GetAsync(id));
public async Task <IActionResult> Index() { return(View(await _customersService.GetAsync())); }
public async Task <IActionResult> GetAsync() { return(Ok(await _customerService.GetAsync())); }
public async void LoadAsync() { Customers = new ObservableCollection <Customer>(await customersService.GetAsync()); }
public async Task OnGetAsync() { Customers = (await _customersService.GetAsync()).ToList(); }
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()); }
public async Task <IActionResult> Get() => Single(await _customersService.GetAsync(UserId));
public async Task<IActionResult> Get() { return Ok(await customersService.GetAsync()); }
public async Task <Customer> Get(int id) { return(await _customersService.GetAsync(id)); }