Beispiel #1
0
        public async Task <IActionResult> PutEventRego(int id, EventRego eventRego)
        {
            if (id != eventRego.EventRegoId)
            {
                return(BadRequest());
            }

            _context.Entry(eventRego).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EventRegoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCoupon(int id, Coupon coupon)
        {
            if (id != coupon.CouponId)
            {
                return(BadRequest());
            }

            _context.Entry(coupon).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CouponExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #3
0
        public async Task <IActionResult> PutFacility(int id, Facility facility)
        {
            if (id != facility.FacilityId)
            {
                return(BadRequest());
            }

            _context.Entry(facility).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FacilityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
        public async Task CreateUserAsync(HubUser user, CancellationToken cancellationToken = default)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (await _dbContext.HubUsers.AnyAsync(u => u.Id == user.Id, cancellationToken))
            {
                throw new DuplicateNameException(nameof(user));
            }

            cancellationToken.ThrowIfCancellationRequested();

            await _dbContext.HubUsers.AddAsync(user, cancellationToken); // Seems silly to be async, but used in some SQL Server scenarios

            await _dbContext.SaveChangesAsync();
        }