public ActionResult Index() { using (AnonoMightEntities anonoMightEntities = new AnonoMightEntities()) { IEnumerable<string> sites = anonoMightEntities.Sites.Where(o => o.Active).Select(o=>o.SiteName).ToList(); return View(sites); } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { string siteName = (string)filterContext.RouteData.Values["site"]; _anonoMightEntities = ContextFactory.GetContext(siteName); base.OnActionExecuting(filterContext); }
protected override void OnActionExecuted(ActionExecutedContext filterContext) { using (AnonoMightEntities anonoMightEntities = new AnonoMightEntities()) { ViewBag.Sites = anonoMightEntities.Sites.Where(o => o.Active).Select(o=>new {SiteName=o.SiteName, SiteTitle = o.SiteTitle}).ToList().Select(o => new KeyValuePair<string, string>(o.SiteName, o.SiteTitle)); } base.OnActionExecuted(filterContext); }
internal string GetController(string siteName) { using (AnonoMightEntities anonoMightEntities = new AnonoMightEntities()) { Site site = anonoMightEntities.Sites.SingleOrDefault(o => o.SiteName == siteName); if (site == null) return null; return ((SiteType)site.SiteType).ToString(); } }
public ActionResult Manage(string siteName) { using (AnonoMightEntities anonoMightEntities = new AnonoMightEntities()) { Site site = anonoMightEntities.Sites.SingleOrDefault(o => o.SiteName == siteName); ManageSiteModel manageSiteModel = new ManageSiteModel(site); manageSiteModel.Name = siteName; ViewBag.Message = string.Empty; return View(manageSiteModel); } }
public ActionResult Manage(HttpPostedFileBase imageFile, ManageSiteModel manageSiteModel) { if (ModelState.IsValid) { if (imageFile != null) { byte[] logo = new byte[imageFile.ContentLength]; imageFile.InputStream.Read(logo, 0, imageFile.ContentLength); using (AnonoMightEntities anonoMightEntities = new AnonoMightEntities()) { Site site = anonoMightEntities.Sites.SingleOrDefault(o => o.SiteName == manageSiteModel.Name); if (site == null) { site = new Site(); anonoMightEntities.Sites.Add(site); site.SiteName = manageSiteModel.Name; if (manageSiteModel.SiteType == SiteType.Definitions) anonoMightEntities.CreateDefinitionsTable(site.SiteName); else if (manageSiteModel.SiteType == SiteType.FacebookProfiles) anonoMightEntities.CreateFacebookProfilesTable(site.SiteName); else if (manageSiteModel.SiteType == SiteType.ImagePosts) anonoMightEntities.CreateImagePostsTable(site.SiteName); else if (manageSiteModel.SiteType == SiteType.Tweets) anonoMightEntities.CreateTweetsTable(site.SiteName); } site.SiteLogo = logo; site.SiteTitle = manageSiteModel.Title; site.SiteType = (byte)manageSiteModel.SiteType; site.Active = manageSiteModel.Active; site.Description = manageSiteModel.Description; anonoMightEntities.SaveChanges(); } ViewBag.Message = "Site has been saved!"; } else { ViewBag.Message = "No Image Selected!"; } } return View(manageSiteModel); }
public ActionResult Content(string site, int page = 1) { FacebookProfile facebookProfile =null; using (AnonoMightEntities anonoMightEntities = new AnonoMightEntities()) { facebookProfile= anonoMightEntities.GetTopFacebookLinkForTheLastMonth(site).SingleOrDefault(); } using (AnonoMightEntities anonoMightEntities = ContextFactory.GetContext(site)) { Site currentSite = anonoMightEntities.Sites.SingleOrDefault(o => o.SiteName == site && o.Active); if (currentSite != null) { return View(new FacebookLinkModel(currentSite, anonoMightEntities.FacebookProfiles, facebookProfile, page)); } else return Content("This site does not exist!"); } }
public ActionResult GetSiteImage(string siteName) { byte[] image = null; using (AnonoMightEntities anonoMightEntities = new AnonoMightEntities()) { Site site = anonoMightEntities.Sites.SingleOrDefault(o => o.SiteName == siteName); if (site != null) { image = site.SiteLogo; } } if (image == null) { return new FilePathResult("~/Images/noimage.png", "image/png"); } else { return new FileContentResult(image, "image/jpeg"); } }
public ActionResult Report(string siteName, Guid postId, ReportClass reportClass) { using (AnonoMightEntities anonoMightEntities = new AnonoMightEntities()) { anonoMightEntities.Reports.Add(new Report { PostId = postId, ReportClass = (byte)reportClass, SiteName = siteName, TimeStamp = DateTime.Now }); anonoMightEntities.SaveChanges(); } return Json("Success"); }