Exemple #1
0
 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);
 }
Exemple #2
0
 /*
 public void updateDiscountGroup(int id, string name, decimal discount)
 {
     throw new NotImplementedException();
 }
 */
 public void updateDiscountGroup(DiscountGroup discountGroup)
 {
     DiscountGroupCtr discoCtr = new DiscountGroupCtr();
     discoCtr.update(discountGroup.ID, discountGroup.Name, (decimal)discountGroup.Discount);
 }
Exemple #3
0
 public DiscountGroup getDiscoutGroup(int id)
 {
     DiscountGroupCtr discoCtr = new DiscountGroupCtr();
     MDiscountGroup mDiscoGrp = discoCtr.get(id, false);
     DiscountGroup discoGrp = new DiscountGroup
     {
         ID = mDiscoGrp.ID,
         Name = mDiscoGrp.Name,
         Discount = mDiscoGrp.Discount
     };
     return discoGrp;
 }
Exemple #4
0
        /*
        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.");
        }
Exemple #5
0
 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;
 }