public DetailedJobModelM() { Customer = new CustomerM(); PhoneModel = new DetailedPhoneModelM(); Job = new JobM(); DeviceOrAccaccessories = new ObservableCollection<DeviceM>(); RepareDetails = new RepareM(); NewParts = new ObservableCollection<NewPartM>(); DeveloperOrMechanist = new SystemUserM(); }
public void AddNewCustomerTest() { CRUDManager crudm = new CRUDManager(); CustomerM c = new CustomerM(); c.Name = "Jayendrak"; c.NIC = "883481018v"; c.Email = "*****@*****.**"; crudm.AddNewCustomer(c); }
public void DetailedJobModelTest() { DetailedJobModelM job = new DetailedJobModelM(); CustomerM c = new CustomerM(); c.Name = "Jayendrak"; c.NIC = "883481918v"; c.Email = "*****@*****.**"; job.Customer = c; CRUDManager crudm = new CRUDManager(); bool b = crudm.AddNewJobDetailed(job); }
public void AddNewCustomer(CustomerM customer) { using (PhoneShopdbEntities e = new PhoneShopdbEntities()) { try { Customer c = new Customer(); c.Name = customer.Name; c.NIC = customer.NIC; c.Email = customer.Email; e.Customers.Add(c); e.SaveChanges(); } catch { } } }
public ObservableCollection<CustomerM> GetAllCustomers() { ObservableCollection<CustomerM> customers = new ObservableCollection<CustomerM>(); using (PhoneShopdbEntities ctx = new PhoneShopdbEntities()) { var c = ctx.Customers.ToList(); foreach (var item in c) { CustomerM customer = new CustomerM(); customer.Id = (int)item.Id; customer.Name = (string)item.Name; customer.NIC = (string)item.NIC; customer.Email = (string)item.Email; var t = ctx.TelephoneNumbers.Where(x => x.Customer_Id == item.Id).ToList(); foreach (var t1 in t) { TelephoneNumberM tel = new TelephoneNumberM(); tel.Id = t1.Id; tel.CustomerId = (int)t1.Customer_Id; tel.IsHome = (bool)t1.IsHome; tel.TelNo = t1.TelNo; customer.TelephoneNumbers.Add(tel); } customers.Add(customer); } } return customers; }