public ActionResult Edit(int id, int page) { prioripage = page; TagDAO tagDAO = new TagDAO(); var listTag = tagDAO.GetTag(id); return(View(listTag)); }
public IActionResult Index() { ViewData["isLogin"] = _sessionDao.GetUsername(Logic.Logic.GetSessionId(Request)) != null; var sessionId = Logic.Logic.GetSessionId(Request); var title = Logic.Logic.GetValue(Request, "title"); var content = Logic.Logic.GetValue(Request, "body"); var tags = Logic.Logic.GetValue(Request, "tags"); var username = _sessionDao.GetUsername(sessionId); var user = (User)_userDao.GetUserByUsername(username); if (user == null) { return(RedirectToAction("Index", "Login")); } if (title != null && content != null && tags != null) { var ts = tags.Split(' '); var questionId = _questionDao.CreateQuestion(title, content, user.Id); foreach (string tagtmp in ts) { if (_tagDao.GetTag(tagtmp) == null) { //create tag _tagDao.CreatTag(tagtmp); } //get tagId var tag = (Tag)_tagDao.GetTag(tagtmp); var tagId = tag.Id; //create question tag _tagQuestionDao.CreateTagQuestion(questionId, tagId); } } else if (Request.Method == "POST") { ViewData["errorAddQuestion"] = "title and body are requirement"; } return(View()); }
public ActionResult Create(Note note) { try { NoteDAO.Create(note); //get tags var tagList = note.TagList; char[] delimiter = { ' ' }; string[] tags = tagList.Split(delimiter); foreach (var tag in tags) { if (tag != null || tag != "") { var t = new Tag { Name = tag }; TagDAO.Create(t); } var tagItem = TagDAO.GetTag(tag); var nTag = new Note_Tag(); nTag.NoteId = note.NoteId; nTag.TagId = tagItem.Id; Note_TagDAO.Create(nTag); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); return(View()); } return(RedirectToAction("Index", "Home")); }
public static Tag GetTag(string ID) { return(TagDAO.GetTag(ID)); }