/// <summary> /// 获取指定条数链接列表 /// </summary> /// <param name="userId"></param> /// <param name="isShow"></param> /// <param name="topIndex"></param> /// <returns></returns> public IList <LinkDto> GetList( int?userId, bool?isShow, int topIndex) { var query = LinkDbProxyRepository.FindAll(); var user = UserDbProxyRepository.FindAll(); var linkType = LinkTypeRepository.FindAll(); query = query.Join(user, x => x.User.Id, y => y.Id, (x, y) => x); query = query.Join(linkType, x => x.LinkType.Id, z => z.Id, (x, z) => x); if (userId != null && userId > 0) { query = query.Where(x => x.User.Id == userId); } if (isShow != null) { query = isShow == true?query.Where(x => x.IsShow) : query.Where(x => !x.IsShow); } query = query.OrderByDescending(x => x.LastDateTime); return(query.Select(x => CreateLinkDto(x, x.User, x.LinkType)).ToList()); }
public void Handle(UpdateLinkTypeCommand command) { var linkType = _linkTypeRepository.FindAll().FirstOrDefault(x => x.Id == command.LinkTypeId); Guard.IsNotNull(linkType, "linkType"); if (linkType.User.Id != command.UserId) { throw new PowerException("非法操作"); } if (command.IsShow != null) { linkType.IsShow = (bool)command.IsShow; } if (command.Sort != null) { linkType.Sort = (int)command.Sort; } linkType.TypeName = command.TypeName; linkType.LastDateTime = DateTime.Now; _linkTypeRepository.Save(linkType); }
public void Handle(DeleteLinkTypeCommand command) { var linkType = _linkTypeRepository.FindAll().FirstOrDefault(x => x.Id == command.LinkTypeId); Guard.IsNotNull(linkType, "linkType"); var link = (from f in _linkRepository.FindAll() let t = f.LinkType where t.Id == command.LinkTypeId select f); if (link.Any()) { throw new BusinessException("链接类型下有相关链接,请清除后删除!"); } if (linkType.User.Id != command.UserId) { throw new PowerException("非法操作"); } _linkTypeRepository.Delete(linkType); }