public async Task <IActionResult> PutPokoj(int id, Pokoj pokoj)
        {
            /*
             * if (id != pokoj.Nr_Pokoju)
             * {
             *  return BadRequest();
             * }
             */

            pokoj.Nr_Pokoju             = id;
            _context.Entry(pokoj).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                if (!PokojExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest(e.Message + "\n" + e.StackTrace));
                }
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PutRole(int id, Role role)
        {
            if (id != role.RoleId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutStandard(int id, Standard standard)
        {
            if (id != standard.StandardPokoju)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #4
0
        public async Task <IActionResult> PutRezerwacja(int id, Rezerwacja rezerwacja)
        {
            /*
             * if (id != rezerwacja.Id_Rezerwacji)
             * {
             *  return BadRequest();
             * }
             */

            rezerwacja.Id_Rezerwacji         = id;
            _context.Entry(rezerwacja).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                if (!RezerwacjaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest(e.Message + "\n" + e.StackTrace));
                }
            }

            return(NoContent());
        }
Exemple #5
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.UserId)
            {
                return(BadRequest());
            }

            Role role = _context.Roles.Find(user.RoleId);

            if (role == null || role.Rights.HasFlag(Role.AccessRights.IsCustomer))
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #6
0
        public async Task <IActionResult> PutTransaction(int id, [FromBody] Transaction transaction)
        {
            if (id != transaction.TransactionId || !ValidTransaction(transaction).Result || !ModelState.IsValid)
            {
                return(BadRequest());
            }

            transaction.Cost = (transaction.CheckOutTime - transaction.CheckInTime).Days * GetRoomCost(transaction.RoomId).Result.Value;

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

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

            return(NoContent());
        }
Exemple #7
0
        public async Task <IActionResult> PutKlient(int id, Klient klient)
        {
            klient.Id_Klient             = id;
            _context.Entry(klient).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                if (!KlientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest(e.Message + "\n" + e.StackTrace));
                }
            }

            return(NoContent());
        }