/// <summary> /// Creates an API model user from a database model user /// </summary> /// <param name="user">The database model user</param> public ApiUser(SimpleForum.Models.User user) { Username = user.FullUsername; ID = user.UserID; Bio = user.Bio?.Trim(); Posts = user.Threads.Count; Comments = user.Comments.Count + user.UserComments.Count; CommentsLocked = user.CommentsLocked; Banned = user.Banned; DateJoined = user.SignupDate; }
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { // Retrieves user and returns error if muted SimpleForum.Models.User user = await _repository.GetUserAsync(context.HttpContext.User); if (user.Muted) { context.Result = Forbid("Account muted, access denied"); return; } await next(); }