Пример #1
0
        public async Task <bool> DiscountPagesAsync(ClientCoupon clientCoupon, int pages)
        {
            if (clientCoupon.SpentPages + pages > (await _couponServices.GetCouponAsync(clientCoupon.CouponId)).Pages)
            {
                return(false);
            }
            clientCoupon.SpentPages += pages;
            await UpdateClientCouponAsync(clientCoupon);

            return(true);
        }
Пример #2
0
 public async Task DeleteClientCouponAsync(ClientCoupon clientCoupon)
 {
     try
     {
         dbContext.ClientCoupon.Remove(clientCoupon);
         await dbContext.SaveChangesAsync();
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #3
0
 public async Task <ClientCoupon> UpdateClientCouponAsync(ClientCoupon clientCoupon)
 {
     try
     {
         var clientExist = dbContext.ClientCoupon.FirstOrDefault(u => u.Id == clientCoupon.Id);
         if (clientExist != null)
         {
             dbContext.Update(clientCoupon);
             await dbContext.SaveChangesAsync();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(clientCoupon);
 }