Exemplo n.º 1
0
        public int GetHolidayCount(string startDate, string endDate)
        {
            DateTime startDateFormatted = System.DateTime.Now;
            DateTime endDateFormatted   = System.DateTime.Now;//TODO check these conditions

            if (startDate != null)
            {
                if (startDate.Trim() != "")
                {
                    try
                    {
                        startDateFormatted = DateTime.Parse(startDate, new CultureInfo("en-GB", true));
                        endDateFormatted   = DateTime.Parse(endDate, new CultureInfo("en-GB", true));
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }

            if (startDateFormatted > endDateFormatted)
            {
                return(0);
            }

            int holidayCount = 0;

            using (var client = new LeaveClient())
            {
                holidayCount = client.GetHolidayCount(startDateFormatted, endDateFormatted, UserId);
            }
            return(holidayCount);
        }