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 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"); }