public List <CustomerOptions> GetAllCustomers(string searchCriteria) { using CrmAppDbContext dbContext = new CrmAppDbContext(); List <Customer> customers = dbContext.Customers .Where(customer => customer.FirstName.Contains(searchCriteria) || customer.LastName.Contains(searchCriteria) ) .ToList(); List <CustomerOptions> customersOpt = new List <CustomerOptions>(); customers.ForEach(customer => customersOpt.Add(new CustomerOptions { FirstName = customer.FirstName, LastName = customer.LastName, Phone = customer.Phone, Email = customer.Email, VatNumber = customer.VatNumber, Address = customer.Address, Dob = customer.Dob, Id = customer.Id + "" })); return(customersOpt); }
public bool SoftDeleteCustomer(int id) { using CrmAppDbContext db = new CrmAppDbContext(); CustomerManagement custMangr = new CustomerManagement(db); return(custMangr.SoftDeleteCustomerById(id)); }
public Customer PutCustomer(int id, CustomerOption custOpt) { using CrmAppDbContext db = new CrmAppDbContext(); CustomerManagement custMangr = new CustomerManagement(db); return(custMangr.Update(custOpt, id)); }
public Customer PostCustomer(CustomerOption custOpt) { using CrmAppDbContext db = new CrmAppDbContext(); CustomerManagement custMangr = new CustomerManagement(db); return(custMangr.CreateCustomer(custOpt)); }
public Customer GetCustomer(int id) { using CrmAppDbContext db = new CrmAppDbContext(); CustomerManagement custMangr = new CustomerManagement(db); return(custMangr.FindCustomerById(id)); }
public List <Customer> GetAllCustomers() { using CrmAppDbContext db = new CrmAppDbContext(); CustomerManagement custMangr = new CustomerManagement(db); return(custMangr.GetAllCustomers()); }
public Customer CreateCustomer(CustomerOptions customerOptions) { Customer customer = new Customer { FirstName = customerOptions.FirstName, LastName = customerOptions.LastName, Phone = customerOptions.Phone, Email = customerOptions.Email, VatNumber = customerOptions.VatNumber, Address = customerOptions.Address, Dob = customerOptions.Dob, CreatedDate = DateTime.Now, IsActive = true, TotalGross = 0m }; using CrmAppDbContext dbContext = new CrmAppDbContext(); dbContext.Customers.Add(customer); dbContext.SaveChanges(); return(customer); }
public ProductService(CrmAppDbContext dbContext) { this.dbContext = dbContext; }
public OrderService(CrmAppDbContext dbContext) { this.dbContext = dbContext; }
public CustomerManagement(CrmAppDbContext _db) { db = _db; }
public BasketManagement(CrmAppDbContext _db) { db = _db; }
public ProductManagement(CrmAppDbContext _db) { db = _db; }
public CustomerService(CrmAppDbContext dbContext) { this.dbContext = dbContext; }