Example #1
0
        public AnimalModel Post([FromBody] NewAnimalModel value)
        {
            var result = new AnimalModel(value.Name);

            _animals.Add(result);

            return(result);
        }
Example #2
0
        public AnimalModel Put(Guid id, [FromBody] NewAnimalModel value)
        {
            var model = _animals.FirstOrDefault(x => x.Id == id);

            if (model == null)
            {
                throw new Exception("Id not found");
            }

            model.Name = value.Name;
            return(model);
        }