public ActionResult Create(ArticleDto model) { if (ModelState.IsValid) { var file = Request.Files["ImageInput"]; if (file != null && file.ContentLength > 0) { var upload = new UploadUtility(StoreAreaForUpload.ForArticle); var result = upload.SharedCoverSaveAs(file); if (!result.Success) { ModelState.AddModelError("UploadError", result.Message); return(View(model)); } model.ThumbPath = result.Message; } else { const string noImage = @"/assets/img/bg/noarticle_photo_500x280.jpg"; model.ThumbPath = Utilities.GetImgUrl(model.ArticleContent); if (String.IsNullOrEmpty(model.ThumbPath)) { model.ThumbPath = noImage; } } _articleService.AddArticle(model); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(VideoDto model) { if (ModelState.IsValid) { var file = Request.Files["ImageInput"]; if (file != null && file.ContentLength > 0) { var upload = new UploadUtility(StoreAreaForUpload.ForVideo); var result = upload.SharedCoverSaveAs(file); if (!result.Success) { ModelState.AddModelError("UploadError", result.Message); return(View(model)); } model.ThumbPath = result.Message; } _videoService.AddVideo(model); return(RedirectToAction("Index")); } BindVideoCategory(model.Category); return(View(model)); }