public User GetUserById(string userId) { if (string.IsNullOrWhiteSpace(userId)) { throw new Exception("用户ID不能为空"); } return(_user.Find(x => x.UserId == userId)); }
public Article GetModelById(string id) { var result = new Article(); if (!string.IsNullOrWhiteSpace(id)) { result = _article.Find(x => x.ArticleId == id); } return(result); }
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); }
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); }
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); } }
public bool IsExist(string articleId) { var article = _article.Find(x => x.ArticleId == articleId); return(_article != null); }
private static bool IsExists(string ip, DateTime lastPostTime) { var comment = _comment.Find(x => x.IPAddress == ip && x.CreateTime == lastPostTime); return(comment != null); }
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)); }