Beispiel #1
0
        public async Task <RobotViewModel> Do(RobotViewModel vm)
        {
            var robot = _context.Robots.FirstOrDefault(x => x.RobotID == vm.RobotID);

            robot.Model        = vm.Model;
            robot.Function     = vm.Function;
            robot.MovementType = vm.MovementType;
            robot.Price        = vm.Price;


            await _context.SaveChangesAsync();

            return(new RobotViewModel
            {
                RobotID = robot.RobotID,
                Model = robot.Model,
                Function = robot.Function,
                MovementType = robot.MovementType,
                Price = robot.Price,
            });
        }
        public async Task <RobotViewModel> Do(RobotViewModel vm)
        {
            var robot = new Robot
            {
                Model        = vm.Model,
                Function     = vm.Function,
                MovementType = vm.MovementType,
                Price        = vm.Price
            };

            _context.Robots.Add(robot);
            await _context.SaveChangesAsync();

            return(new RobotViewModel
            {
                RobotID = robot.RobotID,
                Model = robot.Model,
                Function = robot.Function,
                MovementType = robot.MovementType,
                Price = robot.Price
            });
        }