/* * GetAll() * ViewModel Layer of GetAll, calls the ProblemDAO's GetAll method * Creates a list of ProblemViewModels for the web layer to access through jQuery */ public List <ProblemViewModel> GetAll() { List <ProblemViewModel> problemsViewModelList = new List <ProblemViewModel>(); try { List <Problem> problems = _dao.GetAll(); foreach (var problem in problems) { ProblemViewModel pVM = new ProblemViewModel(); pVM.Id = problem.GetIdAsString(); pVM.Description = problem.Description; pVM.Version = problem.Version; problemsViewModelList.Add(pVM); } } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "ProblemViewModel", "GetAll"); } return(problemsViewModelList); }
public int Update() { UpdateStatus opStatus = UpdateStatus.Failed; try { Employee emp = new Employee(); emp.SetIdFromString(Id); emp.SetDepartmentIdFromString(DepartmentId); emp.Title = Title; emp.Firstname = Firstname; emp.Lastname = Lastname; emp.Phoneno = Phoneno; emp.Email = Email; emp.IsTech = IsTech; emp.StaffPicture64 = StaffPicture64; emp.Version = Version; opStatus = _dao.Update(emp); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "EmployeeViewModel", "Update"); } return(Convert.ToInt16(opStatus)); }
public List <EmployeeViewModel> GetAll() { List <EmployeeViewModel> vmList = new List <EmployeeViewModel>(); try { List <Employee> empList = _dao.GetAll(); foreach (Employee e in empList) { //return only fields for display, subsequent get will fill other fields EmployeeViewModel viewModel = new EmployeeViewModel(); viewModel.Id = e.GetIdAsString(); viewModel.Title = e.Title; viewModel.Firstname = e.Firstname; viewModel.Lastname = e.Lastname; viewModel.Email = e.Email; viewModel.Version = e.Version; viewModel.DepartmentId = e.GetDepartmentIdAsString(); vmList.Add(viewModel);//add to list } } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "EmployeeViewModel", "GetAll"); } return(vmList); }
public List <DepartmentViewModel> GetAll() { List <DepartmentViewModel> depsViewModelList = new List <DepartmentViewModel>(); try { List <Department> departments = _dao.GetAll(); foreach (var department in departments) { DepartmentViewModel dVM = new DepartmentViewModel(); dVM.Id = department.GetIdAsString(); dVM.Name = department.DepartmentName; dVM.Version = department.Version; depsViewModelList.Add(dVM); } } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "GetAll"); } return(depsViewModelList); }
/* * GetAll() * ViewModel Layer of GetAll, calls the EmployeeDAO's GetAll method * Creates a list of EmployeeViewModels for the web layer to access through jQuery */ public List <EmployeeViewModel> GetAll() { List <EmployeeViewModel> empsViewModelList = new List <EmployeeViewModel>(); try { List <Employee> emps = _dao.GetAll(); foreach (var employee in emps) { EmployeeViewModel eVM = new EmployeeViewModel(); eVM.Title = employee.Title; eVM.Firstname = employee.Firstname; eVM.Lastname = employee.Lastname; eVM.Phoneno = employee.Phoneno; eVM.Email = employee.Email; eVM.StaffPicture64 = employee.StaffPicture64; eVM.IsTech = employee.IsTech; eVM.Version = employee.Version; eVM.Id = employee.GetIdAsString(); eVM.DepartmentId = employee.GetDepartmentIdAsString(); empsViewModelList.Add(eVM); } } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "EmployeeViewModel", "GetAll"); } return(empsViewModelList); }
public int Update() { UpdateStatus opStatus = UpdateStatus.Failed; try { Call call = new Call(); call.SetEmployeeIdFromString(EmployeeId); call.SetIdFromString(Id); call.SetProblemIdFromString(ProblemId); call.SetTechIdFromString(TechId); call.Notes = Notes; call.OpenStatus = OpenStatus; call.DateClosed = DateClosed; call.DateOpened = DateOpened; call.Version = Version; opStatus = _dao.Update(call); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "ViewModel", "Update"); } return(Convert.ToInt16(opStatus)); }
public void Create() { try { Department dept = new Department(); dept.DepartmentName = DepartmentName; dept.Version = 1; Id = _dao.Create(dept).GetIdAsString(); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "GetById"); } }
public long Delete() { long deleted = 0; try { deleted = _dao.Delete(Id); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "EmployeeViewModel", "Delete"); } return(deleted); }
public bool Delete() { bool deleteOk = false; try { deleteOk = _dao.Delete(EmployeeId); } catch (Exception e) { ViewModelUtils.ErrorRoutine(e, "EmployeeViewModel", "Delete"); } return(deleteOk); }
public void GetById() { try { Department dep = _dao.GetByDepartmentId(Id); Id = dep.GetIdAsString(); Name = dep.DepartmentName; Version = dep.Version; } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "GetById"); } }
public void Create() { try { Problem prob = new Problem(); prob.Description = Description; prob.Version = Version; ProblemId = _dao.Create(prob).GetIdAsString(); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "ProblemViewModel", "Create"); } }
public void GetById() { try { Problem prob = _dao.GetById(ProblemId); Description = prob.Description; Version = prob.Version; ProblemId = prob.GetIdAsString(); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "ProblemViewModel", "GetById"); } }
public long Delete() { long delStatus = 0; try { delStatus = _dao.Delete(Id); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "CallViewModel", "Delete"); } return(delStatus); }
public void GetByDescription() { try { Problem prob = _dao.GetByDescription(Description); Description = prob.Description; Id = prob.GetIdAsString(); Version = prob.Version; } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "ProblemViewModels", "GetByDescription"); } }
public void GetByDepartmentName() { try { Department dept = _dao.GetByDepartmentName(DepartmentName); DepartmentName = dept.DepartmentName; Id = dept.GetIdAsString(); } catch (Exception ex) { DepartmentName = "not found"; ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "GetByDepartmentName"); } }
public void GetById() { try { Department dept = _dao.GetById(Id); DepartmentName = dept.DepartmentName; Version = dept.Version; Id = dept.GetIdAsString(); } catch (Exception ex) { Id = "not found"; ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "GetById"); } }
public long Delete() { long deleted = 0; try { deleted = _dao.Delete(ProblemId); return(deleted); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "ProblemViewModel", "Delete()"); return(deleted); } }
public void Create() { try { Department dep = new Department(); dep.DepartmentName = Name; dep.Version = Version; dep = _dao.Create(dep); Id = dep.GetIdAsString(); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "Create"); } }
public long Delete() { long deleteFlag = 0; try { deleteFlag = _dao.Delete(Id); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "Delete"); } return(deleteFlag); }
public void Create() { try { Employee emp = new Employee(); emp.DepartmentId = new ObjectId(DepartmentId); emp.Title = Title; emp.Firstname = Firstname; emp.Lastname = Lastname; emp.Phoneno = Phoneno; emp.Email = Email; EmployeeId = _dao.Create(emp); } catch (Exception e) { ViewModelUtils.ErrorRoutine(e, "EmployeeViewModel", "Create"); } }
public int Update() { UpdateStatus opStatus; try { Problem prob = new Problem(); prob.SetIdFromString(ProblemId); prob.Description = Description; prob.Version = Version; opStatus = _dao.Update(prob); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "ProblemViewModel", "Update"); opStatus = UpdateStatus.Failed; } return(Convert.ToInt16(opStatus)); }
public void GetById() { try { Call call = _dao.GetById(Id); TechId = call.GetTechIdAsString(); EmployeeId = call.GetEmployeeIdAsString(); ProblemId = call.GetProblemIdAsString(); OpenStatus = call.OpenStatus; DateClosed = call.DateClosed; DateOpened = call.DateOpened; Notes = call.Notes; Version = call.Version; } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "CallViewModel", "GetById"); } }
public void Create() { try { Employee emp = new Employee(); emp.Title = Title; emp.Firstname = Firstname; emp.Lastname = Lastname; emp.Email = Email; emp.Phoneno = Phoneno; emp.Version = Version; emp.SetDepartmentIdFromString(DepartmentId); Id = _dao.Create(emp).GetIdAsString(); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "EmployeeViewModel", "Create"); } }
public void GetByLastname() { try { Employee emp = _dao.GetByLastname(Lastname); Title = emp.Title; Firstname = emp.Firstname; Lastname = emp.Lastname; Phoneno = emp.Phoneno; Email = emp.Email; Id = emp.GetIdAsString(); DepartmentId = emp.GetDepartmentIdAsString(); Version = emp.Version; } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "EmployeeViewModel", "GetByLastname"); } }
public void GetById(string id) { try { Employee emp = _dao.GetById(id); id = emp._id.ToString(); Title = emp.Title; Firstname = emp.Firstname; Lastname = emp.Lastname; Phoneno = emp.Phoneno; Email = emp.Email; DepartmentId = emp.DepartmentId.ToString(); Entity64 = Convert.ToBase64String(ViewModelUtils.Serializer(emp)); } catch (Exception e) { ViewModelUtils.ErrorRoutine(e, "EmployeeViewModel", "GetById"); } }
public void Create() { try { Call call = new Call(); call.SetTechIdFromString(TechId); call.SetEmployeeIdFromString(EmployeeId); call.SetProblemIdFromString(ProblemId); call.DateClosed = DateClosed; call.DateOpened = DateOpened; call.OpenStatus = OpenStatus; call.Notes = Notes; call.Version = Version; Id = (_dao.Create(call)).GetIdAsString(); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "CallViewModel", "Create"); } }
public int Update() { UpdateStatus opStatus = UpdateStatus.Failed; try { Department dept = new Department(); dept.SetIdFromString(Id); dept.Version = Version; dept.DepartmentName = DepartmentName; opStatus = _dao.Update(dept); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "Update"); } return(Convert.ToInt16(opStatus));//Web layer won't know about enum }
public int Update() { UpdateStatus opStatus; try { Department dep = new Department(); dep.SetIdFromString(Id); dep.DepartmentName = Name; dep.Version = Version; opStatus = _dao.Update(dep); } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "DepartmentViewModel", "Update"); opStatus = UpdateStatus.Failed; } return(Convert.ToInt16(opStatus)); }
public void GetById() { try { Employee emp = _dao.GetById(Id); Title = emp.Title; Firstname = emp.Firstname; Lastname = emp.Lastname; Phoneno = emp.Phoneno; Email = emp.Email; Id = emp.GetIdAsString(); IsTech = emp.IsTech; StaffPicture64 = emp.StaffPicture64; DepartmentId = emp.GetDepartmentIdAsString(); Version = emp.Version; } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "EmployeeViewModel", "GetByID"); } }
public int Update() { int rowsUpdated = -1; try { byte[] BytEmp = Convert.FromBase64String(Entity64); Employee emp = (Employee)ViewModelUtils.Deserializer(BytEmp); emp.Title = Title; emp.Firstname = Firstname; emp.Lastname = Lastname; emp.Phoneno = Phoneno; emp.Email = Email; emp.DepartmentId = new ObjectId(DepartmentId); rowsUpdated = _dao.Update(emp); } catch (Exception e) { ViewModelUtils.ErrorRoutine(e, "EmployeeViewModel", "Update"); } return(rowsUpdated); }