public async Task <bool> ExistAsync(Guid id)
        {
            var request = await _context
                          .FindAsync <ClientRequest>(id);

            return(request != null);
        }
 public virtual async Task <T> GetAsync(Guid aId)
 {
     try
     {
         return(await Context.FindAsync <T>(aId));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
示例#3
0
 public async Task <TEntity> GetById(int id)
 {
     if (id == 0)
     {
         throw new ArgumentException($"{nameof(GetById)} id must not be empty");
     }
     try
     {
         return(await productContext.FindAsync <TEntity>(id));
     }
     catch (Exception ex)
     {
         throw new Exception($"Couldn't retrieve entities: {ex.Message}");
     }
 }
示例#4
0
        public async Task <Result> DeleteProduct(int id)
        {
            var product = await _productContext.FindAsync <Product>(id);

            if (product != null)
            {
                _productContext.Remove <Product>(product);
                await _productContext.SaveChangesAsync();
            }
            else
            {
            }

            return(await Task.FromResult <Result>(new Result()
            {
                IsSuccess = true, Message = "Done"
            }));
        }
 public async Task <Product> GetByAsync(Guid id)
 {
     return(await _context.FindAsync <Product>(id));
 }