public ActionResult Feedback(FeedbackViewModel viewModel) { if(ModelState.IsValid) { using (new UnitOfWork(_currentContext)) { var feedback = new Feedback { Name = viewModel.Author, Email = viewModel.Email, Text = viewModel.Text }; feedbackRepository.Add(feedback); } TempData[Const.ActionResultInfo] = "Спасибо за ваш отзыв. Администрация будет уведомлена."; return RedirectToAction("Feedback"); } TempData[Const.ActionErrorInfo] = "Невозможно добавить ваш отзыв. Пожалуйста, проверьте корректность введенных данных."; return View(); }
/// <summary> /// Create a new Feedback object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="text">Initial value of the Text property.</param> public static Feedback CreateFeedback(global::System.Int32 id, global::System.String name, global::System.String text) { Feedback feedback = new Feedback(); feedback.Id = id; feedback.Name = name; feedback.Text = text; return feedback; }
/// <summary> /// Deprecated Method for adding a new object to the FeedbackSet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToFeedbackSet(Feedback feedback) { base.AddObject("FeedbackSet", feedback); }