/// <summary>
        /// Function to retrieve index page.
        /// </summary>
        /// <returns>Index page</returns>
        public ActionResult Index()
        {
            this.AddBreadcrumbItem(Resources.Timesheet, Url.TimesheetAction());
            var model = new TimesheetPresenter();
            model.WorkDetail = new WorkDetail();
            model.WorkDetail.Project = new Project();
            model.WorkDetail.Date = this.timesheetService.RetrieveApplicableDate(true, DateTimeHelper.RetrieveCurrentDateTime(), SessionData.Instance.UserInfo.Developer.DeveloperID);

            var clients = this.lookupService.RetrieveClients(null, false, SessionData.Instance.UserInfo.Developer.DeveloperID);
            var projects = this.lookupService.RetrieveProjects(null, null, false, null, SessionData.Instance.UserInfo.Developer.DeveloperID);

            model.SortedListItem = this.timesheetService.OrderClientsAndProjects(clients, projects, SessionData.Instance.UserInfo.Developer.DeveloperID, model.WorkDetail.Date);

            model.AssignClients(clients.Sort());
            model.AssignParentProjects(projects.Sort());
            model.Projects.ForEach(p => { p.ProjectName = p.ProjectFullName; });

            model.AssignWorkCategories(this.lookupService.RetrieveWorkCategories(null, false, SessionData.Instance.UserInfo.Developer.DeveloperID));
            model.AssignWorkDetailList(this.timesheetService.RetrieveList(model.WorkDetail.Date, SessionData.Instance.UserInfo.Developer.DeveloperID, SessionData.Instance.UserInfo.Developer.DeveloperID));
            model.TotalTaskHour = model.WorkDetails.Sum(w => w.Hours);
            model.LastWorkDetail = this.timesheetService.RetrieveLastEntry(SessionData.Instance.UserInfo.Developer.DeveloperID);
            return this.View(model);
        }
        /// <summary>
        /// Retrieves the work detail list.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="selectedDate">The selected date.</param>
        /// <returns>work detail list</returns>
        public ActionResult WorkDetails(TimesheetPresenter presenter, string selectedDate)
        {
            if (presenter != null)
            {
                if (SessionData.Instance.UserInfo != null && SessionData.Instance.UserInfo.Developer != null)
                {
                    presenter.AssignWorkDetailList(this.timesheetService.RetrieveList(Convert.ToDateTime(selectedDate, CultureInfo.CurrentCulture), SessionData.Instance.UserInfo.Developer.DeveloperID, SessionData.Instance.UserInfo.Developer.DeveloperID));
                    presenter.TotalTaskHour = presenter.WorkDetails.Sum(w => w.Hours);
                }
            }

            return this.PartialView(WorkDetailsPartialView, presenter);
        }
        /// <summary>
        /// Inserts the or update.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="workDetailId">The work detail identifier.</param>
        /// <returns>work detail</returns>
        public ActionResult InsertOrUpdate(TimesheetPresenter presenter, string workDetailId)
        {
            if (presenter != null && presenter.WorkDetail != null)
            {
                if (SessionData.Instance.UserInfo != null && SessionData.Instance.UserInfo.Developer != null)
                {
                    presenter.WorkDetail.DeveloperID = SessionData.Instance.UserInfo.Developer.DeveloperID;
                }

                if (presenter.WorkDetail.FeatureID == DefaultId)
                {
                    presenter.WorkDetail.FeatureID = null;
                }

                presenter.WorkDetail.WorkDetailID = Convert.ToInt32(workDetailId, CultureInfo.CurrentCulture);
                presenter.AssignWorkDetailList(this.timesheetService.RetrieveList(Convert.ToDateTime(presenter.WorkDetail.Date, CultureInfo.CurrentCulture), SessionData.Instance.UserInfo.Developer.DeveloperID, SessionData.Instance.UserInfo.Developer.DeveloperID));
                presenter.TotalTaskHour = presenter.WorkDetails.Sum(w => w.Hours);
                presenter.TotalTaskHour = presenter.TotalTaskHour + presenter.WorkDetail.HoursReported;
                if (presenter.TotalTaskHour <= 24)
                {
                    this.timesheetService.InsertOrUpdate(presenter.WorkDetail, ApplicationType.Website);
                    return this.Json(presenter);
                }
            }

            return this.Json(presenter);
        }