示例#1
0
 public User GetUserById(string userId)
 {
     if (string.IsNullOrWhiteSpace(userId))
     {
         throw new Exception("用户ID不能为空");
     }
     return(_user.Find(x => x.UserId == userId));
 }
示例#2
0
        public Article GetModelById(string id)
        {
            var result = new Article();

            if (!string.IsNullOrWhiteSpace(id))
            {
                result = _article.Find(x => x.ArticleId == id);
            }
            return(result);
        }
示例#3
0
        public bool Delete(string id, bool isLogic = true)
        {
            var result = false;

            try
            {
                if (!string.IsNullOrWhiteSpace(id))
                {
                    if (isLogic)
                    {
                        var model = _category.Find(x => x.CategoryId == id);
                        if (model != null)
                        {
                            _category.Update(model);
                            result = true;
                        }
                    }
                    else
                    {
                        _category.Delete(id);
                        result = true;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
示例#4
0
        public string GetMenuCategoryId(string id)
        {
            var result = string.Empty;

            if (string.IsNullOrWhiteSpace(id))
            {
                return(result);
            }
            var exp = new PredicatePack <Menu>();

            exp.PushAnd(x => x.MenuId == id);
            exp.PushAnd(x => x.CategoryId != null);
            var exist = _menu.Find(exp);

            return(exist != null ? exist.CategoryId : result);
        }
示例#5
0
 public void Delete(string id, bool isLogic = true)
 {
     if (string.IsNullOrWhiteSpace(id))
     {
         return;
     }
     if (isLogic)
     {
         var model = _category.Find(x => x.CategoryId == id);
         if (model != null)
         {
             _category.Update(model);
         }
     }
     else
     {
         _category.Delete(id);
     }
 }
示例#6
0
        public bool IsExist(string articleId)
        {
            var article = _article.Find(x => x.ArticleId == articleId);

            return(_article != null);
        }
示例#7
0
        private static bool IsExists(string ip, DateTime lastPostTime)
        {
            var comment = _comment.Find(x => x.IPAddress == ip && x.CreateTime == lastPostTime);

            return(comment != null);
        }
示例#8
0
 public User UserLogin(string userName, string password)
 {
     return(string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password)
         ? throw new Exception("用户名或密码不能为空")
         : _user.Find(x => x.UserName == userName && x.Password == password));
 }