public void TestSelect() { HalloContext context = new HalloContext(); Article a = context.Articles .Where(x => x.ApprovedByEditor == true) .FirstOrDefault(x=> x.Id ==2); Assert.IsTrue(a.Images.Count > 0); Assert.IsTrue(a.FrontpageImage != null); }
public PartialViewResult CurrentInfo() { List<Message> model; DateTime today = new DateTime(2013, 3, 10); using (HalloContext context = new HalloContext()) { model = context.Messages .Where(x => x.StartDate < today) .Where(x => x.EndDate > today).ToList(); } return PartialView(model); }
protected void Application_Start() { log4net.Config.XmlConfigurator.Configure(); AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); HalloContext context = new HalloContext(); Database.SetInitializer(new MigrateDatabaseToLatestVersion<HalloContext, HalloDal.Migrations.Configuration>()); Application["FrontpageLinks"] = context.FrontpageLinks.OrderBy(x => x.Order).ToList(); }
public static void init() { Database.SetInitializer(new MigrateDatabaseToLatestVersion<HalloContext, HalloDal.Migrations.Configuration>()); HalloContext c = new HalloContext(); }
public void TestMethod1() { HalloContext context = new HalloContext(); InitArticleCategories(context); //GetOldArticles(context); //Assert.IsTrue(context.Categories.Count() > 5); }
public void ReadImageDimensions() { HalloContext context = new HalloContext(); List<Image> list = context.Images.ToList(); foreach (Image i in list) { System.Drawing.Image jpgImage = System.Drawing.Image.FromFile(@"c:\Hallo\Hallo\Images\articleImages\images\img" + i.Id + ".jpg"); i.Width = jpgImage.Width; i.Height = jpgImage.Height; } context.SaveChanges(); }
// This method loads ArticleCategories from HK-online to a new Hallo-DB public void InitArticleCategories(HalloContext context) { if (context.Categories.Count() > 0) return; SqlConnection sourceConnection = GetSourceConnection(); SqlCommand catCmd = new SqlCommand( "SELECT * from HK_ARTICLE_CATEGORIES order BY CategoriID", sourceConnection ); SqlDataReader catReader = catCmd.ExecuteReader(); while (catReader.Read()) { context.Categories.Add(new ArticleCategory { Name = catReader["CategoriName"].ToString() }); } context.SaveChanges(); catReader.Close(); sourceConnection.Close(); }
public RssResult(HalloContext context, string title) : this() { this.halloContext = context; this.title = title; }
public UserGroupService(HalloContext context) { db = context; }
public List<HKMenuItem> FrontpageMenu(HalloContext context, HttpRequestBase request, User user) { List<HKMenuItem> menu = new List<HKMenuItem>(); List<HKMenuItem> categoryLinks = new List<HKMenuItem>(); List<ArticleCategory> cList = context.Categories.Where(x => x.Articles.Count > 0).OrderBy(c => c.LocalName).ToList(); foreach (ArticleCategory ac in cList) categoryLinks.Add(new HKMenuItem { Text = ac.LocalName, Url = "/Home/Index/" + ac.Id }); menu.Add(new HKMenuItem() { Text = "Artikler", SubMenu = categoryLinks, Active = request.FilePath.Contains("Home/Index/") && request.FilePath.Length > 11 }); menu.Add(new HKMenuItem() { Text = "Aktivitetsklub", Url = "/AcPlan/TeamOverview?all=false" }); if (user.Authorized) { menu.Add(new HKMenuItem { Text = "Streaming", Url = "/Meeting/Streaming" }); List<HKMenuItem> adminLinks = new List<HKMenuItem>(); if (HalloController.IsAuthorized(user, "Editor")) { adminLinks.Add(new HKMenuItem { Text = "Rettigheder", Url = "/Role/Admin" }); } if (HalloController.IsAuthorized(user, "Editor", "Journalist")) { adminLinks.Add(new HKMenuItem { Text = "Artikler", Url = "/Article/List" }); adminLinks.Add(new HKMenuItem { Text = "Filer", Url = "/File/List" }); adminLinks.Add(new HKMenuItem { Text = "Familier", Url = "/FamilyPresentation/List" }); } if (HalloController.IsAuthorized(user, "PmoAdmin")) { adminLinks.Add(new HKMenuItem { Text = "Upload PMO-info", Url = "/User/PmoUpload" }); } if (HalloController.IsAuthorized(user, "SmsAdmin")) { adminLinks.Add(new HKMenuItem { Text = "Send Mail/SMS", Url = "/Mail" }); adminLinks.Add(new HKMenuItem { Text = "Se afsendte SMS", Url = "/Mail/SmsLog" }); adminLinks.Add(new HKMenuItem { Text = "SMS-grupper", Url = "/UserGroup" }); } if (HalloController.IsAuthorized(user, "AcAdmin")) { adminLinks.Add(new HKMenuItem { Text = "AK hold", Url = "/UserGroup/ACIndex" }); adminLinks.Add(new HKMenuItem { Text = "AK datoer", Url = "/AcDate" }); } if (adminLinks.Count > 0) { menu.Add(new HKMenuItem { Text = "Administration", SubMenu = adminLinks }); } } //menu.Add(new HKMenuItem() { Text = "Kalender", Url = "/Calender/Index" }); List<HKMenuItem> externalLinks = new List<HKMenuItem>(); List<FrontpageLink> fpList = context.FrontpageLinks.ToList(); foreach (FrontpageLink fpl in fpList) externalLinks.Add(new HKMenuItem { Text = fpl.Label, Url = fpl.NavigationUrl }); bool linksActive = true; foreach (HKMenuItem item in menu) if (item.Active) linksActive = false; menu.Add(new HKMenuItem() { Text = "Links", SubMenu = externalLinks, Active = linksActive }); return menu; }