コード例 #1
0
ファイル: EmployeeDAO.cs プロジェクト: danruff5/INFO-3070
        public List<Employee> GetAll()
        {
            List<Employee> allEmps = new List<Employee>();

            try
            {
                DbContext ctx = new DbContext();
                allEmps = ctx.Employees.AsQueryable().ToList();
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "GetAll");
            }

            return allEmps;
        }
コード例 #2
0
ファイル: EmployeeDAO.cs プロジェクト: danruff5/INFO-3070
        public Employee GetEmployeeBySurname(string name)
        {
            Employee retEmp = null;
            DbContext _ctx;

            try
            {
                _ctx = new DbContext();
                var employees = _ctx.Employees;
                var employee = employees.AsQueryable<Employee>().Where(emp => emp.Lastname == name).FirstOrDefault();
                retEmp = (Employee)employee;
            }catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "GetEmployeeBySurname");
            }

            return retEmp;
        }
コード例 #3
0
ファイル: EmployeeDAO.cs プロジェクト: danruff5/INFO-3070
        public Employee GetByID(string id)
        {
            Employee retEmp = null;
            ObjectId ID = new ObjectId(id);
            DbContext _ctx;

            try
            {
                _ctx = new DbContext();
                retEmp = _ctx.Employees.AsQueryable().FirstOrDefault(e => e._id == ID);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "GetById");
            }

            return retEmp;
        }
コード例 #4
0
ファイル: DepartmentDAO.cs プロジェクト: danruff5/INFO-3070
        public Department GetDepartment(string idS)
        {
            ObjectId id = new ObjectId(idS);
            Department retDep = null;
            DbContext _ctx;

            try
            {
                _ctx = new DbContext();
                var departments = _ctx.Departments;
                var department = departments.AsQueryable<Department>().Where(dep => dep._id == id).FirstOrDefault();
                retDep = (Department)department;
            } catch (Exception ex)
            {
                Console.WriteLine("Problem " + ex.Message);
            }
            return retDep;
        }
コード例 #5
0
ファイル: DAUtils.cs プロジェクト: danruff5/INFO-3070
        /// <summary>
        /// Main Loading Method
        /// Revisions: Added Problem methods
        /// </summary>
        public bool LoadCollections()
        {
            bool createOk = false;

            try
            {
                DropAndCreateCollections();
                ctx = new DbContext();
                LoadDepartments();
                LoadEmployees();
                createOk = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return createOk;
        }
コード例 #6
0
ファイル: EmployeeDAO.cs プロジェクト: danruff5/INFO-3070
        public int Update(Employee emp)
        {
            int updateOK = -1;
            try
            {
                DbContext ctx = new DbContext();
                ctx.Save<Employee>(emp, "employees");
                updateOK = 1;
            } catch (MongoConcurrencyException ex)
            {
                updateOK = -2;
                Console.WriteLine(ex.Message);
            } catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "Update");
            }

            return updateOK;
        }
コード例 #7
0
        public Employee GetEmployeeBySurname(string name)
        {
            Employee retEmp = null;
            DbContext _ctx;
            try
            {
                _ctx = new DbContext();
                var employees = _ctx.Employees;
                var employee = employees.AsQueryable<Employee>().FirstOrDefault(emp => emp.Lastname == name);
                retEmp = (Employee)employee;
            }
            catch(Exception ex)
            {
                Console.WriteLine("Problem " + ex.Message);

            }

            return retEmp;
        }
コード例 #8
0
ファイル: DAUtilsV2.cs プロジェクト: danruff5/INFO-3070
        /// <summary>
        /// Main Loading Method
        /// Revisions: Added Problem methods
        /// </summary>
        public bool LoadCollections()
        {
            bool createOk = false;

            try
            {
                DropAndCreateCollections();
                ctx = new DbContext();
                LoadPics();
                LoadDepartments();
                LoadEmployees();
                createOk = true;
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "DALUtils", "LoadCollections");
            }
            return createOk;
        }