Пример #1
0
        public async Task <IActionResult> DeleteRoomService(int id)
        {
            var currentUserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            if (currentUserId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var roomServiceFromRepo = await _repo.GetRoomService(id);

            _repo.Delete(roomServiceFromRepo);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            throw new Exception("Failed to delete the Room Service");
        }