public ActionResult Create(FeedbackInputModel model) { if (!this.ModelState.IsValid) { return this.View(model); } var feedback = new Feedback() { Content = model.Content, Title = model.Title }; if (this.User.Identity.IsAuthenticated) { feedback.AuthorId = this.User.Identity.GetUserId(); } this.feedback.Add(feedback); //try //{ // this.feedback.SaveChanges(); //} //catch (Exception ex) //{ // throw; //} this.feedback.SaveChanges(); this.TempData["Notification"] = "Thank you for your feedback!"; return this.Redirect("/"); }
public ActionResult Create(AddFeedBackViewModel model) { if (ModelState.IsValid) { Feedback fb = new Feedback(); Mapper.Map(model, fb); fb.Author = this.UserProfile; this.Data.Feedbacks.Add(fb); this.Data.SaveChanges(); this.TempData["Notification"] = "Feedback successfully sent"; return this.Redirect("/"); } return this.View(model); }
public ActionResult Create(CreateFeedbackModel feedback) { if (feedback != null && ModelState.IsValid) { var currentUserId = this.User.Identity.GetUserId(); var databaseFeedback = new Feedback() { Title = feedback.Title, Content = this.sanitizer.Sanitize(feedback.Content), AuthorId = currentUserId }; this.feedbacks.Add(databaseFeedback); this.feedbacks.SaveChanges(); return this.RedirectToAction("Index", "Home", new { notificationMessage = "You have successfully created a feedback!" }); } return this.View(feedback); }