public JsonResult SubmitVideoUploadForm(VideoUploadModel model)
        {
            try
            {
                if (!ModelState.IsValid) return Json(new { success = false, value = "invalid video upload form" });

                if (!_videoService.IsVideoExists(_videoService.VideoIdExtractor(model.VideoUrl)))
                {
                    const string subCategoriesList = "1089, 1090";

                    var newVideoNodeId = _videoService.CreateNewVideoNode(
                        model.VideoUrl,
                        model.VideoTitle,
                        subCategoriesList,
                        _videoService.GetMonthNode(DateTime.Now.Year.ToString(), DateTime.Now.ToString("MM")));

                    if (newVideoNodeId == 0)
                    {
                        return Json(new {success = false, value = "Error in video node creation"});
                    }

                    if (!CreateVideoItem(model.VideoUrl, model.VideoTitle, subCategoriesList, newVideoNodeId))
                    {
                        _videoService.DeleteVideo(newVideoNodeId);
                        return Json(new {success = false, value = "Error in video Item creation"});
                    }

                    //saving VideoUrl for publish
                    model.NewVideoUrl = Umbraco.TypedContent(newVideoNodeId).Url;
                    _eventPublisher.Publish(new Event<VideoUploadModel> {Entity = model});

                    return Json(new {success = true, value = Umbraco.TypedContent(newVideoNodeId).Url});
                }

               return Json(new { success = false, value = "This Video was already uploaded" });
            }
            catch (Exception e)
            {
                return Json(new {success = false, value = e.Message});
            }
        }
 public ActionResult VideoUploadForm()
 {
     var model = new VideoUploadModel();
     //var categoriesNode =
     //    Umbraco.TypedContentSingleAtXPath("//CategoriesContainer")
     //        .Descendants()
     //        .Where(x => x.DocumentTypeAlias == "SubCategory");
     //foreach (var catNode in categoriesNode)
     //{
     //    model.ListItems.Add(new SelectListItem {Text = catNode.Name, Value = catNode.Id.ToString()});
     //}
     return PartialView("Forms/VideoUploadForm", model);
 }
Exemple #3
0
 public MvcMailMessage VideoMailMessage(VideoUploadModel model)
 {
     ViewBag.Data = model;
     return Populate(x =>
     {
         x.From = new MailAddress("*****@*****.**");
         x.Subject = "A new Video by " + model.MemberName;
         x.ViewName = "VideoMailMessage";
         //EmailsToArray(content.GetPropertyValue<string>("emailAddress")).ForEach(email => x.To.Add(email));
         x.To.Add(emailTo);
     });
 }