public List <CallViewModel> GetAll() { List <CallViewModel> allVms = new List <CallViewModel>(); try { List <Call> allCalls = _model.GetAll(); foreach (Call call in allCalls) { CallViewModel cVm = new CallViewModel(); EmployeeModel employee = new EmployeeModel(); ProblemModel problem = new ProblemModel(); cVm.Id = call.Id; cVm.EmployeeId = call.EmployeeId; cVm.ProblemId = call.ProblemId; cVm.TechId = call.TechId; cVm.TechName = employee.GetById(call.TechId).LastName; cVm.EmployeeName = employee.GetById(call.EmployeeId).LastName; cVm.ProblemDescription = problem.GetById(call.ProblemId).Description; cVm.Notes = call.Notes; cVm.DateOpened = call.DateOpened; cVm.DateClosed = call.DateClosed; cVm.OpenStatus = call.OpenStatus; cVm.Timer = Convert.ToBase64String(call.Timer); allVms.Add(cVm); } } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } return(allVms); }
public void callviewmodeltest() { CallViewModel cal = new CallViewModel(); List <CallViewModel> calls = cal.GetAll(); //Assert.IsTrue(calls.Count > 0); foreach (CallViewModel ca in calls) { EmployeeModel emp = new EmployeeModel(); Employee em = emp.GetById(ca.EmployeeId); ProblemModel pro = new ProblemModel(); Problem pr = pro.GetById(ca.ProblemId); } }
public void GetById(int id) { try { Problem prob = _model.GetById(id); Id = prob.Id; Description = prob.Description; Timer = Convert.ToBase64String(prob.Timer); } catch (Exception ex) { Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); } }
public void GetById() { try { Problems p = _model.GetById(Id); Id = p.Id; Description = p.Description; Timer = Convert.ToBase64String(p.Timer); } catch (NullReferenceException nex) { Description = "not found"; } catch (Exception ex) { Description = "not found"; Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message); throw ex; } }