예제 #1
0
        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.");
        }
예제 #2
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.");
        }