Пример #1
0
        //Retrieves a list of CallViewModels based on a list of all Calls in the database
        public List <CallViewModel> GetAll()
        {
            List <CallViewModel> allVms = new List <CallViewModel>();

            try
            {
                //Get a list of all the calls and use each call in that list to create a view model and then return the list of view model objects
                List <Call> allCalls = _model.GetAll();
                foreach (Call call in allCalls)
                {
                    CallViewModel cvm = new CallViewModel();
                    cvm.Id = call.Id;
                    //Sub properties
                    cvm.EmployeeName       = call.Employee.LastName;
                    cvm.ProblemDescription = call.Problem.Description;
                    cvm.TechName           = call.Employee1.LastName;

                    cvm.EmployeeId = call.EmployeeId;
                    cvm.ProblemId  = call.ProblemId;
                    cvm.TechId     = call.TechId;
                    cvm.DateOpened = call.DateOpened;
                    cvm.DateClosed = call.DateClosed;
                    cvm.OpenStatus = call.OpenStatus;
                    cvm.Notes      = call.Notes;
                    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);
        }//end getAll
Пример #2
0
        public List <CallViewModel> GetAll()
        {
            List <CallViewModel> allVms = new List <CallViewModel>();

            try
            {
                List <Call> allCalls = _model.GetAll();

                foreach (Call call in allCalls)
                {
                    CallViewModel callVm = new CallViewModel();
                    callVm.Id         = call.Id;
                    callVm.EmployeeId = call.EmployeeId;
                    callVm.ProblemId  = call.ProblemId;
                    callVm.DateOpened = call.DateOpened;
                    callVm.DateClosed = call.DateClosed;
                    callVm.OpenStatus = call.OpenStatus;
                    callVm.TechId     = call.TechId;
                    callVm.Notes      = call.Notes;
                    callVm.Timer      = Convert.ToBase64String(call.Timer);
                    callVm.Problem    = call.Problem.Description;
                    callVm.Employee   = call.Employee.FirstName + " " + call.Employee.LastName;
                    callVm.Tech       = call.Employee1.FirstName + " " + call.Employee1.LastName;
                    allVms.Add(callVm);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " +
                                  MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }
            return(allVms);
        }
Пример #3
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);
        }
Пример #4
0
        // Retrieve all the EmployeeViewModel objects and add them to a List
        public List <CallViewModel> GetAll()
        {
            // Create a list to hold the EmployeeViewModel objects
            List <CallViewModel> allVms = new List <CallViewModel>();

            try
            {
                // Create the List to hold the Employee objects. Uses the GetAll()
                // from the EmployeeModel class to populate this List
                List <Call> allCalls = _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 (Call call in allCalls)
                {
                    CallViewModel callVm = new CallViewModel();
                    callVm.Id         = call.Id;
                    callVm.EmployeeId = call.EmployeeId;
                    callVm.ProblemId  = call.ProblemId;
                    callVm.TechId     = call.TechId;
                    callVm.DateOpened = call.DateOpened;
                    callVm.DateClosed = call.DateClosed;
                    callVm.OpenStatus = call.OpenStatus;
                    callVm.Notes      = call.Notes;
                    callVm.Timer      = Convert.ToBase64String(call.Timer);

                    callVm.EmployeeName       = call.Employee.FirstName + " " + call.Employee.LastName;
                    callVm.TechName           = call.Employee1.FirstName + " " + call.Employee1.LastName;
                    callVm.ProblemDescription = call.Problem.Description;

                    allVms.Add(callVm);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " +
                                  MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }

            // Return the List of EmployeeViewModel objects
            return(allVms);
        }
Пример #5
0
        //Retrive all the calls
        public List <CallViewModel> GetAll()
        {
            List <CallViewModel> allCalls = new List <CallViewModel>();

            try
            {
                List <Call> allCal = _model.GetAll();
                foreach (Call ca in allCal)
                {
                    CallViewModel cal = new CallViewModel();
                    EmployeeModel emp = new EmployeeModel();
                    Employee      em  = emp.GetById(ca.EmployeeId);
                    ProblemModel  pro = new ProblemModel();
                    Problem       pr  = pro.GetById(ca.ProblemId);
                    cal.Id                 = ca.Id;
                    cal.EmployeeId         = ca.EmployeeId;
                    cal.EmployeeName       = em.LastName;
                    cal.TechId             = ca.TechId;
                    cal.ProblemId          = ca.ProblemId;
                    cal.ProblemDescription = pr.Description;
                    cal.OpenStatus         = ca.OpenStatus;
                    cal.Notes              = ca.Notes;
                    cal.DateOpened         = ca.DateOpened;
                    cal.DateClosed         = ca.DateClosed;
                    cal.Timer              = Convert.ToBase64String(ca.Timer);
                    allCalls.Add(cal);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }

            return(allCalls);
        }