public IActionResult AddPlanet([FromBody] Planet planet)
 {
     try
     {
         planetLogic.AddPlanet(planet);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(StatusCode(500, $"Internal server error : {ex}"));
     }
 }
Esempio n. 2
0
        public void TestAdd()
        {
            Mock <IRepository <Planet> >        planetRepo = new Mock <IRepository <Planet> >();
            Mock <IRepository <Star> >          starRepo   = new Mock <IRepository <Star> >();
            Mock <IRepository <Models.System> > systemRepo = new Mock <IRepository <Models.System> >();

            planetRepo.Setup(r => r.Add(It.IsAny <Planet>()));
            PlanetLogic logic = new PlanetLogic(planetRepo.Object, starRepo.Object, systemRepo.Object);

            logic.AddPlanet(new Planet());

            planetRepo.Verify(r => r.Add(It.IsAny <Planet>()), Times.Once);
        }
Esempio n. 3
0
        public IActionResult AddPlanet(Planet p)
        {
            p.PlanetID = Guid.NewGuid().ToString();

            planetLogic.AddPlanet(p);
            return(RedirectToAction(nameof(ListPlanet)));
        }