public ActionResult AddReviewComment(CommentModel model) { if (ModelState.IsValid) { model.Save(); } return(RedirectToAction("Index", new { id = model.MainId })); }
public HttpResponseMessage Put(CommentModel model) { try { model.Date = DateTime.Now; if (User != null && User.Identity.IsAuthenticated) { var currentUser = new UserPrincipal(User.Identity.Name, _accountRepository); model.Save(currentUser.User); } else { var currentGuest = new GuestPrincipal(HttpContext.Current.Request.UserHostAddress); if (currentGuest.Guest.IsNew) { if (!string.IsNullOrWhiteSpace(model.Website) && !model.Website.ToLower().Contains("http://")) { var website = model.Website.ToLower().Replace("http://", "").Replace("http:/", "").Replace("http:", ""); model.Website = "http://" + website; } var guest = currentGuest.Guest; guest.Date = DateTime.Now; guest.Email = model.Email; guest.Name = model.Name; guest.Website = model.Website; guest.Save(); currentGuest = new GuestPrincipal(guest.IpAddress); } model.Save(guest: currentGuest.Guest); } return(Request.CreateResponse(HttpStatusCode.OK, model)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }