/// <summary>
        /// Create XML to add time off request.
        /// </summary>
        /// <param name="startDate">Start date.</param>
        /// <param name="endDate">End Date.</param>
        /// <param name="personNumber">Person number.</param>
        /// <param name="reason">Reason string.</param>
        /// <returns>Add time of request.</returns>
        public string CreateAddTimeOffRequest(string startDate, string endDate, string personNumber, string reason)
        {
            TimeOffAddRequest.TimeOffPeriod[] t = new TimeOffAddRequest.TimeOffPeriod[]
            {
                new TimeOffPeriod()
                {
                    Duration    = "FULL_DAY",
                    EndDate     = endDate,
                    PayCodeName = reason,
                    StartDate   = startDate,
                },
            };
            Request rq = new Request()
            {
                Action             = ApiConstants.AddRequests,
                EmployeeRequestMgm = new TimeOffAddRequest.EmployeeRequestMgmt()
                {
                    Employees = new TimeOffAddRequest.Employee()
                    {
                        PersonIdentity = new TimeOffAddRequest.PersonIdentity()
                        {
                            PersonNumber = personNumber
                        }
                    },
                    QueryDateSpan = $"{startDate} - {endDate}",
                    RequestItems  = new TimeOffAddRequest.RequestItems()
                    {
                        GlobalTimeOffRequestItem = new TimeOffAddRequest.GlobalTimeOffRequestItem()
                        {
                            Employee = new TimeOffAddRequest.Employee()
                            {
                                PersonIdentity = new TimeOffAddRequest.PersonIdentity()
                                {
                                    PersonNumber = personNumber
                                }
                            },
                            RequestFor     = "TOR",
                            TimeOffPeriods = new TimeOffAddRequest.TimeOffPeriods()
                            {
                                TimeOffPeriod = t
                            },
                        },
                    },
                },
            };

            return(rq.XmlSerialize <TimeOffAddRequest.Request>());
        }
        /// <summary>
        /// Create XML to add advanced time off request.
        /// </summary>
        /// <param name="personNumber">Person Number.</param>
        /// <param name="obj">Submitted values from employee.</param>
        /// <returns>Advanced time of request.</returns>
        public string CreateAddAdvancedTimeOffRequest(string personNumber, AdvancedTimeOff obj)
        {
            var    monthStartDt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            var    monthEndDt   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(monthStartDt.Year, monthStartDt.Month));
            double?length       = null;

            if (obj.duration.ToLowerInvariant() == Constants.Hours.ToLowerInvariant())
            {
                var shr  = Convert.ToInt32(obj.StartTime.Split(' ')[0].Split(':')[0]);
                var smin = Convert.ToInt32(obj.StartTime.Split(' ')[0].Split(':')[1]);
                var ehr  = Convert.ToInt32(obj.EndTime.Split(' ')[0].Split(':')[0]);
                var emin = Convert.ToInt32(obj.EndTime.Split(' ')[0].Split(':')[1]);

                length = new DateTime(2000, 1, 1, ehr, emin, 0).Subtract(new DateTime(2000, 1, 1, shr, smin, 0)).TotalHours;
            }

            TimeOffAddRequest.TimeOffPeriod[] t = new TimeOffAddRequest.TimeOffPeriod[]
            {
                new TimeOffAddRequest.TimeOffPeriod()
                {
                    Duration    = obj.duration,
                    EndDate     = obj.edt,
                    PayCodeName = obj.DeductFrom,
                    StartDate   = obj.sdt,
                    StartTime   = obj.duration.ToLowerInvariant() == Constants.Hours.ToLowerInvariant() ? obj.StartTime : null,
                    Length      = length?.ToString(),
                },
            };
            Request rq = new Request()
            {
                Action             = ApiConstants.AddRequests,
                EmployeeRequestMgm = new EmployeeRequestMgmt()
                {
                    Employees = new Employee()
                    {
                        PersonIdentity = new TimeOffAddRequest.PersonIdentity()
                        {
                            PersonNumber = personNumber
                        }
                    },
                    QueryDateSpan = monthStartDt.ToString("M/d/yyyy", CultureInfo.InvariantCulture) + "-" + monthEndDt.ToString("M/d/yyyy", CultureInfo.InvariantCulture),
                    RequestItems  = new RequestItems()
                    {
                        GlobalTimeOffRequestItem = new GlobalTimeOffRequestItem()
                        {
                            Employee = new Employee()
                            {
                                PersonIdentity = new PersonIdentity()
                                {
                                    PersonNumber = personNumber
                                }
                            },
                            RequestFor     = "TOR",
                            TimeOffPeriods = new TimeOffPeriods()
                            {
                                TimeOffPeriod = t
                            },
                            Comments = new Comments {
                                Comment = null
                            },
                        },
                    },
                },
            };

            if (!string.IsNullOrEmpty(obj.Note))
            {
                rq.EmployeeRequestMgm.RequestItems.GlobalTimeOffRequestItem.Comments.Comment = new List <Comment>
                {
                    new Comment {
                        CommentText = obj.Comment, Notes = new Notes {
                            Note = new Note {
                                Text = obj.Note
                            }
                        }
                    },
                };
            }
            else
            {
                rq.EmployeeRequestMgm.RequestItems.GlobalTimeOffRequestItem.Comments = null;
            }

            return(rq.XmlSerialize <TimeOffAddRequest.Request>());
        }