Пример #1
0
 public IHttpActionResult addPlanet(PlanetDTO planet) {
     if(ModelState.IsValid) {
         return Ok(_planetService.AddPlanet(new PlanetDTO() {
             Name = planet.Name,
             Distance = planet.Distance
         }));
     }
     return BadRequest();
 }
Пример #2
0
        public PlanetDTO AddPlanet(PlanetDTO dto) {
            var planet = new Planet() {
                Name = dto.Name,
                Distance = dto.Distance
            };

            _planetRepo.Add(planet);
            _planetRepo.SaveChanges();

            return new PlanetDTO() {
                Name = planet.Name,
                Distance = planet.Distance
            };
        }