public void CreateCustomer(CustomerModel customer)
        {
            var customerDb = _customerMapper.ToCustomer(customer);

            using (var wpfAppContext = new WpfAppContext())
            {
                wpfAppContext.Customers.Add(customerDb);
                wpfAppContext.SaveChanges();
            }
        }
        private List <InvoiceModel> GetAllInvoicesForCustomer(int customerId)
        {
            List <InvoiceModel> result;

            using (var wpfAppContext = new WpfAppContext())
            {
                var invoicesDb = wpfAppContext.Invoices.Where(i => i.CustomerId == customerId).ToList();
                result = invoicesDb.Select(invoice => _invoiceMapper.ToInvoiceModel(invoice)).ToList();
            }

            return(result);
        }
        public async Task <List <CustomerModel> > GetCustomersAsync(CustomerModel customerModel)
        {
            Thread.Sleep(5000);
            List <CustomerModel> result;

            using (var wpfAppContext = new WpfAppContext())
            {
                var customersDb = await wpfAppContext.Customers.Where(x => x.LastName == customerModel.LastName).ToListAsync().ConfigureAwait(false);

                result = customersDb.Select(customer => _customerMapper.ToCustomerModel(customer)).ToList();
            }

            Thread.Sleep(5000);

            return(result);
        }
        private void FilterOrGetCustomersByFirstName(List <Customer> customers, CustomerModel customerModel)
        {
            if (string.IsNullOrEmpty(customerModel.FirstName))
            {
                return;
            }

            if (customers.Count > 0)
            {
                customers.RemoveAll(x => x.FirstName != customerModel.FirstName);
                return;
            }

            using (var wpfAppContext = new WpfAppContext())
            {
                var customersDb = wpfAppContext.Customers.Where(x => x.FirstName == customerModel.FirstName).ToList();
                customers.AddRange(customersDb);
            }
        }
        private void FilterOrGetCustomersByAddress(List <Customer> customers, CustomerModel customerModel)
        {
            if (string.IsNullOrEmpty(customerModel.Address))
            {
                return;
            }

            if (customers.Count > 0)
            {
                customers.RemoveAll(x => !x.Address.Contains(customerModel.Address));
                return;
            }

            using (var wpfAppContext = new WpfAppContext())
            {
                var customersDb = wpfAppContext.Customers.Where(x => x.Address.Contains(customerModel.Address)).ToList();
                customers.AddRange(customersDb);
            }
        }
        private void GetCustomerById(List <Customer> customers, CustomerModel customerModel)
        {
            if (customerModel.CustomerId == 0)
            {
                return;
            }

            if (customers.Count > 0)
            {
                customers.RemoveAll(x => x.CustomerId != customerModel.CustomerId);
                return;
            }

            using (var wpfAppContext = new WpfAppContext())
            {
                var customerDb = wpfAppContext.Customers.SingleOrDefault(x => x.CustomerId == customerModel.CustomerId);
                if (customerDb == null)
                {
                    return;
                }

                customers.Add(customerDb);
            }
        }
Example #7
0
        public RoomService()
        {
            var context = new WpfAppContext();

            roomRepository = new RoomRepository(context);
        }
Example #8
0
 public ReportService(WpfAppContext wpfAppContext, IReportMapper reportMapper)
 {
     _wpfAppContext = wpfAppContext;
     _reportMapper  = reportMapper;
 }
 public CharacterRepository(WpfAppContext context)
 {
     _context = context;
 }
Example #10
0
        public CharacterService()
        {
            var context = new WpfAppContext();

            characterRepository = new CharacterRepository(context);
        }
Example #11
0
 public ItemRepository(WpfAppContext context)
 {
     _context = context;
 }
Example #12
0
        public ItemService()
        {
            var context = new WpfAppContext();

            itemRepository = new ItemRepository(context);
        }