public ActionResult Feedback(FeedbackBindingModel bindingModel) { if (ModelState.IsValid) { this._service.CreateFeedback(bindingModel, this.HttpContext.User.Identity.GetUserId()); return(RedirectToAction("Dashboard")); } return(View(bindingModel)); }
public void CreateFeedback(FeedbackBindingModel bindingModel, string userId) { Feedback feedback = Mapper.Map <FeedbackBindingModel, Feedback>(bindingModel); feedback.Id = Guid.NewGuid().ToString(); User sender = this.Context.Users.Find(userId); feedback.Sender = sender; this.Context.Feedbacks.Add(feedback); this.Context.SaveChanges(); }
public IHttpActionResult Post(Guid?productId, [FromBody] FeedbackBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { this.feedback.Create(productId.GetValueOrDefault(), User.Identity.GetUserId(), model.Content, model.Rate); return(Ok(string.Format(CommonConstants.SuccessfullEntityOperation, nameof(Feedback), CommonConstants.Created))); } catch (BadRequestException bre) { ModelState.AddModelError(CommonConstants.ErrorKey, bre.Message); return(BadRequest(ModelState)); } }