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 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 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);
        }
예제 #5
0
        // 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);
        }
예제 #6
0
        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;
        }