Exemplo n.º 1
0
        public ActionResult Post([FromBody] Server server)
        {
            JsonValidationChecker jsonChecker = new JsonValidationChecker();

            // Check if the json is valid.
            if (!jsonChecker.IsValidServer(server))
            {
                return(new BadRequestResult());
            }

            Server myServer = this.serversManager.AddServer(server);

            if (myServer == Server.nullServer)
            {
                // An error has occured when trying to
                // add the server(id exists already).
                return(new BadRequestResult());
            }

            return(new OkObjectResult(myServer));
        }
Exemplo n.º 2
0
        public ActionResult Post([FromBody] FlightPlan flightPlan)
        {
            JsonValidationChecker jsonChecker = new JsonValidationChecker();

            // Check if the json file is valid.
            if (!jsonChecker.IsValidFlightPlan(flightPlan))
            {
                return(new BadRequestResult());
            }

            FlightPlan fp = this.flightPlanManager.AddFlightPlan(flightPlan);

            if (fp == FlightPlan.NullFlightPlan)
            {
                // There was error when trying to add the given flight plan.
                return(new BadRequestResult());
            }

            else
            {
                return(new OkObjectResult(fp));
            }
        }