public async Task CreateAsync(CreateUpdateCustomerCommand createUpdateCustomerCommand) { if (!createUpdateCustomerCommand.IsValid()) { _notificationService.AddValidation("Campos obrigatórios devem ser preenchidos."); return; } var categoryExists = await _context.Set <Category>().AnyAsync(p => p.Id == createUpdateCustomerCommand.CategoryId); if (!categoryExists) { _notificationService.AddValidation("Categoria não encontrada."); return; } var customer = new Customer { Name = createUpdateCustomerCommand.Name, DocumentNumber = createUpdateCustomerCommand.DocumentNumber, CategoryId = createUpdateCustomerCommand.CategoryId, IsRemoved = false, Status = CustomerStatusType.WaitingForApproval, CreationDate = DateTime.Now }; _context.Add(customer); await _context.SaveChangesAsync(); }
public async Task CreateAsync(CreateUpdateCategoryCommand createUpdateCategoryCommand) { if (!createUpdateCategoryCommand.IsValid()) { _notificationService.AddValidation("Campos obrigatórios devem ser preenchidos."); return; } var category = new Category { Name = createUpdateCategoryCommand.Name, IsRemoved = false, CreationDate = DateTime.Now }; _context.Add(category); await _context.SaveChangesAsync(); }