private static void DirectApiImport() { var context = new SpecialistWebDataContext(); var result = DirectApiService.GetActiveCompaignIDs(); for (int j = 0; j < 3; j++) { //WL(DirectApiProxy.GetBannerPhrases(new [] {1297662})); var compaigns = result.Skip(10 * j).Take(10).ToList(); // WL(compaigns); var bannerIds = DirectApiService.GetBanners(new { CampaignIDS = compaigns, Filter = new { IsActive = new[] { "Yes" } } }).AsJEnumerable().Select(x => x.Value <int>("BannerID")) .Distinct() .ToList(); //WL(banners); var phraseList = DirectApiService.GetBannerPhrasesFilter(bannerIds).AsJEnumerable(); var phrases = phraseList .Select(x => new YdBannerPhrase { PhraseID = x["PhraseID"].Value <int>(), CampaignID = x["CampaignID"].Value <int>(), Phrase = x["Phrase"].Value <string>(), CurrentOnSearch = x["CurrentOnSearch"].Value <double>(), BannerID = x["BannerID"].Value <int>() }); var final = phrases.Where(x => DirectApiService.Phrases.Contains(x.Phrase)).ToList(); context.YdBannerPhrases.InsertAllOnSubmit(final); } context.SubmitChanges(); }
public IQueryable <UserWork> GetAllRandomForBlock() { var context = new SpecialistWebDataContext(); return(context.UserWorks.IsActive() .Where(x => x.SmallImage != null) .OrderBy(x => context.GetNewID())); }
public Dictionary <string, PageMeta> GetAllPageMetas() { return(CacheUtils.Get(MethodBase.GetCurrentMethod(), () => { using (var context = new SpecialistWebDataContext()) { return context.PageMetas.ToDictionary(x => x.Url.ToLower(), x => x); } })); }
public SimplePageCommonVM(T data) { Data = data; var url = HttpContext.Current.Request.Url.AbsolutePath; var page = new SpecialistWebDataContext().SimplePages .Where(x => x.UrlName == url).Select(x => new { x.Title, x.Description }) .FirstOrDefault(); _page = page.GetOrDefault(x => Tuple.Create(x.Title, x.Description)) ?? new Tuple <string, string>("", ""); }
public static string TextBlock(int?pageId = null) { var context = new SpecialistWebDataContext(); var url = HttpContext.Current.Request.Url.AbsolutePath; var desc = (pageId.HasValue ? context.SimplePages.Where(x => x.SimplePageID == pageId) : context.SimplePages.Where(x => x.UrlName == url)). Select(x => x.Description).FirstOrDefault(); return(desc); }
public CustomSection GetByUrlNames(string typeUrlName, string sectionUrlName) { var context = new SpecialistWebDataContext(); var customSections = from customSection in context.CustomSections where customSection.CustomSectionType.UrlName == typeUrlName && customSection.UrlName == sectionUrlName select customSection; return(customSections.FirstOrDefault()); }
private static void UpdateActiveByActualDate() { var context = new SpecialistWebDataContext(); var banners = context.Banners .Where(b => b.ActualDate < DateTime.Today && b.IsActive); foreach (var banner in banners) { banner.IsActive = false; } context.SubmitChanges(); }
public CustomSectionType GetByUrlName(string urlName) { var context = new SpecialistWebDataContext(); var loadOptions = new DataLoadOptions(); loadOptions.LoadWith <CustomSectionType>(cst => cst.CustomSections); context.LoadOptions = loadOptions; var sectionTypes = from sectionType in context.CustomSectionTypes where sectionType.UrlName == urlName select sectionType; return(sectionTypes.FirstOrDefault()); }
public static string SkypeTextBlock() { var context = new SpecialistWebDataContext(); var isIcqOnline = new TimeSpan(9, 30, 00) <= DateTime.Now.TimeOfDay && DateTime.Now.TimeOfDay <= new TimeSpan(18, 00, 00) && !DateTime.Now.DayOfWeek.In(DayOfWeek.Saturday, DayOfWeek.Sunday); var icqIcon = Images.Main(isIcqOnline ? "ico_icq.png" : "icq_offline.gif"); var skypeIcon = Images.Main(isIcqOnline ? "skype_online.png" : "skype_offline.png"); var desc = context.SimplePages.Where(x => x.SysName == SimplePages.Skype). Select(x => x.Description).FirstOrDefault(); return(TemplateEngine.GetText(desc, new { icqIcon, skypeIcon })); }
// private byte? GetCompetitionDiscount(OrderDetail orderDetail) { // var competition = CompetitionService.GetAll() // .FirstOrDefault(c => c.WinnerID == orderDetail.Order.UserID && // c.Course_TC == orderDetail.Course_TC && c.Discount != null); // return competition == null ? null : competition.Discount; // } public Discount GetPromocodeDiscount(OrderDetail orderDetail) { try { var promoCode = orderDetail.Order.PromoCode; if (promoCode.IsEmpty() || orderDetail.Order.User.GetOrDefault(x => x.IsCompany)) { return(null); } var discount = new SpecialistWebDataContext().uspCheckPromoCode(promoCode, orderDetail.Course_TC).FirstOrDefault(); if (discount == null || discount.Column1 <= 0) { return(null); } return(new Discount { Discount_ID = Discounts.PromocodeId, PercentValue = (byte?)discount.Column1 }); } catch (Exception ex) { Logger.Exception(ex, "promocode discount"); return(null); } }
private List <string> GetUrls(UrlHelper urlHelper) { var root = RootUrl; var context = new SpecialistDataContext(); var webcontext = new SpecialistWebDataContext(); var urls = new List <string>(); urls.AddRange( context.Courses.IsActive().Where(x => x.UrlName != null).Where(x => x.IsTrack != true) .OrderByDescending(c => c.Course_ID).Select(x => x.UrlName).ToList() .Select(x => root + urlHelper.Action <CourseController>(c => c.Details(x))) ); urls.AddRange( webcontext.News.IsActive().OrderByDescending(n => n.PublishDate).Take(50) .Select(x => new { x.NewsID, x.Title }).ToList() .Select(x => root + urlHelper .Action <SiteNewsController>(c => c.Details(x.NewsID , Linguistics.UrlTranslite(x.Title)))) ); urls.AddRange( webcontext.Sections.IsActive().Select(x => x.UrlName).ToList() .Select(x => root + urlHelper.Action <SectionController>(c => c.Details(x))) ); if (!CommonConst.IsMobile) { urls.AddRange( context.Vendors.IsActive().Select(x => x.UrlName).ToList() .Select(x => root + SimplePages.FullUrls.Vendor + x) ); urls.AddRange( context.Professions.IsActive().Select(x => x.UrlName).ToList() .Select(x => root + urlHelper.Action <ProfessionController>(c => c.Details(x))) ); urls.AddRange( webcontext.Products.IsActive().Select(x => x.UrlName + UrlName.ProductPostfix).ToList() .Select(x => root + urlHelper.Action <ProductController>(c => c.Details(x))) ); urls.AddRange( webcontext.SiteTerms.IsActive().Select(x => x.UrlName).ToList() .Select(x => root + urlHelper.Action <DictionaryController>(c => c.Definition(x))) ); urls.AddRange( webcontext.SimplePages.ToList().Select(x => x.Url) .Select(x => root + x) ); urls.AddRange( context.Certifications.IsActive().Select(x => x.UrlName).ToList() .Select(x => root + urlHelper.Action <CertificationController>( c => c.Details(x))) ); urls.AddRange( context.Exams.Where(x => x.Available).Select(x => x.Exam_TC).ToList() .Select(x => root + urlHelper.Action <ExamController>(c => c.Details(x))) ); } return(urls); }
public string Get() { var context = new SpecialistDataContext(); var groups = context.Groups.PlannedAndNotBegin() .Where(g => g.DateBeg > new DateTime(2011, 1, 1)) .Select(g => new { g.Course_TC, Date = g.DateBeg.Value, g.Course.Name }).ToList(); var orgs = _.List(PriceTypes.Corporate, PriceTypes.CorporateBusinessClass); var prices = context.PriceViews.Where(x => orgs.Contains(x.PriceType_TC) && x.Track_TC == null).Select(x => new { x.Course_TC, x.PriceType_TC, x.Price }).ToList(); var courses = prices.Select(x => x.Course_TC).Distinct(); Func <string, string, string> getPrice = (courseTC, priceTypeTC) => prices.FirstOrDefault(p => p.Course_TC == courseTC && p.PriceType_TC == priceTypeTC).GetOrDefault(x => (decimal?)x.Price) .NotNullString("n0"); groups = (from g in groups group g by new { g.Course_TC, Week = GetWeekNumber(g.Date) } into gr select gr.First()).ToList(); groups = groups.Where(g => courses.Contains(g.Course_TC)).ToList(); var resultGroups = groups.GroupBy(x => x.Course_TC) .Select(x => new { Course_TC = x.Key, x.First().Name, Dates = x.OrderBy(z => z.Date).Select(z => z.Date.ToString("dd.MM")).JoinWith(" ") }) .ToList(); var webcontext = new SpecialistWebDataContext(); var rootSections = webcontext.Sections.Where(s => s.IsMain) .ByWebOrder().IsActive().ToList(); var unity = new UnityContainer(); UnityRegistrator.RegisterServices(unity); var courseService = unity.Resolve <ICourseService>(); var sectionWithCourses = rootSections.Select(s => new { Section = s, CourseTCs = courseService.GetCourseTCListForSections( _.List(s.Section_ID)) }); /*var allSectionCourses = sectionWithCourses * .SelectMany(x => x.CourseTCs).Distinct().ToList(); * var notInList = resultGroups.Where(g => !allSectionCourses.Contains(g.Course_TC)).ToList();*/ var groupBySections = sectionWithCourses.Select(s => Grouping.New(s.Section, resultGroups.Where(c => s.CourseTCs.Contains(c.Course_TC)))) .Where(s => s.Any()).ToList(); return(table[tr[ th["Название курса"], th["Цена ОРГ"], th["Цена ОРГБ"], th["Расписание"]], groupBySections.Select(s => H.l(tr[td[s.Key.Name].Colspan(4)], s.OrderBy(x => x.Name).Select(g => tr[td[g.Name], td[getPrice(g.Course_TC, PriceTypes.Corporate)], td[getPrice(g.Course_TC, PriceTypes.CorporateBusinessClass)], td[g.Dates]])))].ToString()); }