コード例 #1
0
        // End GetByLastname


        //Update with Repo
        public UpdateStatus Update(Employee emp)
        {
            UpdateStatus       status = UpdateStatus.Failed;
            HelpdeskRepository repo   = new HelpdeskRepository(new DbContext());

            try
            {
                var builder = Builders <Employee> .Filter;
                var filter  = Builders <Employee> .Filter.Eq("Id", emp.Id) & Builders <Employee> .Filter.Eq("Version", emp.Version);

                var update = Builders <Employee> .Update
                             .Set("DepartmentId", emp.DepartmentId)
                             .Set("Email", emp.Email)
                             .Set("Firstname", emp.Firstname)
                             .Set("Lastname", emp.Lastname)
                             .Set("Phoneno", emp.Phoneno)
                             .Set("Title", emp.Title)
                             .Set("StaffPicture64", emp.StaffPicture64)
                             .Inc("Version", 1);

                status = repo.Update(emp.Id.ToString(), filter, update);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "UpdateWithRepo");
            }
            return(status);
        }
コード例 #2
0
        //End UpdateWithRepo



        //Create - add an Employee document to the employees collection

        public Employee Create(Employee emp)
        {
            HelpdeskRepository repo = new HelpdeskRepository(new DbContext());

            try
            {
                emp = repo.Create(emp);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "Create");
            }
            return(emp);
        }
コード例 #3
0
        //End UpdateWithRepo



        //Create - add an Department document to the Departments collection

        public Department Create(Department dept)
        {
            HelpdeskRepository repo = new HelpdeskRepository(new DbContext());

            try
            {
                dept = repo.Create(dept);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "DepartmentDAO", "Create");
            }
            return(dept);
        }
コード例 #4
0
        //End UpdateWithRepo



        //Create - add an Problem document to the Problems collection

        public Problem Create(Problem prob)
        {
            HelpdeskRepository repo = new HelpdeskRepository(new DbContext());

            try
            {
                prob = repo.Create(prob);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "ProblemDAO", "Create");
            }
            return(prob);
        }
コード例 #5
0
        //GetAll - This one is just going to return a straight List of Problem instances

        public List <Problem> GetAll()
        {
            List <Problem> probList = new List <Problem>();


            try
            {
                probList.AddRange(repo.GetAll <Problem>().ToList());
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "ProblemDAO", "GetAll");
            }
            return(probList);
        }
コード例 #6
0
        //GetByID - Similar to GetByLastname, see above.
        public Problem GetById(string Id)
        {
            Problem prob    = null;
            var     builder = Builders <Problem> .Filter;

            try
            {
                prob = repo.GetById <Problem>(Id);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "ProblemDAO", "GetById");
            }
            return(prob);
        }
コード例 #7
0
        //GetAll - This one is just going to return a straight List of Employee instances

        public List <Employee> GetAll()
        {
            List <Employee> empList = new List <Employee>();


            try
            {
                empList.AddRange(repo.GetAll <Employee>().ToList());
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "GetAll");
            }
            return(empList);
        }
コード例 #8
0
        //Delete - returns a long (1 or 0) depending on if the delete was successful
        public long Delete(string Id)
        {
            long deleteFlag = 0;

            try
            {
                deleteFlag = repo.Delete <Department>(Id);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "DepartmentDAO", "Delete");
            }

            return(deleteFlag);
        }
コード例 #9
0
        //GetByID - Similar to GetByLastname, see above.
        public Department GetById(string Id)
        {
            Department dept    = null;
            var        builder = Builders <Department> .Filter;

            try
            {
                dept = repo.GetById <Department>(Id);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "DepartmentDAO", "GetById");
            }
            return(dept);
        }
コード例 #10
0
        //GetAll - This one is just going to return a straight List of Department instances

        public List <Department> GetAll()
        {
            List <Department> deptList = new List <Department>();


            try
            {
                deptList.AddRange(repo.GetAll <Department>().ToList());
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "DepartmentDAO", "GetAll");
            }
            return(deptList);
        }
コード例 #11
0
        public bool LoadCollections()
        {
            bool createOk = false;

            try
            {
                DALUtilsV2 dalUtil = new DALUtilsV2();
                createOk = dalUtil.LoadCollections();
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "ViewModelUtils", "LoadCollections");
            }
            return(createOk);
        }
コード例 #12
0
        //GetByID - Similar to GetByLastname, see above.
        public Employee GetById(string Id)
        {
            Employee emp     = null;
            var      builder = Builders <Employee> .Filter;

            try
            {
                emp = repo.GetById <Employee>(Id);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "GetById");
            }
            return(emp);
        }
コード例 #13
0
        //GetByLastname
        public Employee GetByLastname(string name)
        {
            Employee emp     = null;
            var      builder = Builders <Employee> .Filter;
            var      filter  = builder.Eq("Lastname", name);

            try
            {
                emp = repo.GetOne <Employee>(filter);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "EmployeeDAO", "GetByLastname");
            }
            return(emp);
        }
コード例 #14
0
        //GetByLastname
        public Department GetByDepartmentName(string deptName)
        {
            Department dept    = null;
            var        builder = Builders <Department> .Filter;
            var        filter  = builder.Eq("DepartmentName", deptName);

            try
            {
                dept = repo.GetOne <Department>(filter);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "DepartmentDAO", "GetByLastname");
            }
            return(dept);
        }
コード例 #15
0
        //GetByLastname
        public Problem GetByProblemName(string probName)
        {
            Problem prob    = null;
            var     builder = Builders <Problem> .Filter;
            var     filter  = builder.Eq("Description", probName);

            try
            {
                prob = repo.GetOne <Problem>(filter);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "ProblemDAO", "GetByDescription");
            }
            return(prob);
        }
コード例 #16
0
        // End GetByLastname


        //Update with Repo
        public UpdateStatus Update(Department dept)
        {
            UpdateStatus status = UpdateStatus.Failed;

            try
            {
                var builder = Builders <Department> .Filter;
                var filter  = Builders <Department> .Filter.Eq("Id", dept.Id) & Builders <Department> .Filter.Eq("Version", dept.Version);

                var update = Builders <Department> .Update
                             .Set("DepartmentName", dept.DepartmentName)
                             .Inc("Version", 1);


                status = repo.Update(dept.Id.ToString(), filter, update);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "DepartmentDAO", "Update");
            }
            return(status);
        }
コード例 #17
0
        // End GetByLastname


        //Update with Repo
        public UpdateStatus Update(Problem prob)
        {
            UpdateStatus status = UpdateStatus.Failed;

            try
            {
                var builder = Builders <Problem> .Filter;
                var filter  = Builders <Problem> .Filter.Eq("Id", prob.Id) & Builders <Problem> .Filter.Eq("Version", prob.Version);

                var update = Builders <Problem> .Update
                             .Set("Description", prob.Description)
                             .Inc("Version", 1);


                status = repo.Update(prob.Id.ToString(), filter, update);
            }
            catch (Exception ex)
            {
                DALUtilsV2.ErrorRoutine(ex, "ProblemDAO", "Update");
            }
            return(status);
        }
コード例 #18
0
        public void TestLoadCollectionsShouldReturnTrue()
        {
            DALUtilsV2 util = new DALUtilsV2();

            Assert.IsTrue(util.LoadCollections());
        }