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);
        }
Ejemplo n.º 2
0
 //find an employee using Is property
 public void GetById()
 {
     try
     {
         Employee emp = _model.GetById(Id);
         Title        = emp.Title;
         Firstname    = emp.FirstName;
         Lastname     = emp.LastName;
         Phoneno      = emp.PhoneNo;
         Email        = emp.Email;
         Id           = emp.Id;
         DepartmentId = emp.DepartmentId;
         if (emp.StaffPicture != null)
         {
             StaffPicture64 = Convert.ToBase64String(emp.StaffPicture);
         }
         Timer = Convert.ToBase64String(emp.Timer);
     }
     catch (NullReferenceException nex)
     {
         Lastname = "not found";
     }
     catch (Exception ex)
     {
         Lastname = "not found";
         Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name +
                           " " + ex.Message);
         throw ex;
     }
 }
Ejemplo n.º 3
0
        public void Employee_GetById()
        {
            EmployeeModel model    = new EmployeeModel();
            Employees     employee = model.GetById(1);

            Assert.NotNull(employee);
        }
Ejemplo n.º 4
0
        public IHttpActionResult GetEmployeeById(int id)
        {
            RedisKey cacheKey   = "employee_" + id;
            string   cacheValue = null;

            if (Global._enableRedisCache)
            {
                cacheValue = RedisCacheHelper.GetValueByKey(cacheKey);
            }

            if (cacheValue == null)
            {
                try
                {
                    EmployeeModel model    = new EmployeeModel();
                    var           employee = model.GetById(id);
                    //RedisCacheHelper.SetKeyValue(cacheKey, new JavaScriptSerializer().Serialize(employee));
                    return(Content(HttpStatusCode.OK, employee));
                }
                catch (CDSException cdsEx)
                {
                    return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
                }
                catch (Exception ex)
                {
                    return(Content(HttpStatusCode.InternalServerError, ex));
                }
            }
            else
            {
                return(Ok(JsonConvert.DeserializeObject <Object>(cacheValue)));
            }
        }
 public void EmployeeModelGetbyIdShouldReturnEmployee()
 {
     EmployeeModel model = new EmployeeModel();
     Employee emp = model.GetByLastName("Employee");
     Employee anotherEmp = model.GetById(emp.Id);
     Assert.IsNotNull(anotherEmp);
 }
 //Retrieve an instance of employee using Id property
 public void GetById()
 {
     try
     {
         //Retrieve the employee that has the same Id as the view model object this method was called on
         Employee emp = _model.GetById(Id);
         //Set the remaining properties of the view model object
         Title        = emp.Title;
         Firstname    = emp.FirstName;
         Lastname     = emp.LastName;
         Phoneno      = emp.PhoneNo;
         Email        = emp.Email;
         Id           = emp.Id;
         DepartmentId = emp.DepartmentId;
         if (emp.StaffPicture != null)
         {
             StaffPicture64 = Convert.ToBase64String(emp.StaffPicture);
         }
         Timer = Convert.ToBase64String(emp.Timer);
     }
     catch (NullReferenceException nex)
     {
         Lastname = "not found";
         throw nex;
     }
     catch (Exception ex)
     {
         Lastname = "not found";
         Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message);
         throw ex;
     }
 }
Ejemplo n.º 7
0
        public void EmployeeModelGetByLastNameShouldReturnEmployee()
        {
            EmployeeModel model           = new EmployeeModel();
            Employee      someEmployee    = model.GetByLastname("Nguyen");
            Employee      anotherEmployee = model.GetById(someEmployee.Id);

            Assert.IsNotNull(anotherEmployee);
        }
Ejemplo n.º 8
0
        public void EmployeeModelGetbyIdShouldReturnEmployee()
        {
            EmployeeModel model           = new EmployeeModel();
            Employee      someEmployee    = model.GetByEmail("*****@*****.**");
            Employee      anotherEmployee = model.GetById(someEmployee.Id);

            Assert.IsNotNull(anotherEmployee);
        }
Ejemplo n.º 9
0
        public void EmployeeModelGetbyIdShouldReturnEmployee()
        {
            EmployeeModel model           = new EmployeeModel();
            Employee      someEmployee    = model.GetByLastname("Employee"); // retrieve Employee we just added
            Employee      anotherEmployee = model.GetById(someEmployee.Id);  // this is for the actual test

            Assert.IsNotNull(anotherEmployee);
        }
Ejemplo n.º 10
0
        public void Employee_Update()
        {
            EmployeeModel model           = new EmployeeModel();
            Employees     currentEmployee = model.GetById(13);

            if (currentEmployee != null)
            {
                string oldPhoneNo = currentEmployee.PhoneNo;
                string newphoneNo = oldPhoneNo == "(555)000-0000" ? "(222)000-0000" : "(555)000-0000";
                currentEmployee.PhoneNo = newphoneNo;
            }
            Assert.True(model.Update(currentEmployee) == UpdateStatus.Ok);
        }
        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);
            }
        }
Ejemplo n.º 12
0
        public void doIt()
        {
            try
            {
                Document document = new Document();
                PdfWriter.GetInstance(document, new FileStream(mappedpath + "PDF/Call.pdf", FileMode.Create));
                document.Open();
                Paragraph para   = new Paragraph();
                Image     image1 = Image.GetInstance(mappedpath + IMG);
                image1.SetAbsolutePosition(25f, 740f);
                image1.ScalePercent(15f);
                para.Add(image1);
                para.Alignment = Element.ALIGN_RIGHT;
                //Lets write a big header
                addEmptyLine(para, 1);
                Paragraph mainHead = new Paragraph(String.Format("{0,8}", "Calls"), catFont);
                mainHead.Alignment = Element.ALIGN_CENTER;

                para.Add(mainHead);
                addEmptyLine(para, 3);

                PdfPTable table = new PdfPTable(6);
                table.WidthPercentage = 100.00F;
                table.AddCell(addCell("Opened", "h"));
                table.AddCell(addCell("Lastname", "h"));
                table.AddCell(addCell("Tech", "h"));
                table.AddCell(addCell("Problem", "h"));
                table.AddCell(addCell("Status", "h"));
                table.AddCell(addCell("Closed", "h"));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));
                table.AddCell(addCell(" "));

                CallViewModel        call  = new CallViewModel();
                List <CallViewModel> calls = call.GetAll();

                foreach (CallViewModel cal in calls)
                {
                    EmployeeModel emp      = new EmployeeModel();
                    Employee      employee = emp.GetById(cal.TechId);
                    table.AddCell(addCell(cal.DateOpened.ToString("MM/dd/yyyy")));
                    table.AddCell(addCell(cal.EmployeeName));
                    table.AddCell(addCell(employee.LastName));
                    table.AddCell(addCell(cal.ProblemDescription));
                    table.AddCell(addCell(cal.OpenStatus?"Open":"Closed"));
                    table.AddCell(addCell((cal.DateClosed == null)?"":((DateTime)cal.DateClosed).ToString("MM-dd-yyyy")));
                }

                para.Add(table);
                addEmptyLine(para, 3);
                para.Alignment = Element.ALIGN_CENTER;
                Paragraph footer = new Paragraph("Call report written on - " + DateTime.Now, smallFont);
                footer.Alignment = Element.ALIGN_CENTER;
                para.Add(footer);
                document.Add(para);
                document.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error " + ex.Message);
            }
        }