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);
        }
Exemple #2
0
        public bool SoftDeleteCustomer(int id)
        {
            using CrmAppDbContext db = new CrmAppDbContext();
            CustomerManagement custMangr = new CustomerManagement(db);

            return(custMangr.SoftDeleteCustomerById(id));
        }
Exemple #3
0
        public Customer PutCustomer(int id, CustomerOption custOpt)
        {
            using CrmAppDbContext db = new CrmAppDbContext();
            CustomerManagement custMangr = new CustomerManagement(db);

            return(custMangr.Update(custOpt, id));
        }
Exemple #4
0
        public Customer PostCustomer(CustomerOption custOpt)
        {
            using CrmAppDbContext db = new CrmAppDbContext();
            CustomerManagement custMangr = new CustomerManagement(db);

            return(custMangr.CreateCustomer(custOpt));
        }
Exemple #5
0
        public Customer GetCustomer(int id)
        {
            using CrmAppDbContext db = new CrmAppDbContext();
            CustomerManagement custMangr = new CustomerManagement(db);

            return(custMangr.FindCustomerById(id));
        }
Exemple #6
0
        public List <Customer> GetAllCustomers()
        {
            using CrmAppDbContext db = new CrmAppDbContext();
            CustomerManagement custMangr = new CustomerManagement(db);

            return(custMangr.GetAllCustomers());
        }
Exemple #7
0
        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);
        }
Exemple #8
0
 public ProductService(CrmAppDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
Exemple #9
0
 public OrderService(CrmAppDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
 public CustomerManagement(CrmAppDbContext _db)
 {
     db = _db;
 }
 public BasketManagement(CrmAppDbContext _db)
 {
     db = _db;
 }
Exemple #12
0
 public ProductManagement(CrmAppDbContext _db)
 {
     db = _db;
 }
 public CustomerService(CrmAppDbContext dbContext)
 {
     this.dbContext = dbContext;
 }