Example #1
0
        public async Task <ActionResult <RobotViewModel> > Post([FromBody] RobotViewModel robot)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var newRobot = await _robotService.CreateRobot(robot.Name, robot.Type);

            await _notificationHub.Clients.All.SendAsync("Notify", new Notification($"{robot.Name} (Robot) created!", SeverityLevel.Success));

            return(Ok(new RobotViewModel(newRobot)));
        }
        public async Task <bool> AddRobot([FromBody] List <Robot> robotList)
        {
            var result = true;

            foreach (var robot in robotList)
            {
                try
                {
                    await _service.CreateRobot(robot);
                }
                catch (CrewApiException exception)
                {
                    exception.LogException(_logger);
                    result = false;
                }
            }
Example #3
0
        public void CanCreateRobot()
        {
            var robot = _robotService.CreateRobot();

            Assert.IsTrue(robot.RobotId != Guid.Empty);
        }