public ActionResult Index(int contentId=-1) { if (contentId == -1) return View(); Content content = db.Contents.Where(c => c.ID_CO == contentId).Single(); ContentData[] contentDatas = db.ContentDatas.Where(cd => cd.ID_CO==contentId).ToArray(); List<String> urls = new List<String>(); foreach (ContentData cnt in contentDatas) { urls.Add(cnt.URL); } ContentView cw = new ContentView(content.CONTENT_TEXT, content.CONTENT_TITLE, urls.ToArray(), contentId); return View(cw); }
public ActionResult Index(int contentId = -1) { if (contentId != -1) { try { Content content = db.Contents.Where(c => c.ID_CO == contentId).Single(); List<ContentData> contentDatas = db.ContentDatas.Where(cd => cd.ID_CO == content.ID_CO).ToList(); List<String> tagsNames = new List<String>(); TagsInContent[] tags = db.TagsInContents.Where(t => t.ID_CO == contentId).ToArray(); foreach (TagsInContent tagsInC in tags) { Tag tag = db.Tags.Where(t => t.id == tagsInC.ID_TAG).Single(); tagsNames.Add(tag.name); } ContentView cw = new ContentView(content.CONTENT_TEXT, content.CONTENT_TITLE, contentDatas.ToArray(), contentId, tagsNames.ToArray()); return View(cw); } catch (System.InvalidOperationException) { return View(); } } else return View(); }