Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }