コード例 #1
0
ファイル: ElectricCar.cs プロジェクト: Dadov/3rdsemproject
        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
ファイル: ElectricCar.cs プロジェクト: Dadov/3rdsemproject
 // TODO: change to accept one Employee employee argument
 // public void addEmployee(Employee employee)
 public Employee getEmployee(int id)
 {
     EmployeeCtr empCtr = new EmployeeCtr();
     MEmployee mEmp = empCtr.get(id, false);
     List<LogInfo> logInfos = new List<LogInfo>();
     foreach (MLogInfo logInfo in mEmp.LogInfos)
     {
         logInfos.Add(new LogInfo
         {
             ID = logInfo.ID,
             LoginName = logInfo.LoginName,
             Password = logInfo.Password
         });
     }
     if (mEmp != null)
     {
         Employee emp = new Employee()
         {
             ID = mEmp.ID,
             FName = mEmp.FName,
             LName = mEmp.LName,
             Address = mEmp.Address,
             Country = mEmp.Country,
             Phone = mEmp.Phone,
             Email = mEmp.Email,
             LogInfos = logInfos,
             Position = mEmp.Position.ToString(),
             StationID = mEmp.StationId
         };
         return emp;
     }
     throw new SystemException("No Employee model was returned.");
 }