Example #1
0
        public UpdateStatus Update(Call call)
        {
            UpdateStatus       status = UpdateStatus.Failed;
            HelpdeskRepository repo   = new HelpdeskRepository(new DbContext());

            if (!(repo.Exists <Call>(call.GetIdAsString())))
            {
                return(status);
            }
            try
            {
                var filter = Builders <Call> .Filter.Eq("Id", call.Id) & Builders <Call> .Filter.Eq("Version", call.Version);

                var update = Builders <Call> .Update
                             .Set("DateClosed", call.DateClosed)
                             .Set("DateOpened", call.DateOpened)
                             .Set("EmployeeId", call.EmployeeId)
                             .Set("TechId", call.TechId)
                             .Set("Id", call.Id)
                             .Set("ProblemId", call.ProblemId)
                             .Set("Notes", call.Notes)
                             .Set("OpenStatus", call.OpenStatus)
                             .Inc("Version", 1);

                status = repo.Update(call.GetIdAsString(), filter, update);
            }
            catch (Exception ex)
            {
                DALUtils.ErrorRoutine(ex, "CallDAO", "Update");
            }

            return(status);
        }
Example #2
0
        public UpdateStatus Update(Employee emp)
        {
            UpdateStatus       status = UpdateStatus.Failed;
            HelpdeskRepository repo   = new HelpdeskRepository(new DbContext());

            try
            {
                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)
                             .Inc("Version", 1);

                status = repo.Update(emp.GetIdAsString(), filter, update);
            }
            catch (Exception ex)
            {
                DALUtils.ErrorRoutine(ex, "EmployeeDAO", "Update");
            }

            return(status);
        }
Example #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);
        }
Example #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);
        }
Example #5
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);
        }
Example #6
0
        public int Update(Problem prob)
        {
            int status = -1;
            HelpdeskRepository repo = new HelpdeskRepository(new DbContext());

            try
            {
                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)
                             .Set("Id", prob.Id)
                             .Inc("Version", 1);

                status = Convert.ToInt16(repo.Update(prob.GetIdAsString(), filter, update));
            }
            catch (Exception ex)
            {
                DALUtils.ErrorRoutine(ex, "ProblemDAO", "Update");
            }

            return(Convert.ToInt16(status));
        }
        public UpdateStatus Update(Department dep)
        {
            UpdateStatus       status = UpdateStatus.Failed;
            HelpdeskRepository repo   = new HelpdeskRepository(new DbContext());

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

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

                status = repo.Update(dep.GetIdAsString(), filter, update);
            }
            catch (Exception ex)
            {
                DALUtils.ErrorRoutine(ex, "DepartmentDAO", "Update");
            }

            return(status);
        }