Beispiel #1
0
        public void GetLastBTForEmployee_EmployeeNull_null()
        {
            //Arrange
            Employee employee = null;

            //Act
            DateTime?lastBTEndDate = DisplayPermitStatusHelper.GetLastBTForEmployee(employee);

            //Assert
            Assert.AreEqual(null, lastBTEndDate);
        }
Beispiel #2
0
        public void GetStartingDateTimePointForPermitExpiration_GetLastBTForEmployeeNotNull_LastBTDate()
        {
            //Arrange
            Employee employee = mock.Object.Employees.Where(e => e.EmployeeID == 5).FirstOrDefault();

            //Act
            DateTime startingPoint = DisplayPermitStatusHelper.GetStartingDateTimePointForPermitExpiration(employee);

            //Assert
            Assert.AreEqual(new DateTime(2013, 10, 05), startingPoint.Date);
        }
Beispiel #3
0
        public bool Is90DaysAndAbove_ValidDates_Validresult(int DaysToAdd)
        {
            //Arrange
            DateTime dateNow = DateTime.Now.ToLocalTimeAzure();

            //Act
            bool result = DisplayPermitStatusHelper.Is90DaysAndAbove(dateNow.AddDays(-DaysToAdd));

            //Assert
            return(result);
        }
Beispiel #4
0
        public void GetStartingDateTimePointForPermitExpiration_GetLastBTForEmployeeNull_PermitNull_DateTimeNow()
        {
            //Arrange
            Employee employee = mock.Object.Employees.Where(e => e.EmployeeID == 6).FirstOrDefault();

            //Act
            DateTime startingPoint = DisplayPermitStatusHelper.GetStartingDateTimePointForPermitExpiration(employee);

            //Assert
            Assert.AreEqual(DateTime.Now.ToLocalTimeAzure().Date, startingPoint.Date);
        }
Beispiel #5
0
        public void GetStartingDateTimePointForPermitExpiration_EmployeeNull_DateTimeNow()
        {
            //Arrange
            Employee employee = null;

            //Act
            DateTime startingPoint = DisplayPermitStatusHelper.GetStartingDateTimePointForPermitExpiration(employee);

            //Assert
            Assert.AreEqual(DateTime.Now.ToLocalTimeAzure().Date, startingPoint.Date);
        }
Beispiel #6
0
        public void GetLastBTForEmployee_EmployeeHasNoLastBT_null()
        {
            //Arrange
            Employee employee = mock.Object.Employees.Where(e => e.EmployeeID == 6).FirstOrDefault();

            //Act
            DateTime?lastBTEndDate = DisplayPermitStatusHelper.GetLastBTForEmployee(employee);

            //Assert
            Assert.AreEqual(null, lastBTEndDate);
        }
Beispiel #7
0
        public void GetLastBTForEmployee_EmployeeHasLastBT_ValidDate()
        {
            //Arrange
            Employee employee = mock.Object.Employees.Where(e => e.EmployeeID == 5).FirstOrDefault();

            //Act
            DateTime?lastBTEndDate = DisplayPermitStatusHelper.GetLastBTForEmployee(employee);

            //Assert
            Assert.AreEqual(new DateTime(2013, 10, 05), lastBTEndDate.Value.Date);
        }
Beispiel #8
0
        public void GetLastBTForEmployee_EmployeeHasNoLastBTWrongBTStatus_null()
        {
            //Arrange
            Employee employee = mock.Object.Employees.Where(e => e.EmployeeID == 5).FirstOrDefault();

            employee.BusinessTrips.Where(b => b.BusinessTripID == 27).FirstOrDefault().Status = BTStatus.Cancelled;
            BusinessTrip lastBTwithWrongStatus = employee.BusinessTrips.Where(b => b.BusinessTripID == 27).FirstOrDefault();

            employee.BusinessTrips.Clear();
            employee.BusinessTrips.Add(lastBTwithWrongStatus);
            //Act
            DateTime?lastBTEndDate = DisplayPermitStatusHelper.GetLastBTForEmployee(employee);

            //Assert
            Assert.AreEqual(null, lastBTEndDate);
        }
Beispiel #9
0
        public void GetLastBTForEmployee_EmployeeHasNoLastBTWrongDateLesserThanLastPermitStartDate_null()
        {
            //Arrange
            Employee employee = mock.Object.Employees.Where(e => e.EmployeeID == 5).FirstOrDefault();

            employee.BusinessTrips.Where(b => b.BusinessTripID == 27).FirstOrDefault().StartDate = DateTime.Now.ToLocalTimeAzure().AddDays(-1200);
            employee.BusinessTrips.Where(b => b.BusinessTripID == 27).FirstOrDefault().EndDate   = DateTime.Now.ToLocalTimeAzure().AddDays(-1000);
            BusinessTrip lastBTwithWrongStatus = employee.BusinessTrips.Where(b => b.BusinessTripID == 27).FirstOrDefault();

            employee.BusinessTrips.Clear();
            employee.BusinessTrips.Add(lastBTwithWrongStatus);
            //Act
            DateTime?lastBTEndDate = DisplayPermitStatusHelper.GetLastBTForEmployee(employee);

            //Assert
            Assert.AreEqual(null, lastBTEndDate);
        }
Beispiel #10
0
        public List <string> PrepareToXLSExportVisasVU()
        {
            List <string> stringifiedProperties = new List <string>();

            stringifiedProperties.Add(this.EID);
            if (this.DateDismissed != null)
            {
                stringifiedProperties.Add(this.LastName + " " + this.FirstName + "\r\n" + this.DateDismissed.Value.ToShortDateString());
            }
            else
            {
                stringifiedProperties.Add(this.LastName + " " + this.FirstName);
            }

            if (this.Passport != null)
            {
                if (this.Passport.EndDate.HasValue)
                {
                    stringifiedProperties.Add("till\r\n" + this.Passport.EndDate.Value.ToString(String.Format("dd.MM.yyyy")));
                }
                else
                {
                    stringifiedProperties.Add("yes");
                }
            }
            else
            {
                stringifiedProperties.Add("no");
            }

            if (this.Visa != null)
            {
                stringifiedProperties.Add(this.Visa.VisaType);
                stringifiedProperties.Add(this.Visa.StartDate.ToString(String.Format("yyyy-MM-dd")));
                stringifiedProperties.Add(this.Visa.DueDate.ToString(String.Format("yyyy-MM-dd")));

                if (this.Visa.Entries == 0)
                {
                    stringifiedProperties.Add("MULT");
                }
                else
                {
                    stringifiedProperties.Add(this.Visa.Entries.ToString() + "(" + (this.Visa.EntriesUsedInPrivateTrips.GetValueOrDefault() + this.Visa.EntriesUsedInBT.GetValueOrDefault() + this.Visa.CorrectionForVisaEntries.GetValueOrDefault()).ToString() + ")");
                }

                stringifiedProperties.Add(this.Visa.Days.ToString() + "(" + (this.Visa.DaysUsedInPrivateTrips.GetValueOrDefault() + this.Visa.DaysUsedInBT.GetValueOrDefault() + this.Visa.CorrectionForVisaDays.GetValueOrDefault()).ToString() + ")");
            }
            else
            {
                stringifiedProperties.Add("");
                stringifiedProperties.Add("No Visa");
                stringifiedProperties.Add("No Visa");
                stringifiedProperties.Add("");
                stringifiedProperties.Add("");
            }

            if (this.VisaRegistrationDate != null && this.VisaRegistrationDate.RegistrationDate != null && this.VisaRegistrationDate.RegistrationDate.HasValue)
            {
                stringifiedProperties.Add(this.VisaRegistrationDate.RegistrationDate.Value.ToString(String.Format("dd.MM.yyyy")));
            }
            else
            {
                stringifiedProperties.Add("");
            }

            if (this.Permit != null)
            {
                if (this.Permit.Number != null || this.Permit.StartDate != null || this.Permit.EndDate != null)
                {
                    stringifiedProperties.Add(this.Permit.Number ?? "");

                    if (this.Permit.IsKartaPolaka)
                    {
                        if (this.Permit.StartDate != null && this.Permit.EndDate != null)
                        {
                            stringifiedProperties.Add("Karta Polaka" + "\r\n" + this.Permit.StartDate.Value.ToString(String.Format("dd.MM.yyyy")) + " - " + this.Permit.EndDate.Value.ToString(String.Format("dd.MM.yyyy")));
                        }
                        else
                        {
                            stringifiedProperties.Add("Karta Polaka");
                        }
                    }
                    else
                    {
                        stringifiedProperties.Add(this.Permit.StartDate.Value.ToShortDateString() + " - " + this.Permit.EndDate.Value.ToShortDateString());
                    }
                }
                else
                {
                    stringifiedProperties.Add("");
                    if (this.Permit.IsKartaPolaka == true && this.Permit.Number == null && this.Permit.StartDate == null && this.Permit.EndDate == null)
                    {
                        stringifiedProperties.Add("Karta Polaka");
                    }
                    else
                    {
                        stringifiedProperties.Add("");
                    }
                }
            }
            else
            {
                stringifiedProperties.Add("");
                stringifiedProperties.Add("No Permit");
            }

            if (this.BusinessTrips != null)
            {
                BusinessTrip lastBT = this.BusinessTrips
                                      .Where(b => (b.EndDate < DateTime.Now.ToLocalTimeAzure().Date) &&
                                             (b.Status == (BTStatus.Confirmed | BTStatus.Reported)))
                                      .OrderBy(b => b.EndDate)
                                      .LastOrDefault();
                if (lastBT != null)
                {
                    stringifiedProperties.Add(lastBT.Location.Title + ":" + lastBT.StartDate.ToString("dd.MM.yy") + " - " + lastBT.EndDate.ToString("dd.MM.yy"));
                }
                else
                {
                    stringifiedProperties.Add("");
                }
            }
            else
            {
                stringifiedProperties.Add("");
            }

            if (this.Permit != null && this.Permit.EndDate != null)
            {
                DateTime StartingPoint = DisplayPermitStatusHelper.GetStartingDateTimePointForPermitExpiration(this);
                if (DisplayPermitStatusHelper.Is90DaysAndAbove(StartingPoint))
                {
                    stringifiedProperties.Add("Contact Gov");
                }

                else if (DisplayPermitStatusHelper.Is60ToLessThan90Days(StartingPoint))
                {
                    stringifiedProperties.Add("Contact Gov");
                }

                else if (this.Permit.ProlongRequestDate != null)
                {
                    stringifiedProperties.Add(this.Permit.ProlongRequestDate.Value.ToString(String.Format("dd.MM.yyyy")));
                }

                else if (this.Permit.CancelRequestDate != null)
                {
                    stringifiedProperties.Add(this.Permit.CancelRequestDate.Value.ToString(String.Format("dd.MM.yyyy")));
                }
            }
            else
            {
                stringifiedProperties.Add("");
            }
            return(stringifiedProperties);
        }
Beispiel #11
0
        public void WriteVisasAndPermitsData(Worksheet workSheet, string searchString = "")
        {
            int i = 1;

            searchString = searchString != "" ? searchString.Trim() : "";

            List <Employee> selected = repository.Employees.ToList();
            List <Employee> empsWithVisasAndPermits = SearchVisaData(selected, searchString);

            foreach (Employee emp in empsWithVisasAndPermits)
            {
                workSheet.Cells[i, 0] = new Cell(emp.EID);

                if (emp.DateDismissed != null)
                {
                    workSheet.Cells[i, 1] = new Cell(emp.LastName + " " + emp.FirstName + "\n" + emp.DateDismissed.Value.ToShortDateString());
                }
                else
                {
                    workSheet.Cells[i, 1] = new Cell(emp.LastName + " " + emp.FirstName);
                }

                if (emp.Passport != null)
                {
                    if (emp.Passport.EndDate.HasValue)
                    {
                        workSheet.Cells[i, 2] = new Cell("till\n" + emp.Passport.EndDate.Value.ToString(String.Format("dd.MM.yyyy")));
                    }
                    else
                    {
                        workSheet.Cells[i, 2] = new Cell("yes");
                    }
                }
                else
                {
                    workSheet.Cells[i, 2] = new Cell("no");
                }

                if (emp.Visa != null)
                {
                    if (!emp.Visa.DaysUsedInBT.HasValue)
                    {
                        emp.Visa.DaysUsedInBT = 0;
                    }

                    if (!emp.Visa.EntriesUsedInPrivateTrips.HasValue)
                    {
                        emp.Visa.EntriesUsedInPrivateTrips = 0;
                    }

                    if (!emp.Visa.EntriesUsedInBT.HasValue)
                    {
                        emp.Visa.EntriesUsedInBT = 0;
                    }

                    if (!emp.Visa.CorrectionForVisaEntries.HasValue)
                    {
                        emp.Visa.CorrectionForVisaEntries = 0;
                    }

                    if (!emp.Visa.DaysUsedInPrivateTrips.HasValue)
                    {
                        emp.Visa.DaysUsedInPrivateTrips = 0;
                    }

                    if (!emp.Visa.DaysUsedInBT.HasValue)
                    {
                        emp.Visa.DaysUsedInBT = 0;
                    }

                    if (!emp.Visa.CorrectionForVisaDays.HasValue)
                    {
                        emp.Visa.CorrectionForVisaDays = 0;
                    }


                    workSheet.Cells[i, 3] = new Cell(emp.Visa.VisaType);
                    workSheet.Cells[i, 4] = new Cell(emp.Visa.StartDate.ToString(String.Format("yyyy-MM-dd")));
                    workSheet.Cells[i, 5] = new Cell(emp.Visa.DueDate.ToString(String.Format("yyyy-MM-dd")));

                    if (emp.Visa.Entries == 0)
                    {
                        workSheet.Cells[i, 6] = new Cell("MULT");
                    }
                    else
                    {
                        workSheet.Cells[i, 6] = new Cell(emp.Visa.Entries.ToString() + "(" + (emp.Visa.EntriesUsedInPrivateTrips.Value + emp.Visa.EntriesUsedInBT.Value + emp.Visa.CorrectionForVisaEntries.Value).ToString() + ")");
                    }

                    workSheet.Cells[i, 7] = new Cell(emp.Visa.Days.ToString() + "(" + (emp.Visa.DaysUsedInPrivateTrips.Value + emp.Visa.DaysUsedInBT.Value + emp.Visa.CorrectionForVisaDays.Value).ToString() + ")");
                }
                else
                {
                    workSheet.Cells[i, 3] = new Cell("");
                    workSheet.Cells[i, 4] = new Cell("No Visa");
                    workSheet.Cells[i, 5] = new Cell("No Visa");
                    workSheet.Cells[i, 6] = new Cell("");
                    workSheet.Cells[i, 7] = new Cell("");
                }

                if (emp.VisaRegistrationDate != null)
                {
                    workSheet.Cells[i, 8] = new Cell(emp.VisaRegistrationDate.RegistrationDate.ToString(String.Format("dd.MM.yyyy")));
                }
                else
                {
                    workSheet.Cells[i, 8] = new Cell("");
                }

                if (emp.Permit != null)
                {
                    if (emp.Permit.Number != null || emp.Permit.StartDate != null || emp.Permit.EndDate != null)
                    {
                        workSheet.Cells[i, 9] = new Cell(emp.Permit.Number);

                        if (emp.Permit.IsKartaPolaka)
                        {
                            workSheet.Cells[i, 10] = new Cell("Karta Polaka");

                            if (emp.Permit.StartDate != null && emp.Permit.EndDate != null)
                            {
                                workSheet.Cells[i, 10] = new Cell("Karta Polaka" + "\n" + emp.Permit.StartDate.Value.ToString(String.Format("dd.MM.yyyy")) + " - " + emp.Permit.EndDate.Value.ToString(String.Format("dd.MM.yyyy")));
                            }
                        }
                        else
                        {
                            workSheet.Cells[i, 10] = new Cell(emp.Permit.StartDate.Value.ToShortDateString() + " - " + emp.Permit.EndDate.Value.ToShortDateString());
                        }
                    }
                    else
                    {
                        if (emp.Permit.IsKartaPolaka == true && emp.Permit.Number == null && emp.Permit.StartDate == null && emp.Permit.EndDate == null)
                        {
                            workSheet.Cells[i, 10] = new Cell("Karta Polaka");
                        }
                    }
                }
                else
                {
                    workSheet.Cells[i, 10] = new Cell("No Permit");
                }

                if (emp.BusinessTrips != null)
                {
                    BusinessTrip lastBT = emp.BusinessTrips
                                          .Where(b => (b.EndDate < DateTime.Now.ToLocalTimeAzure().Date) &&
                                                 (b.Status == (BTStatus.Confirmed | BTStatus.Reported)))
                                          .LastOrDefault();
                    if (lastBT != null)
                    {
                        workSheet.Cells[i, 11] = new Cell(lastBT.Location.Title + ":" + lastBT.StartDate.ToString("dd.MM.yy") + " - " + lastBT.EndDate.ToString("dd.MM.yy"));
                    }
                    else
                    {
                        workSheet.Cells[i, 11] = new Cell("");
                    }
                }

                if (emp.Permit != null && emp.Permit.EndDate != null)
                {
                    if (emp.Permit.CancelRequestDate != null)
                    {
                        workSheet.Cells[i, 12] = new Cell(emp.Permit.CancelRequestDate.Value.ToString(String.Format("dd.MM.yyyy")));
                    }
                    if (emp.Permit.ProlongRequestDate != null)
                    {
                        workSheet.Cells[i, 12] = new Cell(emp.Permit.ProlongRequestDate.Value.ToString(String.Format("dd.MM.yyyy")));
                    }

                    DateTime StartingPoint = DisplayPermitStatusHelper.GetStartingDateTimePointForPermitExpiration(emp);

                    if (DisplayPermitStatusHelper.Is60ToLessThan90Days(StartingPoint))
                    {
                        workSheet.Cells[i, 12] = new Cell("Contact Gov");
                    }
                    if (DisplayPermitStatusHelper.Is90DaysAndAbove(StartingPoint))
                    {
                        workSheet.Cells[i, 12] = new Cell("Contact Gov");
                    }
                }
                else
                {
                    workSheet.Cells[i, 12] = new Cell("");
                }

                i++;
            }
        }