public ActionResult Detail(string key) { ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 190 : 400; ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 285 : 600; var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(key); ViewBag.ThumbIcon = Utilities.S3ContentPath(model.ContentPhotoThumbURL); LoadTagCloud(); ContentComment concom = new ContentComment(); BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content otherNews = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); otherNews.GetPreviousNews(model.ReleaseDate ); if (otherNews.ContentID > 0 ) { ViewBag.PreviousNews = otherNews.ToUnorderdListItem; } otherNews = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); otherNews.GetNextNews(model.ReleaseDate ); if (otherNews.ContentID > 0) { ViewBag.NextNews = otherNews.ToUnorderdListItem; } return View(model); }
public ActionResult DeleteComment(int commentID) { MembershipUser mu = Membership.GetUser(); var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.ContentComment(commentID); Content content = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(model.ContentID); if (mu == null || model.CreatedByUserID != Convert.ToInt32(mu.ProviderUserKey)) return new EmptyResult(); model.Delete(); return RedirectToAction("Detail", new { @key = content.ContentKey }); }
public ActionResult EditArticle(int? id) { ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 160 : 360; ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 285 : 640; var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); if (id != null && id > 0) { model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content( Convert.ToInt32(id)); } return View(model); }
public ActionResult EditArticle( FormCollection fc, int? contentID, HttpPostedFileBase imageFile, HttpPostedFileBase videoFile, HttpPostedFileBase videoFile2) { mu = Membership.GetUser(); var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); if (contentID != null && contentID > 0) { model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content( Convert.ToInt32(contentID)); } TryUpdateModel(model); ////// begin: amazon var acl = CannedAcl.PublicRead; S3Service s3 = new S3Service(); s3.AccessKeyID = AmazonCloudConfigs.AmazonAccessKey; s3.SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey; if (string.IsNullOrWhiteSpace(model.Detail) ) { ModelState.AddModelError(Messages.Required, Messages.Required + ": " + Messages.Details); } if (imageFile == null && string.IsNullOrWhiteSpace(model.ContentPhotoURL)) { ModelState.AddModelError(Messages.Required, Messages.Required + ": " + Messages.Photo); } if (ModelState.IsValid) { model.ContentKey = FromString.URLKey(model.Title); if (model.ContentID == 0) { mu = Membership.GetUser(); model.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); if (model.ReleaseDate == DateTime.MinValue) { model.ReleaseDate = DateTime.UtcNow; } } if (model.Set() <= 0) return View(model); if (imageFile != null) { Bitmap b = new Bitmap(imageFile.InputStream); System.Drawing.Image fullPhoto = (System.Drawing.Image)b; string fileNameFull = Utilities.CreateUniqueContentFilename(imageFile); System.Drawing.Image imgPhoto = ImageResize.FixedSize(b, 600, 400, System.Drawing.Color.Black); Stream maker = imgPhoto.ToAStream(ImageFormat.Jpeg); s3.AddObject( maker, maker.Length, AmazonCloudConfigs.AmazonBucketName, fileNameFull, imageFile.ContentType, acl); if (!string.IsNullOrWhiteSpace(model.ContentPhotoURL)) { if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, model.ContentPhotoURL)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, model.ContentPhotoURL); } } model.ContentPhotoURL = fileNameFull; // resized string fileNameThumb = Utilities.CreateUniqueContentFilename(imageFile); System.Drawing.Image imgPhotoThumb = ImageResize.FixedSize(b, 350, 250, System.Drawing.Color.Black); maker = imgPhotoThumb.ToAStream(ImageFormat.Jpeg); s3.AddObject( maker, maker.Length, AmazonCloudConfigs.AmazonBucketName, fileNameThumb, imageFile.ContentType, acl); if (!string.IsNullOrWhiteSpace(model.ContentPhotoThumbURL)) { if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, model.ContentPhotoThumbURL)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, model.ContentPhotoThumbURL); } } model.ContentPhotoThumbURL = fileNameThumb; model.Set(); } if (videoFile != null) { // full try { string fileName3 = Utilities.CreateUniqueContentFilename(videoFile); // full fileName3 = Utilities.CreateUniqueContentFilename(videoFile); s3.AddObject( videoFile.InputStream, videoFile.ContentLength, AmazonCloudConfigs.AmazonBucketName, fileName3, videoFile.ContentType, acl); if (!string.IsNullOrWhiteSpace(model.ContentVideoURL)) { if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, model.ContentVideoURL)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, model.ContentVideoURL); } } model.ContentVideoURL = fileName3; model.Set(); } catch { } } if (videoFile2 != null) { // full try { string fileName3 = Utilities.CreateUniqueContentFilename(videoFile2); // full fileName3 = Utilities.CreateUniqueContentFilename(videoFile2); s3.AddObject( videoFile2.InputStream, videoFile2.ContentLength, AmazonCloudConfigs.AmazonBucketName, fileName3, videoFile2.ContentType, acl); if (!string.IsNullOrWhiteSpace(model.ContentVideoURL2)) { if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, model.ContentVideoURL2)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, model.ContentVideoURL2); } } model.ContentVideoURL2 = fileName3; model.Set(); } catch { } } return RedirectToAction("Articles"); } else { return View(model); } }
public ActionResult DeleteVideo(int? id) { var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(Convert.ToInt32(id)); S3Service s3 = new S3Service(); s3.AccessKeyID = AmazonCloudConfigs.AmazonAccessKey; s3.SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey; if (!string.IsNullOrWhiteSpace(model.ContentVideoURL) && s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, model.ContentVideoURL)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, model.ContentVideoURL); model.ContentVideoURL = string.Empty; model.Set(); } if (!string.IsNullOrWhiteSpace(model.ContentVideoURL2) && s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, model.ContentVideoURL2)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, model.ContentVideoURL2); model.ContentVideoURL2 = string.Empty; model.Set(); } return RedirectToAction("EditArticle", new { @id = model.ContentID }); }
public ActionResult DeleteArticle(int? id) { mu = Membership.GetUser(); var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); if (id != null && id > 0) { model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content( Convert.ToInt32(id)); ContentComments concoms = new ContentComments(); concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.U); concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.C); if (model.CreatedByUserID == Convert.ToInt32(mu.ProviderUserKey)) { // security check foreach (ContentComment c1 in concoms) c1.Delete(); model.Delete(); } } return RedirectToAction("Articles"); }
public ActionResult CreateArticle() { var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); if (model.ReleaseDate == DateTime.MinValue) { model.ReleaseDate = DateTime.UtcNow; } return View(model); }
public ActionResult DeleteArticle(int? id) { var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); if (id != null && id > 0) { model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content( Convert.ToInt32(id)); ContentComments concoms = new ContentComments(); concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.U); concoms.GetCommentsForContent(model.ContentID, SiteEnums.CommentStatus.C); foreach (ContentComment c1 in concoms) c1.Delete(); model.Delete(); } return RedirectToAction("Articles"); }
public ActionResult Detail(FormCollection fc, int contentID) { MembershipUser mu = Membership.GetUser(); LoadTagCloud(); var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(contentID); model.Reply = new ContentComment(); model.Reply.StatusType = Convert.ToChar(SiteEnums.CommentStatus.C.ToString()); model.Reply.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); model.Reply.ContentID = contentID; model.Reply.IpAddress = Request.UserHostAddress; TryUpdateModel(model); if (ModelState.IsValid) { if (BlackIPs.IsIPBlocked(Request.UserHostAddress)) { return View(model); } model.Reply.Create(); return View(model); } else { return View(model); } }