/* * 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 List <ProblemViewModel> GetAll() { List <ProblemViewModel> allVms = new List <ProblemViewModel>(); try { List <Problem> allProblems = _model.GetAll(); foreach (Problem prob in allProblems) { ProblemViewModel probVm = new ProblemViewModel(); probVm.Id = prob.Id; probVm.Timer = Convert.ToBase64String(prob.Timer); probVm.Description = prob.Description; allVms.Add(probVm); } } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } return(allVms); }
public IHttpActionResult Put(ProblemViewModel prb) { try { int errorNumber = prb.Update(); switch (errorNumber) { case 1: return Ok("Problem " + prb.Description + " updated!"); break; case -1: return Ok("Problem" + prb.Description + " not updated!"); break; case -2: return Ok("Data is stale for " + prb.Description + ". Problem not updated!"); break; default: return Ok("Problem" + prb.Description + " not updated!"); break; } } catch (Exception ex) { return BadRequest("Update failed - " + ex.Message); } }
public List <ProblemViewModel> GetAll() { // Create a list to hold the ProblemViewModell objects List <ProblemViewModel> allVms = new List <ProblemViewModel>(); try { // Create the List to hold the Employee objects. Uses the GetAll() // from the EmployeeModel class to populate this List List <Problem> allProblems = _model.GetAll(); // For each Employee in the allEmployees List create a view model for them and // then add them to the List of Employee objects foreach (Problem problem in allProblems) { ProblemViewModel probVm = new ProblemViewModel(); probVm.Id = problem.Id; probVm.Description = problem.Description; //probVm.Timer = Convert.ToBase64String(problem.Timer); allVms.Add(probVm); } } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } // Return the List of EmployeeViewModel objects return(allVms); }
public void ProblemVMUpdateShouldReturnTrue() { ProblemViewModel vm = new ProblemViewModel(); vm.GetById("56201963f748f2338c59a8d1"); // Device not plugged in id vm.Description = "DEVICE NOT PLUGGED IN"; int rowsUpdated = vm.Update(); Assert.IsTrue(rowsUpdated == 1); }
public IHttpActionResult Post(ProblemViewModel prb) { try { prb.Create(); return Ok("Problem " + prb.Description + " Created"); } catch (Exception ex) { return BadRequest("Update failed - " + ex.Message); } }
public void ProblemsVMCreateAndDeleteShouldReturnTrue() { bool deleteOK = false; ProblemViewModel vm = new ProblemViewModel(); vm.Description = "It Broke"; vm.Create(); if (vm.Id.Length == 24) deleteOK = vm.Delete(); Assert.IsTrue(deleteOK); }
public IHttpActionResult Get(string id) { try { ProblemViewModel prb = new ProblemViewModel(); prb.GetById(id); return Ok(prb); } catch (Exception ex) { return BadRequest("Retrive failed - " + ex.Message); } }
public IHttpActionResult Get() { try { ProblemViewModel prb = new ProblemViewModel(); List<ProblemViewModel> allProblems = prb.GetAll(); return Ok(allProblems); } catch (Exception ex) { return BadRequest("Retrive failed - " + ex.Message); } }
public IHttpActionResult Delete(string id) { try { ProblemViewModel prb = new ProblemViewModel(); prb.GetById(id); if (prb.Delete()) return Ok(); else return BadRequest("Could not delete"); } catch (Exception ex) { return BadRequest("Retrive failed - " + ex.Message); } }
public void ProblemVMUpdateTwiceShouldReturnNegative2() { ProblemViewModel vm1 = new ProblemViewModel(); ProblemViewModel vm2 = new ProblemViewModel(); vm1.GetById("56201963f748f2338c59a8d1"); // Device not plugged in Id vm2.GetById("56201963f748f2338c59a8d1"); vm1.Description = "DEVICE NOT PLUGGED IN"; int rowsUpdated = vm1.Update(); if (rowsUpdated == 1) rowsUpdated = vm2.Update(); Assert.IsTrue(rowsUpdated == -2); }
// select all the calls public List <CallViewModel> GetAll() { List <CallViewModel> allVms = new List <CallViewModel>(); try { List <Calls> allCalls = _model.GetAll(); foreach (Calls c in allCalls) { CallViewModel cVm = new CallViewModel(); EmployeeViewModel evm = new EmployeeViewModel(); ProblemViewModel pvm = new ProblemViewModel(); cVm.Id = c.Id; cVm.EmployeeId = c.EmployeeId; cVm.ProblemId = c.ProblemId; cVm.TechId = c.TechId; cVm.DateOpened = c.DateOpened; cVm.DateClosed = c.DateClosed; cVm.OpenStatus = c.OpenStatus; cVm.Notes = c.Notes; cVm.Timer = Convert.ToBase64String(c.Timer); evm.Id = c.EmployeeId; evm.GetById(); cVm.EmployeeName = evm.Lastname; evm.Id = c.TechId; evm.GetById(); cVm.TechName = evm.Lastname; pvm.Id = c.ProblemId; pvm.GetById(); cVm.ProblemDescription = pvm.Description; allVms.Add(cVm); } } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } return(allVms); }
public void GetEmpInfo() { //get employee last name EmployeeViewModel emp = new EmployeeViewModel(); emp.Id = this.EmployeeId; emp.GetById(); this.employee_last_name = emp.Lastname; //get technician info emp.Id = this.TechId; emp.GetById(); this.tech_name = emp.Lastname; //get problem by name ProblemViewModel prob = new ProblemViewModel(); prob.Id = this.ProblemId; prob.GetById(); this.problem_description = prob.Description; }
public List <ProblemViewModel> GetAll() { List <ProblemViewModel> viewModels = new List <ProblemViewModel>(); try { List <Problem> problem = _dao.GetAll(); foreach (Problem prob in problem) { ProblemViewModel viewModel = new ProblemViewModel(); viewModel.Description = prob.Description; viewModel.Version = prob.Version; viewModel.ProblemId = prob.GetIdAsString(); viewModels.Add(viewModel); } } catch (Exception ex) { DALUtils.ErrorRoutine(ex, "ProblemViewModel", "GetAll"); } return(viewModels); }
public List<ProblemViewModel> GetAll() { List<ProblemViewModel> viewModels = new List<ProblemViewModel>(); try { List<Problem> problems = _dao.GetAll(); foreach (Problem e in problems) { // Return only fields for display, subdequent get will other fields ProblemViewModel viewModel = new ProblemViewModel(); viewModel.Id = e._id.ToString(); viewModel.Description = e.Description; viewModels.Add(viewModel); // Add to list } } catch (Exception ex) { ErrorRoutine(ex, "ProblemViewModel", "GetAll"); } return viewModels; }
public List <ProblemViewModel> GetAll() { List <ProblemViewModel> viewModels = new List <ProblemViewModel>(); try { List <Problem> Problems = _dao.GetAll(); foreach (Problem e in Problems) { //return only fields for display, subsequent get wil other fields ProblemViewModel viewModel = new ProblemViewModel(); viewModel.Id = e._id.ToString(); viewModel.Description = e.Description; viewModels.Add(viewModel); //add to list } } catch (Exception ex) { ErrorRoutine(ex, "ProblemViewModel", "GetAll"); } return(viewModels); }
//Retrieve a list of problem view models constructed from all the problems in the database public List <ProblemViewModel> GetAll() { List <ProblemViewModel> allVms = new List <ProblemViewModel>(); try { //Get a list of all problems List <Problem> problems = _model.GetAll(); foreach (Problem prb in problems) { ProblemViewModel pvm = new ProblemViewModel(); pvm.Id = prb.Id; pvm.Description = prb.Description; allVms.Add(pvm); } } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } return(allVms); }
public List <ProblemViewModel> GetAll() { List <ProblemViewModel> allVms = new List <ProblemViewModel>(); try { List <Problem> problems = _model.GetAll(); foreach (Problem p in problems) { ProblemViewModel VM = new ProblemViewModel(); VM.Id = p.Id; VM.Description = p.Description; VM.Timer = Convert.ToBase64String(p.Timer); allVms.Add(VM); } } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); } return(allVms); }
public List <ProblemViewModel> GetAll() { List <ProblemViewModel> allpro = new List <ProblemViewModel>(); try { List <Problem> pros = _model.GetAll(); foreach (Problem pr in pros) { ProblemViewModel pro = new ProblemViewModel(); pro.Id = pr.Id; pro.Description = pr.Description; allpro.Add(pro); } } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } return(allpro); }
public List <ProblemViewModel> GetAll() { List <ProblemViewModel> vmList = new List <ProblemViewModel>(); try { List <Problem> probList = _dao.GetAll(); foreach (Problem e in probList) { //return only fields for display, subsequent get will fill other fields ProblemViewModel viewModel = new ProblemViewModel(); viewModel.Id = e.GetIdAsString(); viewModel.Description = e.Description; vmList.Add(viewModel);//add to list } } catch (Exception ex) { ViewModelUtils.ErrorRoutine(ex, "ProblemViewModel", "GetAll"); } return(vmList); }
public void ProblemVMGetAllShouldReturnList() { ProblemViewModel vm = new ProblemViewModel(); List<ProblemViewModel> prbs = vm.GetAll(); Assert.IsTrue(prbs.Count > 0); }