public ActionResult Create(PodcastViewModel model, int type) { if (ModelState.IsValid) { var user = new Podcast { Title = model.Title.Trim(), TypeId = model.TypeId, IsPublish = model.IsPublic, ContentText = model.ContentText != null?model.ContentText.Replace("../../content/files/editor/", "/content/files/editor/") .Replace("../content/files/editor/", "/content/files/editor/") : "", Description = model.Description }; if (model.RegisterTime.ToLower().Contains("pm")) { var m = model.RegisterTime.Split(":"); model.RegisterTime = (Convert.ToInt32(m[0]) == 12 ? 0 : Convert.ToInt32(m[0])) + 12 + ":" + m[1].ToLower().Replace("pm", "").Trim(); } user.PublishDateTime = (model.RegisterDate + " , " + model.RegisterTime.ToLower().Replace("am", "").Trim()).ToGregorianDateTime(); var c = new List <PodcastTag>(); if (model.Tags != null) { var styles = model.Tags.Split(","); foreach (var t in styles) { c.Add(new PodcastTag { TagId = Convert.ToInt32(t), Type = "tag", }); } } if (model.Category != null) { var artist = model.Category.Split(","); // var c = new List<PodcastTag>(); foreach (var t in artist) { c.Add(new PodcastTag { TagId = Convert.ToInt32(t), Type = "cat", }); } } if (model.Auther != null) { var music = model.Auther.Split(","); // var c = new List<PodcastTag>(); foreach (var t in music) { c.Add(new PodcastTag { TagId = Convert.ToInt32(t), Type = "auther", }); } } if (model.Speaker != null) { var music = model.Speaker.Split(","); // var c = new List<PodcastTag>(); foreach (var t in music) { c.Add(new PodcastTag { TagId = Convert.ToInt32(t), Type = "speaker", }); } } if (model.Editor != null) { var music = model.Editor.Split(","); // var c = new List<PodcastTag>(); foreach (var t in music) { c.Add(new PodcastTag { TagId = Convert.ToInt32(t), Type = "editor", }); } } if (c.Count > 0) { user.PodcastTags = c; } _podcastService.AddNewPodcast(user, model.Photo, model.Photo); _uow.SaveChanges(); return(RedirectToAction(nameof(Index), new { type = user.TypeId })); } return(View(model)); }