public async Task <IActionResult> CreateNewComment(string commentText, string id, string subject, string email) { // COMMENT var commentId = GetUniqueID(); string currentUserId = GetCurrentUserID(); var o = CommentObjectFactory.Create(commentId, DateTime.Now, commentText, subject, email); await _commentRepository.AddObject(o); // COMMENT-EVENT var eventObject = await _eventRepository.GetObject(id); var commentObject = await _commentRepository.GetObject(commentId); var ceo = CommentEventObjectFactory.Create(eventObject, commentObject, id, commentId); await _commentEventRepository.AddObject(ceo); //COMMENT-PROFILE var profileObject = await _profileRepository.GetObject(currentUserId); var cpo = CommentProfileObjectFactory.Create(commentObject, profileObject, commentId, currentUserId); await _commentProfileRepository.AddObject(cpo); return(RedirectToAction(nameof(Details), new { id })); }
public void CreateTest() { var r = GetRandom.Object <CommentProfileDbRecord>(); var newComment = new CommentObject(r.Comments); var newProfile = new ProfileObject(r.Profiles); string c = Constants.Unspecified; string p = Constants.Unspecified; var o = CommentProfileObjectFactory.Create(newComment, newProfile, c, p); Assert.AreEqual(o.CommentObject.DbRecord, r.Comments); Assert.AreEqual(o.ProfileObject.DbRecord, r.Profiles); Assert.AreEqual(o.DbRecord.CommentID, r.Comments.ID); Assert.AreEqual(o.DbRecord.ProfileID, r.Profiles.ID); Assert.AreEqual(o.DbRecord.Profiles, r.Profiles); Assert.AreEqual(o.DbRecord.Comments, r.Comments); }