public async Task <bool> AddWebinarPurchasedOptionsDetails(WebinarPurchasedOptionsDetails webinarPurchasedOptionsDetails) { try { webinarPurchasedOptionsDetails.WebinarLocalId = _context.Webinars .FirstOrDefaultAsync((webinar) => webinar.Id == webinarPurchasedOptionsDetails.WebinarId).Result.LocalId; _context.WebinarPurchasedOptionsDetails.Add(webinarPurchasedOptionsDetails); var response = await _context.SaveChangesAsync(); return(response >= 1); } catch (DbUpdateException ex) { throw new DbUpdateException(ex.Message); } }
public async Task <bool> UpdateWebinarPurchasedOptionsDetails(WebinarPurchasedOptionsDetails webinarPurchasedOptionsDetails) { try { var modelToBeUpdated = _context.WebinarPurchasedOptionsDetails.FirstOrDefaultAsync(webinarPrice => webinarPrice.Id == webinarPurchasedOptionsDetails.Id).Result; modelToBeUpdated.MaxCount = webinarPurchasedOptionsDetails.MaxCount; modelToBeUpdated.MaxDuration = webinarPurchasedOptionsDetails.MaxDuration; modelToBeUpdated.Price = webinarPurchasedOptionsDetails.Price; _context.Entry(modelToBeUpdated).State = EntityState.Modified; var response = await _context.SaveChangesAsync(); return(response >= 1); } catch (DbUpdateException ex) { throw new DbUpdateException(ex.Message); } }