public Responce createUser(HttpListenerRequest request)
        {
            User user = parseUser(request);

            userRepository.createUser(user);

            return(Responce.ok((UserPlane)user));
        }
Exemple #2
0
        public Responce getAnimals(HttpListenerRequest request)
        {
            foreach (Consuming animal in DB.animals)
            {
                animal.calculateFeedDate();
            }

            return(Responce.ok(DB.getAnimals()));
        }
        public Responce setAnimalOnUser(HttpListenerRequest request)
        {
            string animalAsString = RequestBodyParser.parse(request.InputStream, request.ContentEncoding);
            Animal animal         = JsonConvert.DeserializeObject <Animal>(animalAsString);

            User user = userRepository.setAnimalOnUser(Int32.Parse(request.QueryString["userId"]), animal);

            return(Responce.ok((UserPlane)user));
        }
Exemple #4
0
        public Responce getAppointedUser(HttpListenerRequest request)
        {
            Animal animal = parseAnimal(request);

            User user = userRepository.findOneByAnimal(animal);

            if (user != null)
            {
                return(Responce.ok((UserPlane)user));
            }

            return(Responce.notFound());
        }
Exemple #5
0
        public Responce feedToday(HttpListenerRequest request)
        {
            Animal animal = parseAnimal(request);

            User user = userRepository.findOneByAnimal(animal);

            if (user != null)
            {
                user.feedTheAnimal(animal);
                return(Responce.ok(user));
            }

            return(Responce.notFound());
        }
 public Responce getUsers(HttpListenerRequest request)
 {
     return(Responce.ok(userRepository.getUsers()));
 }