public async Task <Coupon> AddCouponAsync(Coupon bond) { try { dbContext.Coupon.Add(bond); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return(bond); }
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); }
public async Task <Client> AddClientAsync(Client client) { try { if (dbContext.Client.Where(c => c.Email.ToLower() == client.Email.ToLower()).FirstOrDefault() != null) { return(null); } dbContext.Client.Add(client); await dbContext.SaveChangesAsync(); } catch (Exception) { return(null); } return(client); }