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)); }
public ActionResult Create(int vId, double?t) { double hours = 0; double minutes = 0; double seconds = 0; if (t.HasValue) { hours = Math.Floor(Convert.ToDouble(t / 60 / 60)); minutes = Math.Floor(Convert.ToDouble((t - (hours * 60 * 60)) / 60)); seconds = Math.Floor(Convert.ToDouble(t - (hours * 60 * 60) - (minutes * 60))); } var model = new VideoTranscriptModel { UserEditedId = User.Identity.GetUserId(), VideoId = vId, HourSeek = Convert.ToInt32(hours), MinuteSeek = Convert.ToInt32(minutes), SecondSeek = Convert.ToInt32(seconds) }; ViewBag.Reporters = _reporterRepository.All.ToList(); return(PartialView("_CreateForm", model)); }