private static void ComplexGeoLocations() { var files = Directory.GetFiles("complex"); var result = string.Empty; var complexes = new SpecialistDataContext().Complexes.Select(x => new { x.Complex_TC, x.UrlName }).ToList(); foreach (var path in files) { var text = File.ReadAllText(path); var patterns = _.List(@"YMaps\.Placemark\(new YMaps\.GeoPoint", @"""Placemark"", new YMaps\.GeoPoint"); var urlName = Path.GetFileNameWithoutExtension(path); var complexTC = complexes.First(x => x.UrlName == urlName).Complex_TC; foreach (var pattern in patterns) { var groups = Regex.Matches(text, pattern + @"\((.*?)\)"); if (groups.Count > 0) { result += "{{\"{0}\",\"{1}\"}}" .FormatWith(complexTC, groups[0].Groups[1].Value.Replace(" ", "")) + Environment.NewLine; break; } } } WL(result); }
public List <Advice> GetRandomAdvices() { var context = new SpecialistDataContext(); return(context.GetTable <Advice>().IsActive() .OrderBy(x => context.GetNewID()).Take(CommonConst.AdviceCount).ToList()); }
static void TestConnection() { var context = new SpecialistDataContext( "data source=195.19.32.198;initial catalog=SPECIALIST;user id=SpecWebDataEditor;password=ghjdbltw;MultipleActiveResultSets=True"); var course = context.Courses.First(); }
public virtual List <Course> AllCoursesForList() { var localContext = new SpecialistDataContext(); var loadOptions = new DataLoadOptions(); loadOptions.LoadWith <Course>(c => c.CourseLanguages); loadOptions.LoadWith <CourseLanguage>(c => c.Language); localContext.LoadOptions = loadOptions; var result = localContext.Courses.IsActive().Select(c => new { c.Course_ID, c.Course_TC, c.IsTrack, c.UrlName, c.WebName, c.IsNew, c.WebPublishSchedule, c.Name, c.WebShortName, c.CourseDirectionA_TC, c.BaseHours, c.AdditionalHours, c.IntraExtramuralHours, c.IntraExtramuralHoursOut, Languages = c.CourseLanguages.Select(x => x.Language_TC), TrackFirstCourseTC = c.TrackCourses.OrderBy(t => t.SortOrder) .Select(t => t.Course.Course_TC).FirstOrDefault() }).ToList().GroupBy(c => c.UrlName).Select(x => x.OrderBy(y => y.Course_ID).First()); return(result.Select(c => { var courseLanguages = new EntitySet <CourseLanguage>(); courseLanguages.AddRange(c.Languages.Select(ln => new CourseLanguage { Language = new Language { Language_TC = ln } })); return new Course { Course_ID = c.Course_ID, Course_TC = c.Course_TC, UrlName = c.UrlName, IsNew = c.IsNew, WebPublishSchedule = c.WebPublishSchedule, WebName = c.WebName, CourseDirectionA_TC = c.CourseDirectionA_TC, Name = c.Name, IsTrack = c.IsTrack, WebShortName = c.WebShortName, BaseHours = c.BaseHours, AdditionalHours = c.AdditionalHours, IntraExtramuralHours = c.IntraExtramuralHours, IntraExtramuralHoursOut = c.IntraExtramuralHoursOut, CourseLanguages = courseLanguages, TrackFirstCourseTC = c.TrackFirstCourseTC }; }).ToList()); }
public OrgResponse GetOrgRandomResponseForMainPage() { var context = new SpecialistDataContext(); return(context.GetTable <OrgResponse>().Where(x => x.ShortDescription != null) .OrderBy(x => context.GetNewID()).FirstOrDefault()); }
private static void CourseLinks2() { var courses = new SpecialistDataContext().Courses .Where(x => x.IsActive && x.UrlName != null && !x.IsTrack.GetValueOrDefault()) .Select(x => new { x.Course_TC, x.UrlName, x.Name }).ToList(); var files = Directory.GetFiles("links").ToList(); var result = new List <Tuple <string, string, string> >(); foreach (var file in files) { var lines = File.ReadAllLines(file).Skip(2).ToList(); if (lines.Count == 0) { continue; } var data = courses.FirstOrDefault(x => x.Course_TC == Path.GetFileName(file)); if (data == null) { continue; } var links = lines.Select(x => x.Split('\t')[1]) .Where(x => x.Contains("www.specialist.ru") && !x.Contains(".asp")) .Select(x => Regex.Replace(x, "\\?.*", "")).Distinct().JoinWith("<br/>"); result.Add(Tuple.Create( /*H.Anchor("http://www.specialist.ru/course/" + data.UrlName, data.Name).ToString()*/ data.Name, links, data.Course_TC)); } var text = table[result.Select(x => tr[td[x.Item3], td[x.Item1], td[x.Item2]])].ToString(); File.WriteAllText("courselinks.html", HtmlHead + text); }
public List <Response> GetRandomForWebinar() { var context = new SpecialistDataContext(); return(context.GetTable <Response>().IsActive() .Where(x => x.IsWebinar) .OrderBy(x => context.GetNewID()).Take(15).ToList()); }
public List <Response> GetRandomResponsesByCourse(string CourseTC, int rows) { var context = new SpecialistDataContext(); return(context.GetTable <Response>().IsActive() .Where(x => x.Type == RawQuestionnaireType.CourseComment).Where(r => r.Course_TC == CourseTC) .OrderBy(x => context.GetNewID()).Take(rows).ToList()); }
public static void GroupsWrite() { var context = new SpecialistDataContext(); var types = _.List("ÌÑ"); var courseNames = context.Courses.Where(c => types.Contains(c.AuthorizationType_TC) && c.Course_TC.StartsWith("Ì") && c.IsActive && c.IsTrack != true) .Select(x => new { x.Course_TC, x.Name, x.NameOfficialEn, x.UrlName }).ToList(); var courses = courseNames.Select(x => x.Course_TC); var prices = context.PriceViews.Where(x => x.Track_TC == null && courses.Contains(x.Course_TC)) .Select(x => new { x.PriceType_TC, x.Course_TC, x.PriceType.PriceListType_TC }).ToList(); var groups = context.Groups.Where(x => courses.Contains(x.Course_TC)).NotBegin() .Where(x => x.DateEnd != null) .Select(x => new { x.Course_TC, x.DateBeg, x.DateEnd, x.TimeBeg, x.TimeEnd }).OrderBy(x => x.DateBeg).ToList(); var distanceCourses = prices.Where(x => x.PriceType_TC == PriceTypes.Webinar) .Select(x => x.Course_TC).Distinct().ToList(); var fulltimeCourses = prices.Where(x => !PriceTypes.IsWebinar(x.PriceType_TC)) .Select(x => x.Course_TC).Distinct().ToList(); var data = groups.Select(k => { var courseTC = k.Course_TC.Trim(); var course = courseNames.First(z => z.Course_TC == courseTC); var priceTypes = new List <string>(); if (fulltimeCourses.Contains(courseTC)) { priceTypes.Add("Instructor-led"); } if (distanceCourses.Contains(courseTC)) { priceTypes.Add("Virtual Instructor-led"); } var culture = CultureInfo.CreateSpecificCulture("en-US"); return(_.List( "1050468", "516392", Regex.Replace(courseTC, @"[^\d]", ""), "", priceTypes.JoinWith(" and "), "Russian", // k.DateBeg.Value.ToString("MM\\/dd\\/yyyy"), // k.DateEnd.Value.ToString("MM\\/dd\\/yyyy"), k.DateBeg.Value.ToString("dd.MM.yyyy"), k.DateEnd.Value.ToString("dd.MM.yyyy"), k.TimeBeg.Value.ToString("h:mm tt", culture), k.TimeEnd.Value.ToString("h:mm tt", culture), "", "", "", "Moscow", "http://www.specialist.ru/course/" + course.UrlName.ToLower(), "", "Y" ) .JoinWith("\t")); }); File.WriteAllLines("result.txt", data); }
public SiteObjectService(IContextProvider contextProvider) { this.context = (SpecialistDataContext) contextProvider.Get(typeof(SiteObject)); if (context != null) { context.Log = new StringWriter(); } }
public static HashSet <DateTime> DayOffList() { return(MethodBase.GetCurrentMethod().CacheDay(() => { var start = DateTime.Today.AddYears(-3); var end = DateTime.Today.AddYears(3); var context = new SpecialistDataContext(); var workDays = _.List('В', 'П'); return new HashSet <DateTime>(context.GetTable <Calendar>().Where(x => x.DateValue >= start && x.DateValue <= end && workDays.Contains(x.WorkDay)) .Select(x => x.DateValue).ToList()); })); }
public void CreateDB() { var courseStudentData = new SpecialistDataContext().StudentInGroups .Select(x => new { x.Student_ID, x.Group.Course.ParentCourse_TC }).ToList(); var courseStudents = courseStudentData.Select(x => new CourseStudent { CourseTC = x.ParentCourse_TC, StudentId = x.Student_ID }); var context = new RecRepository().GetContext(); context.AddMany(courseStudents); }
public void CreateNames() { var courses = new SpecialistDataContext().Courses .Select(x => new { x.Course_TC, x.Name }).ToList(); var names = courses.Select(x => new CourseName() { CourseTC = x.Course_TC, Name = x.Name }); var context = new RecRepository().GetContext(); context.AddMany(names); }
// public List<EntityWithList<IEntityCommonInfo, IEntityCommonInfo>> GetMenuTree(object entity) { // var context = new SpecialistDataContext(); // var allForMenu = GetAllForMenu(); // var relations = allForMenu.GetValueOrDefault(Tuple.Create(entity.GetType(), // (int)LinqToSqlUtils.GetPK(entity))) ?? new List<SiteObjectRelation>(); // if(!relations.Any()) // return new List<EntityWithList<IEntityCommonInfo, IEntityCommonInfo>>(); // var tableNames = types.Select(x => SiteObject.TypeTableNames.GetValueOrDefault(x)) ; // var tree = relations.Where(x => tableNames.Contains(x.RelationObjectType)).Select(x => EntityWithList.New(x, // allForMenu.GetValueOrDefault(Tuple.Create(SiteObject.TableNameTypes[x.RelationObjectType], (int)x.RelationObject_ID)))); // var allrelations = tree.SelectMany(x => x.List.Concat(_.List(x.Entity))) // .ToList(); // var entityByType = new Dictionary<Type, Dictionary<object, IEntityCommonInfo>>(); // entityByType.Add(typeof (Section), // GetEntities<Section>(context, allrelations, x => x.Section_ID)); // entityByType.Add(typeof (Vendor), // GetEntities<Vendor>(context, allrelations, x => x.Vendor_ID)); // entityByType.Add(typeof (Product), // GetEntities<Product>(context, allrelations, x => x.Product_ID)); // entityByType.Add(typeof (SiteTerm), // GetEntities<SiteTerm>(context, allrelations, x => x.SiteTerm_ID)); // entityByType.Add(typeof (Profession), // GetEntities<Profession>(context, allrelations, x => x.Profession_ID)); // entityByType.Add(typeof (Course), // GetEntities<Course>(context, allrelations, x => x.Course_TC)); // // // Func<SiteObjectRelation, IEntityCommonInfo> getEntity = x => // entityByType[SiteObject.TableNameTypes[x.RelationObjectType]] // [x.RelationObject_ID]; // var entityWithTags = tree.Select(x => EntityWithList.New(getEntity(x.Entity), // x.List.Select(getEntity)/*.OrderBy(e => e.WebSortOrder)*/)).ToList(); // return entityWithTags; // } Dictionary <object, IEntityCommonInfo> GetEntities <T>(SpecialistDataContext context, List <SiteObjectRelation> allrelations, Func <T, object> idSelector) where T : class, IEntityCommonInfo { var ids = GetEntityIds(typeof(T), allrelations); if (!ids.Any()) { return(new Dictionary <object, IEntityCommonInfo>()); } return(Repository2 <T> .GetByPKList(context.GetTable <T>(), ids) .ToDictionary(idSelector, x => (IEntityCommonInfo)x)); }
public ActionResult UpdateSorting(List <string> changedTCList, List <string> allTCList) { if (changedTCList != null) { var context = new SpecialistDataContext(); var courses = context.Courses.Where(c => c.IsActive) .OrderBy(c => c.WebSortOrder) .ToList(); new CourseSorting(courses, changedTCList, allTCList).Update(); context.SubmitChanges(); Thread.Sleep(2000); } return(Json("done")); }
private static void CourseTable() { var context = new SpecialistDataContext(); var courses = context.Courses .Where(x => x.IsActive && !x.IsTrack.GetValueOrDefault()) .Select(x => new { x.Course_TC, x.Name, x.UrlName, x.Description, x.AuthorizationType_TC }).ToList(); var courseGroups = context.Groups.Where(g => g.DateBeg >= DateTime.Today).Select(x => x.Course_TC) .Distinct().ToList(); courses = courses.Where(x => x.AuthorizationType_TC != "МС" && !courseGroups.Contains(x.Course_TC)).ToList(); var text = table[courses.Select(x => tr[td[x.Course_TC], td[H.Anchor("http://www.specialist.ru/course/" + x.UrlName, x.Name)], td[x.Description]])].ToString(); File.WriteAllText("courses.html", HtmlHead + text); }
public virtual List <PriceView> GetCurrent() { using (var context = new SpecialistDataContext()) { var loadOptions = new DataLoadOptions(); // context.Log = new StringWriter(); loadOptions.LoadWith <PriceView>(pw => pw.PriceType); context.LoadOptions = loadOptions; var query = context.PriceViews.Where(x => PriceTypes.Current.Contains(x.PriceType_TC)); #if (DEBUG) return(query.Where(p => CourseTC.TestTC.Contains(p.Course_TC) || CourseTC.TestTC.Contains(p.Track_TC)).ToList()); #endif return(query.ToList()); } }
public void Write() { var context = new SpecialistDataContext(); var options = new DataLoadOptions(); options.LoadWith <Group>(c => c.Course); context.LoadOptions = options; var content = context.CourseContents.Where(x => x.Course.IsActive) .Select(x => new { x.ModuleName, x.ModuleNumber, x.Course_TC }) .ToList().GroupBy(x => x.Course_TC).ToDictionary( x => x.Key, z => z.OrderBy(x => x.ModuleNumber) .Select(x => x.ModuleName).ToList()); var groups = context.Groups.PlannedAndNotBegin() .NotSeminars().Where(x => x.DateBeg > DateTime.Today && x.BranchOffice.TrueCity_TC == Cities.Moscow).ToList(); var events = groups.Select(g => new Conference { Name = g.Course.GetName(), OrgName = "Центр компьютерного обучения \"Специалист\" при МГТУ им. Н.Э.Баумана", PublishDate = DateTime.Today.DefaultString(), Description = (content.GetValueOrDefault(g.Course_TC) ?? new List <string>()) .AddFluent( H.Anchor("http://www.specialist.ru/course/{0}?utm_source=executive&utm_medium=text&utm_campaign=2012".FormatWith(g.Course.UrlName), "Подробнее программу курса смотрите на странице курса").ToString() ).AddFluent(Text).JoinWith("<br/>"), BeginDate = g.DateBeg.DefaultString(), EndDate = g.DateEnd.DefaultString(), TypeId = 1479, SubjectId = 1815, Location = "", CountryId = 1779, RegionId = 5560, City = "Москва", RegForm = "", Contact = "", Email = "*****@*****.**", Phone = "(495) 232-3216, 780-4844 (для корпоративных клиентов)" }).ToArray(); SerializationUtils.Serialize(events).Save("events.xml"); /*var container = new UnityContainer(); * UnityRegistrator.RegisterServices(container); * var groupService = container.Resolve<IGroupService>();*/ }
public static void ImportExams(IEnumerable <ProviderExam> providerExams, int vendorID, string examType, int providerId) { var context = new SpecialistDataContext(PioneerConnectionString); foreach (var providerExam in providerExams) { var exam = context.Exams .FirstOrDefault(e => e.Exam_TC == providerExam.Number); if (exam != null) { exam.LastChangeDate = DateTime.Now; } else { exam = new Exam { Exam_TC = providerExam.Number, ExamName = providerExam.Name, ExamType = examType, Vendor_ID = vendorID, LastChangeDate = DateTime.Now }; context.Exams.InsertOnSubmit(exam); } if (!exam.ProviderPrice.HasValue || examType == exam.ExamType) /* if (exam.ExamProviders.All(e => e.Provider_ID != providerId)) { * exam.ExamProviders.Add( * new ExamProvider { * Provider_ID = providerId, * LastChanger_TC = Employees.Specweb, * InputDate = DateTime.Now, * Employee_TC = Employees.Specweb, * LastChangeDate = DateTime.Now * }); * }*/ /*|| (vendorID == ProviderConst.OracleId && examType == Providers.VueExamType)*/ { exam.ProviderPrice = providerExam.Price; exam.Available = true; exam.Languages = providerExam.Languages.Where(l => ProviderConst.GetPrometricLanguages().Contains(l)) .JoinWith(","); } } context.SubmitChanges(); }
private static void ParseReccomendations() { var lines = File.ReadAllLines("profs.txt"); var names = new SpecialistDataContext().Courses .Select(x => new { x.Course_TC, x.Name }).ToDictionary(x => x.Course_TC, x => x.Name); var result = new List <string>(); foreach (var line in lines) { var courseTCs = StringUtils.SafeSplit(line.Split('\t')[2]) .Where(x => !x.IsEmpty()); result.Add(line + "\t\"{0}\"".FormatWith(courseTCs.Select(x => "[{0}]{1}".FormatWith(x, names.GetValueOrDefault(x))).JoinWith(Environment.NewLine))); } File.WriteAllLines("result.txt", result); }
public Response GetRandomForMainPage(List <string> courseTCs) { var context = new SpecialistDataContext(); var response = context.GetTable <Response>().IsActive() .Where(x => x.Rating == ResponseRating.ForMain && courseTCs.Contains(x.Course_TC)) .OrderBy(x => context.GetNewID()).FirstOrDefault(); if (response != null) { return(response); } return(context.GetTable <Response>().IsActive() .Where(x => x.Rating == ResponseRating.ForMain) .OrderBy(x => context.GetNewID()).FirstOrDefault()); }
public virtual List <Group> WebinarOnly() { var localContext = new SpecialistDataContext(); var loadOptions = GetDataLoadOptions(); localContext.LoadOptions = loadOptions; var groups = localContext.Groups.OrderBy(g => g.DateBeg) .WebinarOnly() .NotSeminars() .ToList(); foreach (var @group in groups) { @group.IsWebinarOnly = true; } UpdateIntraExtraDateBegin(groups); return(groups); }
private static void CourseLInks() { var courses = new SpecialistDataContext().Courses .Where(x => x.IsActive && x.UrlName != null && !x.IsTrack.GetValueOrDefault()) .Select(x => new { x.Course_TC, x.UrlName }).ToList().Select(x => Tuple.Create(x, "http://www.specialist.ru/course/" + x.UrlName)); var url = "https://siteexplorer.search.yahoo.com/export;_ylt=A0oG7zEOG5xOZc8AUFfbl8kF?p={0}&bwm=i&fr=sfp"; var doneUrls = Directory.GetFiles("links").Select(Path.GetFileName).ToList(); var courses2 = courses.Where(x => !doneUrls.Contains(x.Item1.UrlName)).ToList(); foreach (var course in courses2) { var fullurl = url.FormatWith(HttpUtility.UrlEncode(course.Item2)); var text = YandexParser.GetHtml(fullurl); File.WriteAllText("links/" + course.Item1.UrlName, text); } }
public void CreateCoefs() { var courseTCs = new SpecialistDataContext().Courses.Where(x => x.IsActive) .Select(x => x.ParentCourse_TC).Distinct().ToList(); var context = new RecRepository().GetContext(); context.DeleteMany <CourseCoef>(c => true); var pairs = courseTCs.SelectMany(x => courseTCs.Select(y => Tuple.Create(x, y))) .Where(x => string.Compare(x.Item1, x.Item2) > 0).ToList(); var i = 0; var courseStudents = context.All <CourseStudent>().ToList() .GroupByToDictionary(x => x.CourseTC, x => x.StudentId); var cache = new List <CourseCoef>(); foreach (var p in pairs) { i++; if (i % 100 == 0) { System.Console.WriteLine(i); } var x1 = courseStudents.GetValueOrDefault(p.Item1); var x2 = courseStudents.GetValueOrDefault(p.Item2); if (x1 == null || x2 == null) { continue; } var a = x1.Count; var b = x2.Count; var c = x1.Intersect(x2).Count(); if (c < 10) { continue; } var k = c * decimal.One * Math.Max(a, b) / ((a + b - c) * Math.Min(a, b)); var ck = new CourseCoef { CourseTC = p.Item1, CourseTC2 = p.Item2, Coef = k * 100, Count = c }; cache.Add(ck); } context.AddMany(cache); }
private Dictionary <Type, Dictionary <object, IEntityCommonInfo> > GetAllEntityByType(List <SiteObjectRelation> allrelations) { var context = new SpecialistDataContext(); var entityByType = new Dictionary <Type, Dictionary <object, IEntityCommonInfo> >(); entityByType.Add(typeof(Section), GetEntities <Section>(context, allrelations, x => x.Section_ID)); entityByType.Add(typeof(Vendor), GetEntities <Vendor>(context, allrelations, x => x.Vendor_ID)); entityByType.Add(typeof(Product), GetEntities <Product>(context, allrelations, x => x.Product_ID)); entityByType.Add(typeof(SiteTerm), GetEntities <SiteTerm>(context, allrelations, x => x.SiteTerm_ID)); entityByType.Add(typeof(Profession), GetEntities <Profession>(context, allrelations, x => x.Profession_ID)); entityByType.Add(typeof(Course), GetEntities <Course>(context, allrelations, x => x.Course_TC)); return(entityByType); }
public void Write() { var courseTCs = Courses.Select(x => x.Key).ToList(); var context = new SpecialistDataContext(); var courseData = context.Courses.Select(x => new { x.Course_TC, x.UrlName }) .ToDictionary(x => x.Course_TC, x => x.UrlName); var groups = context.Groups.Where(x => courseTCs.Contains(x.Course_TC)).NotBegin() .Where(x => x.DateEnd != null) .Select(x => new { x.Course_TC, x.DateBeg, x.DateEnd, x.TimeBeg, x.TimeEnd }).OrderBy(x => x.DateBeg).ToList(); var data = new List <List <string> >(); foreach (var gr in groups) { var en = new CultureInfo("en-US"); var row = _.List( Courses[gr.Course_TC.Trim()].ToString(), "Russian", "RUS", "MOSKVA", "GOSPITALNY LANE 4/6 ", "MOSKVA", "MOSKVA", "105005", gr.DateBeg.Value.ToString("dd-MMM-yyyy", en), gr.DateEnd.Value.ToString("dd-MMM-yyyy", en), "ILT", "", "http://www.specialist.ru/course/" + courseData[gr.Course_TC.Trim()], "+7 (495)7804848", "", "*****@*****.**", "57017"); data.Add(row); } File.WriteAllText("cisco.csv", CsvUtil.Render(data)); }
public void Update() { var context = new PassportDataContext(); var photos = context.UserContacts.Where(x => x.ContactTypeID == ContactTypes.VKontakte && x.User.Student_ID > 0) .Select(x => new { x.User.Student_ID, x.Contact }) .ToDictionary(x => x.Student_ID.Value, x => GetVkUrl(x.Contact)); var students = photos.Keys.ToList(); var specContext = new SpecialistDataContext(); var responses = specContext.GetTable <Response>().Select(x => new { x.RawQuestionnaire.Questionnaire.Student_ID, Response = x }) .Where(x => students.Contains(x.Student_ID)).ToList(); foreach (var response in responses) { var vkUrl = photos[response.Student_ID]; if (vkUrl != null) { response.Response.PhotoUrl = vkUrl.Item1; response.Response.SocialUrl = vkUrl.Item2; } } specContext.SubmitChanges(); }
public static List <ExamPrice> UpdateExamPricesFromProviderPrices(bool submit = false) { var result = new List <ExamPrice>(); var context = new SpecialistDataContext(PioneerConnectionString); var currency = context.Currencies .Where(c => c.CurrencyType_TC == "USD").OrderByDescending(c => c.FiscalDate) .First().Rate; var exams = context.Exams.Where(c => c.ProviderPrice != null && c.ProviderPrice > 0).ToList(); var examCount = exams.Count(); var i = 0; foreach (var exam in exams) { if (submit) { WriteStatus("Обновление цен", null, i, examCount); } var price = exam.ProviderPrice.Value * ProviderConst.NdsCoefficient * currency; if (exam.ExamType == Providers.VueExamType) { price = price * ProviderConst.VueCoefficient; } var newPrice = price % 10 == 0 ? price : ((int)(price * (decimal)0.1)) * 10 + 10; result.Add(new ExamPrice { Exam = exam, Old = (int)exam.ExamPrice.GetValueOrDefault(), New = (int)newPrice }); exam.ExamPrice = newPrice; } if (submit) { context.SubmitChanges(); } return(result); }
public virtual IQueryable <Group> GetPlannedAndNotBegin() { /*#if(DEBUG) * return new List<Group>().AsQueryable(); #endif*/ /* using() * {*/ var groups = new List <Group>(); var localContext = new SpecialistDataContext(); #if (!DEBUG) var loadOptions = GetDataLoadOptions(); localContext.LoadOptions = loadOptions; groups = localContext.Groups.OrderBy(g => g.DateBeg) .PlannedAndNotBegin().NotSeminars().ToList(); foreach (var gr in groups) { gr.IsWebinarOnly = false; if (gr.Group_ID == 176681) { gr.WebinarExists = false; } } #endif #if (DEBUG) groups = localContext.Groups.OrderBy(g => g.DateBeg) .Where(g => CourseTC.TestTC.Contains(g.Course_TC)) .PlannedAndNotBegin() .NotSeminars() .ToList(); #endif // } UpdateIntraExtraDateBegin(groups); return(groups.AsQueryable()); }
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); }