private Comment FillComment(SqlDataReader reader) { var comment = new Comment(); comment.Id = reader.GetInt32(0); comment.PostId = reader.GetInt32(1); comment.Name = reader.GetString(2); comment.Email = reader.GetValueOrDefault<string>(3); comment.Url = reader.GetValueOrDefault<string>(4); comment.Body = reader.GetString(5); comment.Status = (CommentStatus)reader.GetInt32(6); comment.DateCreated = reader.GetDateTime(7); return comment; }
private Post FillPost(SqlDataReader reader) { var post = new Post(); post.Id = reader.GetInt32(0); post.Author = new Author(); post.Author.Id = reader.GetInt32(1); post.Title = reader.GetValueOrDefault<string>(2); post.Body = reader.GetValueOrDefault<string>(3); post.IsPublished = reader.GetBoolean(4); post.DateCreated = reader.GetDateTime(5); return post; }
private static ScheduleItemList ConvertReaderDataToScheduleItemList(SqlDataReader reader) { ScheduleItemList schedules = null; if (reader.HasRows) { schedules = new ScheduleItemList(); while (reader.Read()) { schedules.Add(new ScheduleItem(reader.GetValueOrDefault<int>("ID"), reader.GetValueOrDefault<int>("ProjectID"), reader.GetValueOrDefault<int>("EmployeeID"), reader.GetValueOrDefault<int>("WeekID"), reader.GetValueOrDefault<decimal>("Hours"))); } } return schedules; }
private static ProjectList ConvertReaderDataToProjectList(SqlDataReader reader) { ProjectList projects = null; if (reader.HasRows) { projects = new ProjectList(); while (reader.Read()) { var project = new Project(); project.Id = reader.GetValueOrDefault<int>("ID"); project.ProjectNumber = reader.GetValueOrDefault<decimal>("ProjectNo"); project.Name = reader.GetValueOrDefault<string>("ProjectName"); project.ClientId = reader.GetValueOrDefault<int>("ClientID"); project.StatusId = reader.GetValueOrDefault<int>("ProjectStatus"); project.Location = reader.GetValueOrDefault<string>("ProjectLocation"); project.ConstructionType = reader.GetValueOrDefault<string>("ConstructionType"); project.ProjectType = reader.GetValueOrDefault<string>("ProjectType"); project.PhaseId = reader.GetValueOrDefault<int>("PhaseID"); project.EstimatedStartDate = reader.GetValueOrDefault<DateTime>("EstimatedStartDate"); project.EstimatedCompletionDate = reader.GetValueOrDefault<DateTime>("EstimatedCompletionDate"); project.FeeAmount = reader.GetValueOrDefault<decimal>("FeeAmount"); project.FeeStructure = reader.GetValueOrDefault<string>("FeeStructure"); project.ContractTypeId = reader.GetValueOrDefault<int>("ContractType"); project.PICId = reader.GetValueOrDefault<int>("PIC"); project.PM1Id = reader.GetValueOrDefault<int>("PM1"); project.PM2Id = reader.GetValueOrDefault<int>("PM2"); project.LastModifiedByUserId = reader.GetValueOrDefault<int>("LastModifiedByUserID"); project.PICCode = reader.GetValueOrDefault<string>("PICCode"); project.PM1Code = reader.GetValueOrDefault<string>("PM1Code"); project.PM2Code = reader.GetValueOrDefault<string>("PM2Code"); project.Comments = reader.GetValueOrDefault<string>("Comments"); project.IsActive = reader.GetValueOrDefault<bool>("Active"); project.LastModifiedDate = reader.GetValueOrDefault<DateTime>("LastModifiedDate"); projects.Add(project); } } return projects; }
private static List<Employee> ConvertReaderDataToProjectList(SqlDataReader reader) { List<Employee> employees = null; if (reader.HasRows) { employees = new List<Employee>(); while (reader.Read()) { var employee = new Employee(); employee.Id = reader.GetValueOrDefault<int>("EmployeeID"); employee.FirstName = reader.GetValueOrDefault<string>("EmployeeFirst"); employee.LastName = reader.GetValueOrDefault<string>("EmployeeLast"); employee.Name = reader.GetValueOrDefault<string>("EmployeeName"); employee.Title = reader.GetValueOrDefault<string>("Title"); employee.StartDate = reader.GetValueOrDefault<DateTime>("EmploymentStartDate"); int yearsOfExperience = 0; int.TryParse(reader.GetValueOrDefault<string>("YearsOfExperience"), out yearsOfExperience); employee.YearsOfExperience = yearsOfExperience; employee.Education = reader.GetValueOrDefault<string>("Education"); employee.Licenses = reader.GetValueOrDefault<string>("Licenses"); employee.ProfessionalMemberships = reader.GetValueOrDefault<string>("ProfessionalMemberships"); employee.ProfessionalCommittees = reader.GetValueOrDefault<string>("ProfessionalCommittees"); employee.Comments = reader.GetValueOrDefault<string>("Comments"); employee.HoursPerWeek = reader.GetValueOrDefault<decimal>("HoursPerWeek"); employee.PhoneExtension = reader.GetValueOrDefault<int>("PhoneExtension"); employee.EmailAddress = reader.GetValueOrDefault<string>("EmailAddress"); employee.HasPMFiscalSummaryAddress = reader.GetValueOrDefault<bool>("PMFiscalSummary"); employee.HasPICFiscalSummaryAddress = reader.GetValueOrDefault<bool>("PICFiscalSummary"); employee.LastModifiedDate = reader.GetValueOrDefault<DateTime>("LastModified"); employee.LastModifiedBy = reader.GetValueOrDefault<string>("LastModifiedBy"); employees.Add(employee); } } return employees; }