public async Task <ShopOperationResult> CreateAsync(PurchaseInvoice item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     _db.PurchaseInvoices.Add(item);
     try
     {
         await _db.SaveChangesAsync();
     }
     catch
     {
         return(ShopOperationResult.Failed(_errorDescriber.DefaultError()));
     }
     return(ShopOperationResult.Success);
 }
 public async Task <ShopOperationResult> UpdateAsync(PurchaseInvoice item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     _db.PurchaseInvoices.Attach(item);
     _db.PurchaseInvoices.Update(item);
     try
     {
         await _db.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         return(ShopOperationResult.Failed(_errorDescriber.ConcurrencyFailure()));
     }
     return(ShopOperationResult.Success);
 }
        public async Task <ShopOperationResult> DeleteAsync(Guid id)
        {
            var item = await GetAsync(id);

            if (item == null)
            {
                return(ShopOperationResult.Failed(_errorDescriber.NotFoundItem()));
            }

            _db.PurchaseInvoices.Remove(item);
            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(ShopOperationResult.Failed(_errorDescriber.ConcurrencyFailure()));
            }
            return(ShopOperationResult.Success);
        }