protected void addComentario_Click(object sender, EventArgs e) { try { if (SessionManager.IsUserAuthenticated(Context)) { String contentComment = introducirComentario.Text; UserProfileDetails userProfileDetails = SessionManager.FindUserProfileDetails(Context); String email = userProfileDetails.Email; UserProfile u = userService.FindUserByEmail(email); DateTime commentDate = DateTime.Now; Comment c = new Comment(); c.content = contentComment; c.loginName = u.loginName; c.commentDate = commentDate; c.Event = evento; eventService.AddComment(contentComment, evento.eventId, u.usrId); } } catch { throw new Exception(); } }
public IActionResult AddComment(int eventId, [FromForm] string comment) { var result = _eventService.AddComment(eventId, comment, HttpContext); if (result.IsError) { return(StatusCode(422, result.Errors)); } return(Ok(result.SuccessResult)); }
public void Service_AddComment() { try { long userId = userService.RegisterUser(userLoginName2, clearPassword, new UserProfileDetails(firstName, lastName, email, language, country)); eventService.AddComment(content2, myEvent.eventId, userId); Event e1 = eventService.FindEventById(myEvent.eventId); ICollection <Comment> comentarios = e1.Comments; ; Assert.AreEqual(2, comentarios.Count, "Comment has not been add."); } catch (Exception e) { Assert.Fail(e.Message); } }