public FubuContinuation AskCommand(AskInputModel inputModel) { var question = inputModel.Map <Question>(); question.Id = Guid.NewGuid().ToString("D"); question.Answers = new List <Answer>(); _repo.GetQuestions().Add(question); return(FubuContinuation.RedirectTo(question.Map <QuestionInputModel>())); }
public ActionResult Ask(AskInputModel input) { if (!ModelState.IsValid) { return(this.View(input)); } var tagNames = Regex.Split(input.Tags, @"\W+"); var uniqueTagNames = new HashSet <string>(tagNames); var postTags = new List <Tag>(); foreach (var uniquesTagName in uniqueTagNames) { var tag = this.tags.All().Where(x => x.Name == uniquesTagName).FirstOrDefault(); if (tag == null) { tag = new Tag { Name = uniquesTagName }; this.tags.Add(tag); } postTags.Add(tag); } var userId = this.User.Identity.GetUserId(); var post = new Post { Title = input.Title, Content = this.sanitizer.Sanitize(input.Content), AuthorId = userId }; foreach (var postTag in postTags) { postTag.Posts.Add(post); } this.tags.SaveChanges(); return(this.RedirectToAction("Display", new { id = post.Id })); }
public ActionResult Ask(AskInputModel input) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); var post = new Post { Title = input.Title, Content = sanitizer.Sanitize(input.Content), AuthorId = userId //TODO: Tags }; posts.Add(post); posts.SaveChanges(); return(RedirectToAction("Display", new { id = post.Id, url = "new" })); } return(View(input)); }
public ActionResult Ask(AskInputModel input) { if (ModelState.IsValid) { var userId = this.User.Identity.GetUserId(); var post = new Post { Title = input.Title, Content = this.sanitizer.Sanitize(input.Content), AuthorId = userId, }; this.posts.Add(post); this.posts.SaveChanges(); this.TempData["Notification"] = "Your question has been Send. We'll be in touch with you soon "; return(RedirectToAction("Display", new { id = post.Id, url = "new" })); } return(this.View(input)); }
public ActionResult Ask(AskInputModel input) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); var post = new Post { Content = input.Content, Title = input.Title, AuthorId = userId, TagId = input.TagId, Category = input.Category //todo: Tags }; _posts.Add(post); _posts.SaveChanges(); // return RedirectToAction("Display", new {id = post.Id, Url = "new"}); //todo: fix this return(RedirectToAction("Index", "Post", new { id = post.TagId })); } return(View(input)); }
public ActionResult Ask(AskInputModel input) { if (ModelState.IsValid) { var userId = this.User.Identity.GetUserId(); var post = new Post { Title = input.Title, Content = this.sanitizer.Sanitize(input.Content), AuthorId = userId, // TODO: Tags // TODO: Author }; this.posts.Add(post); this.posts.SaveChanges(); return this.RedirectToAction("Display", new { id = post.Id, url = "new" }); } return this.View(input); }
public ActionResult Ask() { var model = new AskInputModel(); return this.View(model); }
public ActionResult Ask() { var model = new AskInputModel(); return(View(model)); }