Пример #1
0
        public async Task RemoveLinkById(Guid id)       //删除单个链接
        {
            using (ILinkService linkService = new LinkService())
            {
                var data = await linkService.GetAllAsync().FirstOrDefaultAsync(m => m.Id == id);

                if (data != null)
                {
                    await linkService.RemoveAsync(data);
                }
            }
        }
Пример #2
0
 public async Task <LinkDto> GetAllLinkById(Guid id)
 {
     using (ILinkService linkService = new LinkService())
     {
         return(await linkService.GetAllAsync().Where(m => m.Id == id).Select(m => new LinkDto()
         {
             Id = m.Id,
             Title = m.Title,
             Url = m.Url,
             Describe = m.Describe
         }).FirstOrDefaultAsync());
     }
 }
Пример #3
0
        public async Task EditLink(Guid id, string title, string url, string describe)
        {
            using (ILinkService linkService = new LinkService())
            {
                var data = await linkService.GetAllAsync().FirstOrDefaultAsync(m => m.Id == id);

                if (data != null)
                {
                    data.Title    = title;
                    data.Url      = url;
                    data.Describe = describe;
                    await linkService.EditAsync(data);
                }
            }
        }
Пример #4
0
 public async Task <List <LinkDto> > GetAllLink(string linkname, string desc)
 {
     using (ILinkService linkService = new LinkService())
     {
         return(await linkService.GetAllAsync()
                .Where(m => string.IsNullOrEmpty(linkname) & string.IsNullOrEmpty(desc) || m.Title.Contains(linkname) & m.Describe.Contains(desc))
                .Select(m => new LinkDto()
         {
             Id = m.Id,
             Title = m.Title,
             Url = m.Url,
             Describe = m.Describe
         }).ToListAsync());
     }
 }