Esempio n. 1
0
        public async Task DeleteAsync(int id)
        {
            var category = await _context.Set <Category>().FirstOrDefaultAsync(p => p.Id == id && !p.IsRemoved);

            if (category == null)
            {
                _notificationService.AddValidation("Categoria não encontrada.");
                return;
            }

            category.IsRemoved = true;
            await _context.SaveChangesAsync();
        }
Esempio n. 2
0
 public async Task <List <ExternalProduct> > GetProductsAsync()
 {
     return(await _context
            .Set <ExternalProduct>()
            .Take(100)
            .ToListAsync());
 }
 public async Task <List <CustomerView> > GetCustomersAsync(CustomerStatusType?status)
 {
     return(await _context
            .Set <Customer>()
            .Where(p => !p.IsRemoved && (!status.HasValue || p.Status == status.Value))
            .Select(p => new CustomerView
     {
         Id = p.Id,
         DocumentNumber = p.DocumentNumber,
         Name = p.Name,
         CategoryId = p.CategoryId,
         CategoryName = p.Category.Name,
         Status = p.Status
     })
            .ToListAsync());
 }