Example #1
0
        public Planet Create(PlanetInputDto planetInput)
        {
            Planet newPlanet = _planetRepository.Create(new Planet(planetInput.Name, planetInput.Climate, planetInput.Terrain));

            _planetRepository.SaveChanges();

            newPlanet.ApparitionsInFilms = GetPlanetFromSwapi(newPlanet.Name);
            return(newPlanet);
        }
        public async Task <IActionResult> Create(Planet planetViewModel)
        {
            try
            {
                var planet = new Planet
                {
                    Name        = planetViewModel.Name,
                    Description = string.Empty,
                    ImageUrl    = planetViewModel.ImageUrl,
                    SolarSystem = planetViewModel.SolarSystem,
                    Status      = PlanetStatus.TODO
                };
                await _planetRepository.Create(planet);

                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }