示例#1
0
        public decimal ReturnDuration(string LeaveFrom, string LeaveUpto, string LeaveFromTime, string LeaveUptoTime)
        {
            DateTime startDateFormatted = System.DateTime.Now;
            DateTime endDateFormatted   = System.DateTime.Now;//TODO check these conditions

            if (LeaveFrom != null)
            {
                if (LeaveFrom.Trim() != "")
                {
                    try
                    {
                        startDateFormatted = DateTime.Parse(LeaveFrom, new CultureInfo("en-GB", true));
                        endDateFormatted   = DateTime.Parse(LeaveUpto, new CultureInfo("en-GB", true));
                    }
                    catch
                    {
                    }
                }
            }
            if (startDateFormatted > endDateFormatted)
            {
                return(0);
            }

            decimal duration = 0;

            using (var client = new LeaveClient())
            {
                duration = client.ReturnDuration(startDateFormatted, endDateFormatted, LeaveFromTime, LeaveUptoTime, UserId);
            }

            return(duration);
        }