Esempio n. 1
0
        public override async Task DeleteAsync(CommentInfo model)
        {
            using (MVCBlogContext Context = new MVCBlogContext())
            {
                var entity = Context.CommentInfo.Find(model.Id);
                entity.IsDelete = true;
                await Context.SaveChangesAsync();

                await base.DeleteAsync(model);
            }
        }
Esempio n. 2
0
        public override async Task InsertAsync(CategoryInfo model, int userid)
        {
            using (MVCBlogContext Context = new MVCBlogContext())
            {
                model.CreateUser = Context.UserInfo.Find(userid == 0 ? model.CreateUser.Id : userid);
                Context.CategoryInfo.Add(model);
                await Context.SaveChangesAsync();

                await base.InsertAsync(model, userid);
            }
        }
Esempio n. 3
0
        public override async Task InsertAsync(CommentInfo model, int userid = 0)
        {
            using (MVCBlogContext Context = new MVCBlogContext())
            {
                model.CommentUser = await Context.UserInfo.FindAsync(userid);

                Context.CommentInfo.Add(model);
                await Context.SaveChangesAsync();

                await base.InsertAsync(model, userid);
            }
        }
Esempio n. 4
0
        public override async Task UpdateAsync(CommentInfo model)
        {
            using (MVCBlogContext Context = new MVCBlogContext())
            {
                var entity = await Context.CommentInfo.FindAsync(model.Id);

                entity.CommentContent = model.CommentContent;
                await Context.SaveChangesAsync();

                await base.UpdateAsync(model);
            }
        }
Esempio n. 5
0
        public override async Task DeleteAsync(PostInfo model)
        {
            using (MVCBlogContext Context = new MVCBlogContext())
            {
                if (model != null)
                {
                    var entity = Context.PostInfo.Find(model.Id);
                    entity.IsDelete   = true;
                    entity.PostStatus = PostStatus.除;
                    await Context.SaveChangesAsync();

                    await base.DeleteAsync(model);
                }
            }
        }
Esempio n. 6
0
        public override async Task UpdateAsync(CategoryInfo model)
        {
            using (MVCBlogContext Context = new MVCBlogContext())
            {
                var entity = Context.CategoryInfo.Find(model.Id);
                if (entity != null)
                {
                    entity.CategoryName = model.CategoryName;
                    entity.IsDelete     = model.IsDelete;
                    await Context.SaveChangesAsync();

                    await base.UpdateAsync(model);
                }
            }
        }
Esempio n. 7
0
        //private MVCBlogContext Context;

        //public UserService(MVCBlogContext _context)
        //{
        //    this.Context = _context;
        //}

        public override async Task InsertAsync(UserInfo user, int userid = 0)
        {
            using (MVCBlogContext Context = new MVCBlogContext())
            {
                user.Password   = AesSecret.EncryptStringToAES(user.Password);
                user.CreateTime = DateTime.Now;
                user.EditedTime = DateTime.Now;
                user.UserStatus = UserStatus.正常;
                user.UserRole   = UserRole.读者;
                user.IsDelete   = false;
                Context.UserInfo.Add(user);
                await Context.SaveChangesAsync();

                await base.InsertAsync(user, userid);
            }
        }
Esempio n. 8
0
        public async Task <UserInfo> ValidateUserAsync(string email, string password)
        {
            using (MVCBlogContext Context = new MVCBlogContext())
            {
                string          encryptPassword = AesSecret.EncryptStringToAES(password);
                Func <UserInfo> finditem        = () => Context.UserInfo.FirstOrDefault(x => x.Email == email && x.Password == encryptPassword);
                var             entity          = await Common.ThreadHelper.StartAsync <UserInfo>(finditem);

                if (entity != null)
                {
                    entity.LastLoginTime = DateTime.Now;
                    await Context.SaveChangesAsync();

                    entity = await Context.UserInfo.FindAsync(entity.Id);

                    return(entity);
                }
                return(null);
            }
        }