public static DateTimeBoundary <bool> GetFeature(this IEnumerable <AdditionalInfo> items) { !0 valueOrDefault; AdditionalInfo result = items.GetInfosByClass(AdditionalInfoClass.Feature).FirstOrDefault <AdditionalInfo>(); DateTimeBoundary <bool> feature = new DateTimeBoundary <bool>(); if (result != null) { feature.Id = result.Id; feature.StartDate = result.StartDate; feature.EndDate = result.EndDate; DateTimeBoundary <bool> dateTimeBoundary = feature; DateTime now = DateTime.Now; DateTime?startDate = result.StartDate; if ((startDate.HasValue ? now < startDate.GetValueOrDefault() : true)) { valueOrDefault = 0; } else { now = DateTime.Now; startDate = result.EndDate; if (startDate.HasValue) { valueOrDefault = now <= startDate.GetValueOrDefault(); } else { valueOrDefault = 0; } } dateTimeBoundary.Status = valueOrDefault; } return(feature); }
public static DateTimeBoundary <bool> GetFeature(this IEnumerable <AdditionalInfo> items) { AdditionalInfo result = items.GetInfosByClass(AdditionalInfoClass.Feature).FirstOrDefault(); DateTimeBoundary <bool> feature = new DateTimeBoundary <bool>(); if (result != null) { feature.Id = result.Id; feature.StartDate = result.StartDate; feature.EndDate = result.EndDate; DateTime now = DateTime.Now; DateTime?startDate = result.StartDate; int status; if (now >= startDate) { now = DateTime.Now; startDate = result.EndDate; status = ((now <= startDate) ? 1 : 0); } else { status = 0; } feature.Status = (byte)status != 0; } return(feature); }
public static DateTimeBoundary GetShowcase(this IEnumerable <AdditionalInfo> items) { AdditionalInfo result = items.GetInfosByClass(AdditionalInfoClass.Showcase).FirstOrDefault <AdditionalInfo>(); DateTimeBoundary showcase = new DateTimeBoundary(); if (result != null) { showcase.Id = result.Id; showcase.StartDate = result.StartDate; showcase.EndDate = result.EndDate; } return(showcase); }
public static DateTimeBoundary <PublishingStatus> GetPublishing(this IEnumerable <AdditionalInfo> items) { AdditionalInfo result = items.GetInfosByClass(AdditionalInfoClass.Publish).FirstOrDefault <AdditionalInfo>(); DateTimeBoundary <PublishingStatus> publishing = new DateTimeBoundary <PublishingStatus>(); if (result != null && result.AdditionalInfoTypeId.HasValue) { publishing.Status = result.AdditionalInfoTypeId.Value; publishing.StartDate = result.StartDate; publishing.EndDate = result.EndDate; } return(publishing); }
protected override void CommandBody(SqlCommand command) { PackageType packageType; DateTime? nullable; DateTime? item; DateTime? item1; DateTime? nullable1; DateTime? item2; command.CommandText = base.StoredProcedureName; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@PageNumber", SqlDbType.Int).Value = this._pageNumber; command.Parameters.Add("@PageSize", SqlDbType.Int).Value = this._pageSize; command.Parameters.Add("@SortBy", SqlDbType.NVarChar).Value = this._sortBy.ValueOrDBNull <CommunityGridSortByOption?>(); command.Parameters.Add("@SortOrder", SqlDbType.NVarChar).Value = this._orderBy.ValueOrDBNull <OrderBy?>(); command.Parameters.Add("@CommunityName", SqlDbType.VarChar).Value = this._filter.Community.ValueOrDBNull <string>(); command.Parameters.Add("@HasAdultApartments", SqlDbType.Bit).Value = this._filter.AAC.ValueOrDBNull <bool?>(); command.Parameters.Add("@ShowcaseStartDate", SqlDbType.Date).Value = this._filter.ShowcaseStart.ValueOrDBNull <string>(); command.Parameters.Add("@ShowcaseEndDate", SqlDbType.Date).Value = this._filter.ShowcaseEnd.ValueOrDBNull <string>(); command.Parameters.Add("@PublishStartDate", SqlDbType.Date).Value = this._filter.PublishStart.ValueOrDBNull <string>(); command.Parameters.Add("@PublishEndDate", SqlDbType.Date).Value = this._filter.PublishEnd.ValueOrDBNull <string>(); command.Parameters.Add("@HasAdultHomes", SqlDbType.Bit).Value = this._filter.AAH.ValueOrDBNull <bool?>(); command.Parameters.Add("@HasSeniorHousing", SqlDbType.Bit).Value = this._filter.SHC.ValueOrDBNull <bool?>(); command.Parameters.Add("@IsShowcase", SqlDbType.Bit).Value = this._filter.Showcase.ValueOrDBNull <bool?>(); command.Parameters.Add("@IsPublish", SqlDbType.Bit).Value = this._filter.Publish.ValueOrDBNull <bool?>(); command.Parameters.Add("@CategoriesTable", SqlDbType.Structured).Value = this._filter.Categories.GetAdditionalInfoTable(); command.Parameters.Add("@PackagesTable", SqlDbType.Structured).Value = this._filter.Packages.GetAdditionalInfoTable(); command.Parameters.Add("@TotalCount", SqlDbType.Int).Direction = ParameterDirection.Output; command.Parameters.Add("@BookTable", SqlDbType.Structured).Value = this._books.GetBookTable(); SqlDataReader dr = command.ExecuteReader(); this._result = new List <Community>(); while (dr.Read()) { Community community = new Community() { Id = new long?(Convert.ToInt64(dr["CommunityId"])), Name = Convert.ToString(dr["Name"]) }; string bookNumber = dr.GetValue <string>("BookNumber"); community.Book = new Book() { Number = bookNumber }; Enum.TryParse <PackageType>(Convert.ToString(dr["Package"]), out packageType); community.Package = new PackageType?(((int)packageType == 0 ? PackageType.Basic : packageType)); community.ListingTypes = new List <ListingType>(); int hasAdultApartments = dr.GetOrdinal("HasAdultApartments"); int hasAdultHomes = dr.GetOrdinal("HasAdultHomes"); int hasSeniorHousing = dr.GetOrdinal("HasSeniorHousing"); if (!dr.IsDBNull(hasAdultApartments) && (bool)dr["HasAdultApartments"]) { community.ListingTypes.Add(ListingType.ActiveAdultCommunities); } if (!dr.IsDBNull(hasAdultHomes) && (bool)dr["HasAdultHomes"]) { community.ListingTypes.Add(ListingType.ActiveAdultHomes); } community.SeniorHousingAndCareCategoryIds = new List <long>(); if (!dr.IsDBNull(hasSeniorHousing) && (bool)dr["HasSeniorHousing"]) { community.ListingTypes.Add(ListingType.SeniorHousingAndCare); string[] shacCategoriesIds = dr["SHCSubcategories"].ToString().Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); community.SeniorHousingAndCareCategoryIds = ( from strId in shacCategoriesIds select Convert.ToInt64(strId)).ToList <long>(); } int showcaseStart = dr.GetOrdinal("ShowcaseStart"); int showcaseEnd = dr.GetOrdinal("ShowcaseEnd"); int publishStart = dr.GetOrdinal("PublishStart"); int publishEnd = dr.GetOrdinal("PublishEnd"); DateTimeBoundary showcase = community.Showcase; if (!dr.IsDBNull(showcaseStart)) { item = (DateTime?)dr["ShowcaseStart"]; } else { nullable = null; item = nullable; } showcase.StartDate = item; DateTimeBoundary dateTimeBoundary = community.Showcase; if (!dr.IsDBNull(showcaseEnd)) { item1 = (DateTime?)dr["ShowcaseEnd"]; } else { nullable = null; item1 = nullable; } dateTimeBoundary.EndDate = item1; DateTimeBoundary <PublishingStatus> publishing = community.Publishing; if (!dr.IsDBNull(publishStart)) { nullable1 = (DateTime?)dr["PublishStart"]; } else { nullable = null; nullable1 = nullable; } publishing.StartDate = nullable1; DateTimeBoundary <PublishingStatus> publishing1 = community.Publishing; if (!dr.IsDBNull(publishEnd)) { item2 = (DateTime?)dr["PublishEnd"]; } else { nullable = null; item2 = nullable; } publishing1.EndDate = item2; this._result.Add(community); } }
protected override void CommandBody(SqlCommand command) { long?nullable; command.CommandText = base.StoredProcedureName; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@ServiceId", SqlDbType.BigInt).Value = this._id; SqlDataReader reader = command.ExecuteReader(); this._serviceProvider.Book = new Book(); if (reader.Read()) { this._serviceProvider.Name = reader["Name"].ToString(); Book book = this._serviceProvider.Book; int? nullableValue = reader.GetNullableValue <int>("BookId"); if (nullableValue.HasValue) { nullable = new long?((long)nullableValue.GetValueOrDefault()); } else { nullable = null; } book.Id = nullable; this._serviceProvider.Description = reader["Description"].ToString(); this._serviceProvider.WebsiteUrl = reader["WebsiteURL"].ToString(); this._serviceProvider.DisplayWebsiteUrl = reader.GetNullableValue <bool>("IsDisplayWebsiteUrl").FromNullable(); this._serviceProvider.DisplayAddress = reader.GetNullableValue <bool>("IsDisplayAddress").FromNullable(); this._serviceProvider.MarchexAccountId = reader.GetValue <string>("MARCHEX_AccountId"); this._serviceProvider.UserId = reader.GetNullableValue <Guid>("ModifyUserId"); } if (reader.NextResult()) { this._serviceProvider.Address = reader.GetAddress(); } if (reader.NextResult()) { this._serviceProvider.Phones = reader.GetPhones().Item1; } if (reader.NextResult()) { this._serviceProvider.Emails = reader.GetEmails(); } if (reader.NextResult()) { this._serviceProvider.Contacts = reader.GetContacts(); } if (reader.NextResult()) { this._serviceProvider.OfficeHours = reader.GetOfficeHours(); } if (reader.NextResult()) { this._serviceProvider.Images = reader.GetImages(); } if (reader.NextResult()) { this._serviceProvider.CallTrackingPhones = reader.GetPhones().Item2; } if (reader.NextResult()) { List <AdditionalInfo> infos = reader.GetAdditionalInfo(); this._serviceProvider.PaymentTypeIds = infos.GetServicePaymentTypes(); this._serviceProvider.ServiceCategories = infos.GetServiceCategories(); this._serviceProvider.Package = new PackageType?(infos.GetServicePackage()); DateTimeBoundary <bool> feature = infos.GetFeature(); this._serviceProvider.FeatureEndDate = feature.EndDate; this._serviceProvider.FeatureStartDate = feature.StartDate; DateTimeBoundary <PublishingStatus> publish = infos.GetPublishing(); this._serviceProvider.PublishEndDate = publish.EndDate; this._serviceProvider.PublishStartDate = publish.StartDate; this._serviceProvider.Coupon = infos.GetCoupon(); } }