Example #1
0
        public MvcHtmlString GetJourneysAndOvertimesForOneEmp(int eID = 0)
        {
            using (OvertimeController controller = new OvertimeController(repository))
            {
                if (repository.Employees.Where(e => e.EmployeeID == eID).Count() != 0)
                {
                    List <DateTime> journeyDates  = new List <DateTime>();
                    List <DateTime> overtimeDates = new List <DateTime>();

                    journeyDates  = SearchJourneyDataForOneEmp(eID);
                    overtimeDates = controller.SearchOvertimeDataForOneEmp(eID);

                    List <DateTime> overtimeAndJorneyDates = new List <DateTime>();
                    overtimeAndJorneyDates.AddRange(journeyDates);
                    overtimeAndJorneyDates.AddRange(overtimeDates);
                    overtimeAndJorneyDates.Sort();

                    return(CreateDatesToReclaimForDropdown(overtimeAndJorneyDates));
                }
                else
                {
                    return(new MvcHtmlString(""));
                }
            }
        }
Example #2
0
        public MvcHtmlString GetJourneysAndOvertimesForOneEmpEdit(int eID, string from)
        {
            using (OvertimeController controller = new OvertimeController(repository))
            {
                if (repository.Employees.Where(e => e.EmployeeID == eID).Count() != 0)
                {
                    DateTime parseFrom;
                    try
                    {
                        parseFrom = DateTime.ParseExact(from, "dd.MM.yyyy", null);
                    }
                    catch (SystemException)
                    {
                        return(new MvcHtmlString(""));
                    }
                    List <DateTime> journeyDates  = new List <DateTime>();
                    List <DateTime> overtimeDates = new List <DateTime>();

                    journeyDates  = SearchJourneyDataForOneEmp(eID);
                    overtimeDates = controller.SearchOvertimeDataForOneEmp(eID);

                    List <DateTime> overtimeAndJorneyDates = new List <DateTime>();
                    overtimeAndJorneyDates.AddRange(journeyDates);
                    overtimeAndJorneyDates.AddRange(overtimeDates);
                    DateTime reclaimDateOvertimes = repository.Overtimes
                                                    .Where(o => o.EmployeeID == eID &&
                                                           o.ReclaimDate == parseFrom)
                                                    .Select(o => o.Date).FirstOrDefault();
                    DateTime reclaimDateJourneys = repository.Journeys
                                                   .Where(o => o.JourneyOf.EmployeeID == eID &&
                                                          o.ReclaimDate == parseFrom)
                                                   .Select(o => o.Date).FirstOrDefault();

                    overtimeAndJorneyDates.Sort();

                    if (reclaimDateOvertimes != DateTime.MinValue)
                    {
                        overtimeAndJorneyDates.Insert(0, reclaimDateOvertimes);
                    }
                    if (reclaimDateJourneys != DateTime.MinValue)
                    {
                        overtimeAndJorneyDates.Insert(0, reclaimDateJourneys);
                    }

                    return(CreateDatesToReclaimForDropdown(overtimeAndJorneyDates));
                }
                else
                {
                    return(new MvcHtmlString(""));
                }
            }
        }