コード例 #1
0
        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);
        }
コード例 #2
0
        public async Task <SignInResult> OnPostLoginAsync(Models.ForumUser model, string password)
        {
            var result = await this.signInManager.PasswordSignInAsync(model.UserName, password, false, lockoutOnFailure : true);

            return(result);
        }
コード例 #3
0
        public Models.ForumUser GetUser(ClaimsPrincipal principal)
        {
            Models.ForumUser user = this.userManager.GetUserAsync(principal).GetAwaiter().GetResult();

            return(user);
        }
コード例 #4
0
        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());
        }