示例#1
0
        public async Task <IActionResult> PutUser(int Id, User user)
        {
            if (!userRepository.isUserAdmin(GetUserId()))
            {
                return(BadRequest(new { isAdmin = "User does not have Admin priviledges!" }));
            }

            user.Id = Id;

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <ActionResult <Reservation> > DeleteReservation(int Id)
        {
            var reservation = await _context.Reservations.FindAsync(Id);

            if (reservation == null)
            {
                return(NotFound());
            }

            _context.Reservations.Remove(reservation);
            await _context.SaveChangesAsync();

            return(reservation);
        }
示例#3
0
        public async Task <IActionResult> PutCar(int Id, Car car)
        {
            car.Id = Id;

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

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

            return(NoContent());
        }