public ActionResult Create(VideoTranscriptModel model)
        {
            if (ModelState.IsValid)
            {
                var videoTranscript = AutoMapper.Mapper.Map <VideoTranscriptModel, VideoTranscript>(model);

                if (!string.IsNullOrWhiteSpace(model.ReporterIds))
                {
                    var reporters = model.ReporterIds.Split(',');
                    foreach (string rpId in reporters)
                    {
                        if (!string.IsNullOrWhiteSpace(rpId))
                        {
                            var rpIdNormalize = rpId.Trim();
                            var reporter      = _reporterRepository.Find(Convert.ToInt32(rpIdNormalize));
                            if (reporter != null)
                            {
                                videoTranscript.Reporters.Add(reporter);
                            }
                        }
                    }
                }
                videoTranscript.ConvertedToSeconds = model.HourSeek * 60 * 60 + model.MinuteSeek * 60 + model.SecondSeek;

                _videoTranscriptRepository.InsertOrUpdate(videoTranscript);
                _videoTranscriptRepository.Save();
            }

            var transcripts      = _videoTranscriptRepository.GetMany(vt => vt.VideoId == model.VideoId).ToList();
            var transcriptModels = AutoMapper.Mapper.Map <List <VideoTranscript>, List <VideoTranscriptModel> >(transcripts);

            return(PartialView("_ListTranscripts", transcriptModels));
        }
Esempio n. 2
0
        public ReporterToListEntity GetReporterById(string id)
        {
            var reporter       = _reporterRepository.Find(Convert.ToInt32(id));
            var reporterEntity = Mapper.Map <ReporterToListEntity>(reporter);

            return(reporterEntity);
        }
Esempio n. 3
0
        public ActionResult Create(HttpPostedFileBase thumbnail, string returnUrl, ArticleModel articleModel)
        {
            if (thumbnail != null && thumbnail.ContentLength > 0)
            {
                string fileName      = Convert.ToInt32((DateTime.Now - new DateTime(2010, 01, 01)).TotalSeconds) + "_" + thumbnail.FileName.Replace(' ', '-');
                string currentDomain = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"];
                string folder        = "UploadedImages/Article";
                string filePath      = System.Configuration.ConfigurationManager.AppSettings[currentDomain] + @"\" + folder + @"\" + fileName;

                using (new Impersonator("uploaduser", "", "Upload@@123"))
                {
                    thumbnail.SaveAs(filePath);
                }
                articleModel.Thumbnail = currentDomain + "/" + folder + "/" + fileName;
            }
            else if (string.IsNullOrEmpty(articleModel.Thumbnail))
            {
                articleModel.Thumbnail = "/Images/NoImage.png";
            }

            ModelState.Clear();
            TryValidateModel(articleModel);

            if (ModelState.IsValid)
            {
                var article = AutoMapper.Mapper.Map <ArticleModel, Article>(articleModel);
                if (article.ArticleContent == null)
                {
                    article.ArticleContent = "";
                }
                _articleRepository.Load(article, v => v.Reporters);
                article.Reporters.Clear();
                if (!string.IsNullOrWhiteSpace(articleModel.ReporterIds))
                {
                    var reporters = articleModel.ReporterIds.Split(',');
                    foreach (string rpId in reporters)
                    {
                        if (!string.IsNullOrWhiteSpace(rpId))
                        {
                            var rpIdNormalize = rpId.Trim();
                            var reporter      = _reporterRepository.Find(Convert.ToInt32(rpIdNormalize));
                            if (reporter != null)
                            {
                                article.Reporters.Add(reporter);
                            }
                        }
                    }
                }

                _articleRepository.Load(article, a => a.Keywords);
                article.Keywords.Clear();
                if (!string.IsNullOrWhiteSpace(articleModel.Keywords))
                {
                    var keywords = articleModel.Keywords.Split(',');
                    foreach (string kw in keywords)
                    {
                        if (!string.IsNullOrWhiteSpace(kw))
                        {
                            var kwNormalize = kw.Trim();
                            var keyword     = _keywordRepository.FindValue(kwNormalize);
                            if (keyword == null)
                            {
                                keyword = new Keyword()
                                {
                                    Value = kwNormalize
                                }
                            }
                            ;
                            article.Keywords.Add(keyword);
                        }
                    }
                }

                _articleRepository.Load(article, a => a.Categories);
                article.Categories.Clear();
                if (!string.IsNullOrWhiteSpace(articleModel.CategoryIds))
                {
                    var cats = articleModel.CategoryIds.Split(',');
                    foreach (string ct in cats)
                    {
                        var ctId = Convert.ToInt32(ct);
                        var cat  = _articleCategoryRepository.Find(ctId);
                        if (cat != null)
                        {
                            article.Categories.Add(cat);
                        }
                    }
                }
                article.CreatedTime = DateTime.Now;

                if (articleModel.Published)
                {
                    article.IsPublished    = true;
                    article.ArticleStatus  = (int)ArticleStatus.Good;
                    article.ArticleContent = NormalizeContent(articleModel.ArticleDraft);
                    article.PublishedTime  = DateTime.Now;
                }
                else
                {
                    article.IsPublished   = false;                         //Mac dinh la false
                    article.ArticleStatus = (int)ArticleStatus.NeedReview; //Mặc định bài đăng chưa được duyệt
                }

                if (article.ArticleSeriesId.HasValue)
                {
                    article.SeriesOrder = _articleRepository.GetLastOrder(article.ArticleSeriesId.Value);
                }
                _articleRepository.InsertOrUpdate(article);
                _articleRepository.Save();

                UpdateRevision(article.Id);

                return(RedirectToAction("Management", "Article"));
                //return Json(new { success = true, time = DateTime.Now.ToString("dd/MM/yyyy HH:mm"), id = article.Id, UniqueTitle = article.UniqueTitle, date = article.PublishedTime.ToString("dd-MM-yyyy") });
            }

            ViewBag.PossibleReporters = _reporterRepository.All.ToList();
            ViewBag.PossibleKeywords  = _keywordRepository.All;
            ViewBag.User = context.Users.Find(User.Identity.GetUserId());
            return(View(articleModel));
        }
Esempio n. 4
0
        //
        // GET: /Reporter/Details/5

        public ViewResult Details(string title)
        {
            return(View(_reporterRepository.Find(title)));
        }