示例#1
0
 public ActionResult Edit(VideoViewModel video)
 {
     ViewBag.SelectedPage = Navigator.Items.VIDEOS;
     if (ModelState.IsValid)
     {
         video.URL = URLValidator.CleanURL(video.URL);
         if (!URLValidator.IsValidURLPart(video.URL))
         {
             TempData["ErrorMessage"] = "Video Failed To Add, URL Not Valid";
         }
         else if (servicesManager.VideoService.IsVideoURLExist(video.URL, video.VideoId))
         {
             TempData["ErrorMessage"] = "Video Failed To Add, URL already exist";
         }
         else
         {
             int new_id = servicesManager.VideoService.UpdateVideo(video);
             if (new_id > 0)
             {
                 TempData["SuccessMessage"] = "Video Updated Successfully";
                 return(RedirectToAction("Edit", video.VideoId));
             }
             else
             {
                 TempData["ErrorMessage"] = "Video Failed To Update";
             }
         }
     }
     //FillArticleCategories(article.CategoryId);
     FillVideoAuthor(video.AuthorId);
     FillVideoCategories(video.CategoryId);
     FillAvailableTags();
     return(View(video));
 }
 public ActionResult Edit(ArticleViewModel article)
 {
     ViewBag.SelectedPage = Navigator.Items.ARTICLES;
     if (ModelState.IsValid)
     {
         article.URL = URLValidator.CleanURL(article.URL);
         if (!URLValidator.IsValidURLPart(article.URL))
         {
             TempData["ErrorMessage"] = "Article Failed To Add, URL Not Valid";
         }
         else if (servicesManager.ArticleService.IsArticleURLExist(article.URL, article.ArticleId))
         {
             TempData["ErrorMessage"] = "Article Failed To Add, URL already exist";
         }
         else
         {
             int new_id = servicesManager.ArticleService.UpdateArticle(article);
             if (new_id > 0)
             {
                 TempData["SuccessMessage"] = "Article Updated Successfully";
                 return(RedirectToAction("Edit", article.ArticleId));
             }
             else
             {
                 TempData["ErrorMessage"] = "Article Failed To Update";
             }
         }
     }
     FillArticleCategories(article.CategoryId);
     FillArticleAuthor(article.AuthorId);
     FillAvailableTags();
     return(View(article));
 }
示例#3
0
        public ActionResult New(VideoViewModel video, IEnumerable <HttpPostedFileBase> Images)
        {
            ViewBag.SelectedPage = Navigator.Items.NEWVIDEO;
            FillVideoCategories(video.CategoryId);
            FillVideoAuthor(video.AuthorId);
            FillAvailableTags();

            if (ModelState.IsValid)
            {
                video.URL = URLValidator.CleanURL(video.URL);
                if (Images != null && Images.Count() > 0 && !ImageService.IsValid(Images))
                {
                    TempData["ErrorMessage"] = "Video Failed To Add, Invalid Image File";
                }
                else if (!URLValidator.IsValidURLPart(video.URL))
                {
                    TempData["ErrorMessage"] = "Video Failed To Add, URL Not Valid";
                }
                else if (servicesManager.VideoService.IsVideoURLExist(video.URL))
                {
                    TempData["ErrorMessage"] = "Video Failed To Add, URL already exist";
                }
                else
                {
                    int new_id = servicesManager.VideoService.AddNewVideo(video, Images);

                    if (new_id > 0)
                    {
                        TempData["SuccessMessage"] = "Video Added Successfully";
                        return(RedirectToAction("Edit", new { id = new_id }));
                    }
                    else
                    {
                        TempData["ErrorMessage"] = "Video Failed To Add";
                    }
                }
            }

            return(View(video));
        }
        public ActionResult New(ArticleViewModel article, IEnumerable <HttpPostedFileBase> Images)
        {
            ViewBag.SelectedPage = Navigator.Items.NEWARTICLE;
            FillArticleCategories(article.CategoryId);
            FillArticleAuthor(article.AuthorId);
            FillAvailableTags();

            if (ModelState.IsValid)
            {
                article.URL = URLValidator.CleanURL(article.URL);
                if (Images != null && Images.Count() > 0 && !ImageService.IsValid(Images))
                {
                    TempData["ErrorMessage"] = "Article Failed To Add, Invalid Image File";
                }
                else if (!URLValidator.IsValidURLPart(article.URL))
                {
                    TempData["ErrorMessage"] = "Article Failed To Add, URL Not Valid";
                }
                else if (servicesManager.ArticleService.IsArticleURLExist(article.URL))
                {
                    TempData["ErrorMessage"] = "Article Failed To Add, URL already exist";
                }
                else
                {
                    int new_id = servicesManager.ArticleService.AddNewArticle(article, Images);

                    if (new_id > 0)
                    {
                        TempData["SuccessMessage"] = "Article Added Successfully";
                        return(RedirectToAction("Edit", new { id = new_id }));
                    }
                    else
                    {
                        TempData["ErrorMessage"] = "Article Failed To Add";
                    }
                }
            }

            return(View(article));
        }