private Comments CreateComment(ExamContext context, AddCommentDTO commentJson, Users user) { Comments newComment = new Comments() { Text = commentJson.Text, }; newComment.PostDate = DateTime.Now; newComment.CommentedBy = user; context.Comments.Add(newComment); context.SaveChanges(); return newComment; }
private static LoginResponseDTO CreateResponseLogin(Users foundUser, string sessionKey) { LoginResponseDTO user = new LoginResponseDTO() { DisplayName = foundUser.DisplayName, Sessionkey = sessionKey, }; return user; }
private string AddSessionKey(ExamContext context, Users foundUser) { string sessionKey = this.GenerateSessionKey(foundUser.Id); foundUser.SessionKey = sessionKey; context.Entry(foundUser).State = System.Data.EntityState.Modified; context.SaveChanges(); return sessionKey; }
private static Users CreateNewUSer(UserRegisterDTO userJSON, ExamContext context) { // when the user is created Users createdUser = new Users() { DisplayName = userJSON.DisplayName, Username = userJSON.Username, AuthCode = userJSON.AuthCode, }; //we can make sessionkey context.Users.Add(createdUser); context.SaveChanges(); return createdUser; }