Пример #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());
        }