public IActionResult PostEngine([FromBody] PostEngine model)
        {
            if (ModelState.IsValid)
            {
                var command = new AddEngine(model.Name, model.Power, model.Torque, model.Cylinders, model.Displacement, model.FuelType);
                commandBus.AddCommand(command);
                commandBus.InvokeCommandsQueue();

                var result = GetEngineDetails(command.Id);
                return(CreatedAtRoute(
                           "GetEngine",
                           new { engineId = command.Id },
                           result
                           ));
            }

            return(BadRequest(ModelState));
        }
Example #2
0
        public IActionResult CreateUser([FromBody] PostUser model)
        {
            if (ModelState.IsValid)
            {
                var command = new AddUser(model.Email, model.Password);
                commandBus.AddCommand(command);
                commandBus.InvokeCommandsQueue();

                var result = GetUserDetails(command.Id);

                return(CreatedAtRoute(
                           "GetUser",
                           new { userEmail = command.Email },
                           result.Data
                           ));
            }

            return(BadRequest(ModelState));
        }
        public IActionResult PostManufacturer([FromBody] PostManufacturer model)
        {
            if (ModelState.IsValid)
            {
                var command = new AddManufacturer(model.Name, model.ModelsNames);
                commandBus.AddCommand(command); commandBus.InvokeCommandsQueue();

                var result = GetManufacturerDetails(command.Id);
                return(CreatedAtRoute(
                           "GetManufacturer",
                           new { manufacturerId = command.Id },
                           result
                           ));
            }

            return(BadRequest(ModelState));
        }
        public IActionResult PostVehicle([FromBody] PostNewVehicle model)
        {
            if (ModelState.IsValid)
            {
                var command = new AddVehicle(model.ModelId, new Guid()); //TODO: Retrieve current user id
                commandBus.AddCommand(command);
                commandBus.InvokeCommandsQueue();

                var result = GetVehicleDetails(command.Id);

                return(CreatedAtRoute(
                           "GetVehicle",
                           new { vehicleId = command.Id },
                           result
                           ));
            }

            return(BadRequest(ModelState));
        }