public void addCustomer(string fname, string lname, string address, string country, string phone, string email, string password, string payStatus, DiscountGroup discountGroup) { CustomerCtr custCtr = new CustomerCtr(); int newCust = custCtr.add(fname, lname, address, country, phone, email, discountGroup.ID, payStatus); LogInfoCtr logInfoCtr = new LogInfoCtr(); // email is used as login name for everyone logInfoCtr.add(email, password, newCust); }
/* public void updateCustomer(int id, string fname, string lname, string address, string country, string phone, string email, LogInfo logInfo, string payStatus, DiscountGroup discountGroup) { throw new NotImplementedException(); } */ public void updateCustomer(Customer customer) { CustomerCtr custCtr = new CustomerCtr(); List<MLogInfo> mLogInfos = new List<MLogInfo>(); foreach (LogInfo logInfo in customer.LogInfos) { mLogInfos.Add(new MLogInfo { ID = logInfo.ID, LoginName = logInfo.LoginName, Password = logInfo.Password }); } custCtr.update(customer.ID, customer.FName, customer.LName, customer.Address, customer.Country, customer.Phone, customer.Email, mLogInfos, customer.DiscountGroup.ID, customer.PaymentStatus); }
public List<LogInfo> getPersonLogInfos(int id) { CustomerCtr custCtr = new CustomerCtr(); MCustomer mCust = custCtr.get(id, false); if (mCust != null) { List<LogInfo> logInfos = new List<LogInfo>(); foreach (MLogInfo mLogInfo in mCust.LogInfos) { logInfos.Add(new LogInfo { ID = mLogInfo.ID, LoginName = mLogInfo.LoginName, Password = mLogInfo.Password }); } return logInfos; } EmployeeCtr empCtr = new EmployeeCtr(); MEmployee mEmp = empCtr.get(id, false); if (mEmp != null) { List<LogInfo> logInfos = new List<LogInfo>(); foreach (MLogInfo mLogInfo in mEmp.LogInfos) { logInfos.Add(new LogInfo { ID = mLogInfo.ID, LoginName = mLogInfo.LoginName, Password = mLogInfo.Password }); } return logInfos; } throw new SystemException("Nor Employee or Customer was found with given ID."); }
/* public void addCustmer(Customer customer) { CustomerCtr custCtr = new CustomerCtr(); int newCust = custCtr.add(customer.FName, customer.LName, customer.Address, customer.Country, customer.Phone, customer.Email, customer.DiscountGroup.ID, customer.PaymentStatus); LogInfoCtr logInfoCtr = new LogInfoCtr(); // email is used as login name for everyone logInfoCtr.add(customer.Email, customer.LogInfo.Password, newCust); } */ public Customer getCustomer(int id) { CustomerCtr custCtr = new CustomerCtr(); MCustomer mCust = null; try { mCust = custCtr.get(id, false); } catch (NullReferenceException) { } Customer cust = new Customer(); if (mCust != null) { List<LogInfo> logInfos = new List<LogInfo>(); foreach (MLogInfo mLogInfo in mCust.LogInfos) { logInfos.Add(new LogInfo { ID = mLogInfo.ID, LoginName = mLogInfo.LoginName, Password = mLogInfo.Password }); } DiscountGroup discoGroup = new DiscountGroup { ID = mCust.DiscountGroup.ID, Name = mCust.DiscountGroup.Name, Discount = mCust.DiscountGroup.Discount }; cust.ID = mCust.ID; cust.FName = mCust.FName; cust.LName = mCust.LName; cust.Address = mCust.Address; cust.Country = mCust.Country; cust.Phone = mCust.Phone; cust.Email = mCust.Email; cust.LogInfos = logInfos; cust.PaymentStatus = mCust.PaymentStatus; cust.DiscountGroup = discoGroup; } return cust; //throw new SystemException("No Customer model was returned."); }
public List<Customer> getAllCustomers() { CustomerCtr custCtr = new CustomerCtr(); List<MCustomer> mCusts = custCtr.getAll(); List<Customer> custs = new List<Customer>(); foreach (MCustomer mCust in mCusts) { List<LogInfo> logInfos = new List<LogInfo>(); foreach (MLogInfo mLogInfo in mCust.LogInfos) { logInfos.Add(new LogInfo { ID = mLogInfo.ID, LoginName = mLogInfo.LoginName, Password = mLogInfo.Password }); } DiscountGroup discoGroup = new DiscountGroup { ID = mCust.DiscountGroup.ID, Name = mCust.DiscountGroup.Name, Discount = mCust.DiscountGroup.Discount }; Customer cust = new Customer() { ID = mCust.ID, FName = mCust.FName, LName = mCust.LName, Address = mCust.Address, Country = mCust.Country, Phone = mCust.Phone, Email = mCust.Email, LogInfos = logInfos, PaymentStatus = mCust.PaymentStatus, DiscountGroup = discoGroup }; custs.Add(cust); } return custs; }
public void deleteCustomer(int id) { CustomerCtr custCtr = new CustomerCtr(); custCtr.delete(id); }