// 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 EmployeeVMUpdateShouldReturnTrue() { EmployeeViewModel vm = new EmployeeViewModel(); vm.GetById("56201963f748f2338c59a8c7"); // Smartypants id vm.Phoneno = "555-555-5551"; int rowsUpdated = vm.Update(); Assert.IsTrue(rowsUpdated == 1); }
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 IHttpActionResult Get(string id) { try { EmployeeViewModel emp = new EmployeeViewModel(); emp.GetById(id); return Ok(emp); } catch (Exception ex) { return BadRequest("Retrive failed - " + ex.Message); } }
public IHttpActionResult Delete(string empId) { try { EmployeeViewModel emp = new EmployeeViewModel(); emp.GetById(empId); emp.Delete(); return Ok(emp.Lastname + " has been deleted"); } catch (Exception e) { return BadRequest("Delete failed - " + e.Message); } }
public void EmployeeVMUpdateTwiceShouldReturnNegative2() { EmployeeViewModel vm1 = new EmployeeViewModel(); EmployeeViewModel vm2 = new EmployeeViewModel(); vm1.GetById("56201963f748f2338c59a8c7"); // Smartypants Id vm2.GetById("56201963f748f2338c59a8c7"); vm1.Phoneno = "555-555-5551"; int rowsUpdated = vm1.Update(); if (rowsUpdated == 1) rowsUpdated = vm2.Update(); Assert.IsTrue(rowsUpdated == -2); }
public IHttpActionResult Delete(string id) { try { EmployeeViewModel emp = new EmployeeViewModel(); emp.GetById(id); if (emp.Delete()) return Ok("Employee Deleted"); else return BadRequest("Could not delete"); } catch (Exception ex) { return BadRequest("Retrive failed - " + ex.Message); } }