public ActionResult Create(Comment comment, int id) { if (ModelState.IsValid) { var userId = this.User.Identity.GetUserId(); _service.Create(comment, id, userId); return RedirectToAction("Details", "Pins", new { id = id }); } return View(); }
public void Create(Comment comment, int pinId, string userId) { comment.PinId = pinId; comment.UserId = userId; comment.DateTime = DateTime.Now; var currentUser = this.FindUser(userId); var pin = this.FindPin(pinId); var newNote = new Notification() { DateTime = DateTime.Now, Message = currentUser.DisplayName + " has left a comment on your pin: " + comment.Words, UserId = pin.UserId, PinId = pin.Id, }; _repo.Add<Comment>(comment); _repo.Add<Notification>(newNote); _repo.SaveChanges(); }