Exemplo n.º 1
0
        //Create new machine
        public async Task <bool> CreateMachine(MachineCreate model)
        {
            Machine machine =
                new Machine()
            {
                MachineName = model.MachineName,
                Active      = true,
                AreaId      = model.AreaId
            };

            _context.Machines.Add(machine);
            return(await _context.SaveChangesAsync() == 1);
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> CreateMachine(MachineCreate machine)
        {
            //Check if model is valid
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState)); //404
            }

            //Instantiate service
            MachineService service = CreateMachineService();

            if (await service.CreateMachine(machine) == false)
            {
                return(InternalServerError());
            }

            return(Ok()); //200
        }