public string GetNewestUser() { Models.ForumUser user = this.dbService.DbContext.Users.OrderByDescending(u => u.RegisteredOn).FirstOrDefault(); string username = string.Empty; if (user != null) { username = user.UserName; } return(username); }
public async Task <SignInResult> OnPostLoginAsync(Models.ForumUser model, string password) { var result = await this.signInManager.PasswordSignInAsync(model.UserName, password, false, lockoutOnFailure : true); return(result); }
public Models.ForumUser GetUser(ClaimsPrincipal principal) { Models.ForumUser user = this.userManager.GetUserAsync(principal).GetAwaiter().GetResult(); return(user); }
public async Task <int> AddPost(ViewModels.Interfaces.Post.IPostInputModel model, Models.ForumUser user, string forumId) { var post = this.mapper.Map <Models.Post>(model); var forum = this.dbService.DbContext.Forums.FirstOrDefault(f => f.Id == forumId); post.StartedOn = DateTime.UtcNow; post.Description = this.ParseDescription(post.Description); post.Views = 0; post.Author = user; post.AuthorId = user.Id; await this.dbService.DbContext.Posts.AddAsync(post); return(await this.dbService.DbContext.SaveChangesAsync()); }