/// <summary>
 /// Adds the work categories.
 /// </summary>
 /// <param name="timesheetParams">The timesheet parameters.</param>
 /// <param name="itemIdToInclude">The item identifier to include.</param>
 /// <param name="isInactiveOnly">if set to <c>true</c> [is inactive only].</param>
 /// <param name="userId">The user unique identifier.</param>
 private void AddWorkCategories(TimesheetParameters timesheetParams, string itemIdToInclude, bool isInactiveOnly, string userId)
 {
     int? itemToIncludeTemp = string.IsNullOrEmpty(itemIdToInclude) ? (int?)null : Convert.ToInt32(itemIdToInclude, CultureInfo.CurrentCulture);
     var workCategories = this.lookupService.RetrieveWorkCategories(itemToIncludeTemp, isInactiveOnly, Convert.ToInt32(userId, CultureInfo.CurrentCulture));
     if (workCategories != null)
     {
         workCategories.Sort();
         foreach (LookupItem item in workCategories)
         {
             timesheetParams.WorkCategories.Add(new TypeInfo { Id = item.ID, Name = item.Name });
         }
     }
 }
 /// <summary>
 /// Adds the work categories.
 /// </summary>
 /// <param name="timesheetParams">The timesheet parameters.</param>
 /// <param name="isInactiveOnly">if set to <c>true</c> [is inactive only].</param>
 /// <param name="userId">The user unique identifier.</param>
 private void AddWorkCategories(TimesheetParameters timesheetParams, bool isInactiveOnly, string userId)
 {
     var workCategories = this.lookupService.RetrieveWorkCategories(null, isInactiveOnly, Convert.ToInt32(userId, CultureInfo.CurrentCulture));
     if (workCategories != null)
     {
         workCategories.Sort();
         foreach (LookupItem item in workCategories)
         {
             timesheetParams.WorkCategories.Add(new TypeInfo { Id = item.ID, Name = item.Name });
         }
     }
 }
 /// <summary>
 /// Adds the project list.
 /// </summary>
 /// <param name="timesheetParams">The timesheet parameters.</param>
 /// <param name="developerId">The developer identifier.</param>
 /// <param name="itemIdToInclude">The item identifier to include.</param>
 /// <param name="inactiveOnly">if set to <c>true</c> [inactive only].</param>
 /// <param name="isNonProjectOnly">The is non project only.</param>
 private void AddProjectList(TimesheetParameters timesheetParams, string developerId, string itemIdToInclude, bool inactiveOnly, string isNonProjectOnly)
 {
     int? itemToIncludeTemp = string.IsNullOrEmpty(itemIdToInclude) ? (int?)null : Convert.ToInt32(itemIdToInclude, CultureInfo.CurrentCulture);
     bool? isNonProjectOnlyTemp = string.IsNullOrEmpty(isNonProjectOnly) ? (bool?)null : Convert.ToBoolean(isNonProjectOnly, CultureInfo.CurrentCulture);
     var projects = this.lookupService.RetrieveProjects(null, itemToIncludeTemp, inactiveOnly, isNonProjectOnlyTemp, Convert.ToInt32(developerId, CultureInfo.CurrentCulture));
     this.timesheetService.OrderClientsAndProjects(null, projects, Convert.ToInt32(developerId, CultureInfo.CurrentCulture), DateTime.Now);
     if (projects != null)
     {
         projects = projects.Sort();
         foreach (ProjectFillItem project in projects)
         {
             timesheetParams.ProjectList.Add(new ProjectDetail { Id = project.ProjectID, Name = project.ProjectFullName, ClientId = project.ClientID, ClientName = project.ClientName });
         }
     }
 }
 /// <summary>
 /// Adds the project list.
 /// </summary>
 /// <param name="timesheetParams">The timesheet parameters.</param>
 /// <param name="developerId">The developer identifier.</param>
 /// <param name="inactiveOnly">if set to <c>true</c> [inactive only].</param>
 private void AddProjectList(TimesheetParameters timesheetParams, string developerId, bool inactiveOnly)
 {
     var projects = this.lookupService.RetrieveProjects(null, null, inactiveOnly, null, Convert.ToInt32(developerId, CultureInfo.CurrentCulture));
     this.timesheetService.OrderClientsAndProjects(null, projects, Convert.ToInt32(developerId, CultureInfo.CurrentCulture), DateTime.Now);
     if (projects != null)
     {
         projects = projects.Sort();
         foreach (ProjectFillItem project in projects)
         {
             timesheetParams.ProjectList.Add(new ProjectDetail { Id = project.ProjectID, Name = project.ProjectFullName, ClientId = project.ClientID, ClientName = project.ClientName });
         }
     }
 }
        public HttpResponseMessage RetrieveTimesheetParameters(string developerId, string itemIdToInclude, string inactiveOnly, string isNonProjectOnly)
        {
            TimesheetParameters timesheetParams = new TimesheetParameters();
            var isInactiveOnlyTemp = !string.IsNullOrEmpty(inactiveOnly) ? Convert.ToBoolean(inactiveOnly, CultureInfo.CurrentCulture) : false;
            var developerIdTemp = !string.IsNullOrEmpty(developerId) ? Convert.ToInt32(developerId, CultureInfo.CurrentCulture) : -1;
            this.AddProjectList(timesheetParams, developerId, itemIdToInclude, isInactiveOnlyTemp, isNonProjectOnly);
            this.AddWorkCategories(timesheetParams, itemIdToInclude, isInactiveOnlyTemp, developerId);
            var lastTaskDetails = this.timesheetService.RetrieveLastEntry(developerIdTemp);
            if (lastTaskDetails != null)
            {
                timesheetParams.LastTaskDetail = new TaskDetail { ProjectId = lastTaskDetails.ProjectID, FeatureId = lastTaskDetails.FeatureID, CategoryId = lastTaskDetails.CategoryID };
            }

            return Request.CreateResponse(HttpStatusCode.OK, timesheetParams);
        }
        public HttpResponseMessage RetrieveTimesheetParameters(string developerId, bool lastTaskDetailOnly)
        {
            TimesheetParameters timesheetParams = new TimesheetParameters();
            var developerIdTemp = !string.IsNullOrEmpty(developerId) ? Convert.ToInt32(developerId, CultureInfo.CurrentCulture) : -1;
            if (!Convert.ToBoolean(lastTaskDetailOnly, CultureInfo.InvariantCulture))
            {
                ////this.AddClientList(timesheetParams, isInactiveOnlyTemp, developerId);
                this.AddProjectList(timesheetParams, developerId, false);
                this.AddWorkCategories(timesheetParams, false, developerId);
            }

            var lastTaskDetails = this.timesheetService.RetrieveLastEntry(developerIdTemp);
            var applicableDate = this.timesheetService.RetrieveApplicableDate(true, DateTime.Now, Convert.ToInt32(developerId, CultureInfo.CurrentCulture));
            if (lastTaskDetails != null)
            {
                timesheetParams.LastTaskDetail = new TaskDetail { ProjectId = lastTaskDetails.ProjectID, FeatureId = lastTaskDetails.FeatureID, CategoryId = lastTaskDetails.CategoryID, Date = applicableDate };
            }

            return Request.CreateResponse(HttpStatusCode.OK, timesheetParams);
        }