/// <inheritdoc/> public bool Create(CustomerDto customerDto) { try { using (var context = new Connection_Crea_Test_DA()) { Customer customer = new Customer() { CreatedDate = DateTime.UtcNow, Document = customerDto.Document, Email = customerDto.Email, FirtsName = customerDto.FirtsName, LastName = customerDto.LastName, Phone = customerDto.Phone }; context.Customer.Add(customer); return(context.SaveChanges() == 1); } } catch (CustomerWorkerException ex) { throw ex; } }
private Sale GetSale(int id) { try { using (var context = new Connection_Crea_Test_DA()) { return(context.Sale.FirstOrDefault(row => row.ID == id)); } } catch (SaleWorkerException ex) { throw ex; } }
/// <inheritdoc/> public Sale Search(DateTime date) { try { using (var context = new Connection_Crea_Test_DA()) { return(context.Sale.FirstOrDefault(row => row.SaleDate == date)); } } catch (SaleWorkerException ex) { throw ex; } }
private Customer GetCustomer(string document) { try { using (var context = new Connection_Crea_Test_DA()) { return(context.Customer.FirstOrDefault(row => row.Document == document)); } } catch (CustomerWorkerException ex) { throw ex; } }
private Product GetProduct(int id) { try { using (var context = new Connection_Crea_Test_DA()) { return(context.Product.FirstOrDefault(row => row.ID == id)); } } catch (ProductWorkerException ex) { throw ex; } }
/// <inheritdoc/> public CustomerDto SearchByName(string name) { try { using (var context = new Connection_Crea_Test_DA()) { var customer = context.Customer.FirstOrDefault(row => row.FirtsName.Contains(name) || row.LastName.Contains(name)); return(ConvertToDto(customer)); } } catch (CustomerWorkerException ex) { throw ex; } }
/// <inheritdoc/> public CustomerDto Search(int id) { try { using (var context = new Connection_Crea_Test_DA()) { var customer = context.Customer.FirstOrDefault(row => row.ID == id); return(ConvertToDto(customer)); } } catch (CustomerWorkerException ex) { throw ex; } }
/// <inheritdoc/> public SaleDto Search(Guid salesId) { try { using (var context = new Connection_Crea_Test_DA()) { var sale = context.Sale.FirstOrDefault(row => row.SaleGuid == salesId); return(ConvertToDto(sale)); } } catch (SaleWorkerException ex) { throw ex; } }
/// <inheritdoc/> public bool ChangeState(string document, bool enable) { try { using (var context = new Connection_Crea_Test_DA()) { var customer = context.Customer.FirstOrDefault(row => row.Document == document); customer.Enable = enable; return(context.SaveChanges() == 1); } } catch (CustomerWorkerException ex) { throw ex; } }
public bool ChangeState(int id, bool enable) { try { using (var context = new Connection_Crea_Test_DA()) { var Product = context.Product.FirstOrDefault(row => row.ID == id); Product.Enable = enable; return(context.SaveChanges() == 1); } } catch (ProductWorkerException ex) { throw ex; } }
/// <inheritdoc/> public bool Update(SaleDto saleDto) { try { using (var context = new Connection_Crea_Test_DA()) { var Sale = context.Sale.FirstOrDefault(row => row.ID == saleDto.ID); Sale.Quantity = saleDto.Quantity; return(context.SaveChanges() == 1); } } catch (SaleWorkerException ex) { throw ex; } }
public bool ChangeState(int id, States state) { try { using (var context = new Connection_Crea_Test_DA()) { var Sale = context.Sale.FirstOrDefault(row => row.ID == id); Sale.State = state.ToString(); return(context.SaveChanges() == 1); } } catch (SaleWorkerException ex) { throw ex; } }
/// <inheritdoc/> public bool Update(ProductDto productDto) { try { using (var context = new Connection_Crea_Test_DA()) { var Product = context.Product.FirstOrDefault(row => row.ID == productDto.ID); Product.Description = productDto.Description; Product.Name = productDto.Name; Product.UnitPrice = productDto.UnitPrice; Product.UpdatedDate = DateTime.UtcNow; return(context.SaveChanges() == 1); } } catch (ProductWorkerException ex) { throw ex; } }
/// <inheritdoc/> public bool Update(CustomerDto customerDto) { try { using (var context = new Connection_Crea_Test_DA()) { var customer = context.Customer.FirstOrDefault(row => row.Document == customerDto.Document); customer.Email = customerDto.Email; customer.FirtsName = customerDto.FirtsName; customer.LastName = customerDto.LastName; customer.Phone = customerDto.Phone; customer.UpdatedDate = DateTime.UtcNow; return(context.SaveChanges() == 1); } } catch (CustomerWorkerException ex) { throw ex; } }
/// <inheritdoc/> public bool Create(ProductDto productDto) { try { using (var context = new Connection_Crea_Test_DA()) { Product product = new Product() { CreatedDate = DateTime.UtcNow, Description = productDto.Description, Name = productDto.Name, UnitPrice = productDto.UnitPrice }; context.Product.Add(product); return(context.SaveChanges() == 1); } } catch (ProductWorkerException ex) { throw ex; } }
public bool Create(SaleDto saleDto) { try { using (var context = new Connection_Crea_Test_DA()) { Sale sale = new Sale() { SaleDate = DateTime.UtcNow, SaleGuid = saleDto.SalesGuid, CustomerID = saleDto.CustomerID, ProductID = saleDto.ProductID, Quantity = saleDto.Quantity }; context.Sale.Add(sale); return(context.SaveChanges() == 1); } } catch (SaleWorkerException ex) { throw ex; } }
/// <inheritdoc/> public ProductDto Search(string name) { try { using (var context = new Connection_Crea_Test_DA()) { var product = context.Product.FirstOrDefault(row => row.Name.Contains(name)); ProductDto productDto = new ProductDto() { Description = product.Description, Enable = Convert.ToBoolean(product.Enable), ID = product.ID, Name = product.Name, UnitPrice = product.UnitPrice }; return(productDto); } } catch (ProductWorkerException ex) { throw ex; } }