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); }
public List <EmployeeViewModel> GetTechs() { List <EmployeeViewModel> viewModels = new List <EmployeeViewModel>(); try { List <Employee> techs = _dao.GetAll(); foreach (Employee e in techs) { if (e.IsTech) { EmployeeViewModel viewModel = new EmployeeViewModel(); viewModel.Id = e.GetIdAsString(); viewModel.Title = e.Title; viewModel.Firstname = e.Firstname; viewModel.Lastname = e.Lastname; viewModel.Phoneno = e.Phoneno; viewModel.Email = e.Email; viewModel.IsTech = e.IsTech; viewModel.StaffPicture64 = e.StaffPicture64; viewModel.Version = e.Version; viewModel.DepartmentId = e.GetDepartmentIdAsString(); viewModels.Add(viewModel); } } } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "EmployeeViewModel", "GetAll"); } return(viewModels); }
public List <CallViewModel> GetAll() { List <CallViewModel> viewModels = new List <CallViewModel>(); try { List <Call> Calls = _dao.GetAll(); foreach (Call c in Calls) { CallViewModel viewModel = new CallViewModel(); viewModel.DateClosed = c.DateClosed; viewModel.DateOpened = c.DateOpened; viewModel.TechId = c.GetTechIdAsString(); viewModel.ProblemId = c.GetProblemIdAsString(); viewModel.EmployeeId = c.GetEmployeeIdAsString(); viewModel.Id = c.GetIdAsString(); viewModel.OpenStatus = c.OpenStatus; viewModel.Notes = c.Notes; viewModel.Version = c.Version; viewModel.GetEmpInfo(); viewModels.Add(viewModel); } } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "CallViewModel", "GetAll"); } return(viewModels); }
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); }
public long Delete(string id) { try { return(repo.Delete <Problem>(id)); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "ProblemDAO", "Update"); return(0); } }
public Department Create(Department createdept) { try { createdept = repo.Create <Department>(createdept); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "DepartmentDAO", "Create"); } return(createdept); }
public Problem Create(Problem createprob) { try { createprob = repo.Create <Problem>(createprob); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "ProblemDAO", "Create"); } return(createprob); }
public Employee Create(Employee createEmp) { try { createEmp = repo.Create <Employee>(createEmp); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "EmployeeDAO", "Create"); } return(createEmp); }
public Call Create(Call createCall) { try { createCall = repo.Create <Call>(createCall); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "CallDAO", "Create"); } return(createCall); }
public long Delete(string id) { try { repo.Delete <Employee>(id); return(1); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "EmployeeDAO", "Update"); return(0); } }
public long Delete(string id) { try { repo.Delete <Department>(id); return(1); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "DepartmentDAO", "Update"); return(0); } }
// Method Name: GetAll // Purpose: Retrieves a straight list of Employee Objects // Accepts: Nothing // Returns: List of Employees public List <Employee> GetAll() { List <Employee> allEmps = new List <Employee>(); try { DbContext ctx = new DbContext(); allEmps = ctx.Employees.ToList(); } catch (Exception e) { DALUtils.ErrorRoutine(e, "EmployeDAO", "GetAll"); } return(allEmps); }
public long Delete(string id) { long deleted = 0; try { deleted = repo.Delete <Call>(id); return(deleted); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "CallDAO", "Update"); return(deleted); } }
public List <Call> GetAll() { List <Call> call = new List <Call>(); try { call = repo.GetAll <Call>(); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "CallDAO", "GetAll"); } return(call); }
public List <Department> GetAll() { List <Department> deps = null; try { deps = repo.GetAll <Department>(); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "DepartmentDAO", "GetAll"); } return(deps); }
/* * GetAll() * Uses the Repository and Returns a List of all Problems */ public List <Problem> GetAll() { List <Problem> probs = null; try { probs = repo.GetAll <Problem>(); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "ProblemDAO", "GetAll"); } return(probs); }
public Department GetById(string deptId) { Department dept = new Department(); try { dept = repo.GetById <Department>(deptId); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "DepartmentDAO", "GetById"); } return(dept); }
public List <Employee> GetAll() { List <Employee> emp = new List <Employee>(); try { emp = repo.GetAll <Employee>(); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "EmployeeDAO", "GetAll"); } return(emp); }
public Employee GetById(string employId) { Employee emp = new Employee(); try { emp = repo.GetById <Employee>(employId); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "EmployeeDAO", "GetById"); } return(emp); }
public Problem GetById(string probId) { Problem prob = new Problem(); try { prob = repo.GetById <Problem>(probId); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "ProblemDAO", "GetById"); } return(prob); }
public Department Create(Department dep) { repo = new HelpdeskRepository(new DbContext()); Department depRet = null; try { depRet = repo.Create <Department>(dep); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "DepartmentDAO", "Create"); } return(depRet); }
/* * Delete() * Uses the Repository and deletes the Problem id that is passed to this function * Returns a delete status number based on if the delete was successful or not */ public long Delete(string id) { repo = new HelpdeskRepository(new DbContext()); long delete_status = 0; try { delete_status = repo.Delete <Problem>(id); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "ProblemDAO", "Delete"); } return(delete_status); }
/* * Create() * Uses the Repository and creates the problem based on the object that was passed in as an argument * Returns the created Problem in a problem Object */ public Problem Create(Problem prob) { repo = new HelpdeskRepository(new DbContext()); Problem probRet = null; try { probRet = repo.Create <Problem>(prob); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "ProblemDAO", "Create"); } return(probRet); }
public Call Create(Call call) { repo = new HelpdeskRepository(new DbContext()); Call callRet = null; try { callRet = repo.Create <Call>(call); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "EmployeeDAO", "Create"); } return(callRet); }
public List <Department> GetAll() { List <Department> allDeps = new List <Department>(); try { DbContext ctx = new DbContext(); allDeps = ctx.Departments.ToList(); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "DepartmentDAO", "GetAll"); } return(allDeps); }
/* * Create() * Uses the Repository and creates the Employee based on the object that was passed in as an argument * Returns the created Employee that was created */ public Employee Create(Employee emp) { repo = new HelpdeskRepository(new DbContext()); Employee empRet = null; try { empRet = repo.Create <Employee>(emp); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "EmployeeDAO", "Create"); } return(empRet); }
public List <Call> GetAll() { List <Call> allCalls = new List <Call>(); try { DbContext ctx = new DbContext(); allCalls = ctx.Calls.ToList(); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "CallDAO", "GetAll"); } return(allCalls); }
/* * GetById() * Uses the Repository and Gets the specific employee based on the "id" of the Employee * Returns an Employee Object */ public Employee GetById(string id) { Employee emp = null; var builder = Builders <Employee> .Filter; var filter = builder.Eq("Id", new ObjectId(id)); try { emp = repo.GetOne <Employee>(filter); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "EmployeeDAO", "GetById"); } return(emp); }
// Method Name: Create // Purpose: Add an Employee document to the employees collection // Accepts: An employee object // Returns: A string public string Create(Employee emp) { string newid = ""; try { DbContext ctx = new DbContext(); ctx.Save(emp, "employees"); newid = emp._id.ToString(); } catch (Exception e) { DALUtils.ErrorRoutine(e, "EmployeeDAO", "Create"); } return(newid); }
public Problem GetByDescription(string desc) { Problem prob = null; var builder = Builders <Problem> .Filter; var filter = builder.Eq("Description", desc); try { prob = repo.GetOne <Problem>(filter); } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "ProblemViewModel", "GetByDescription"); } return(prob); }