public async Task <IActionResult> Create(Guid deviceId, Guid id, [Bind("Action,ActionName,DeviceName")] Code code) { if (!ModelState.IsValid) { return(View(code)); } await _repository.AddAsync(code, await GetDeviceAsync(deviceId)); return(RedirectToAction("Index", new { deviceId })); }
public async Task <IActionResult> PostCode([FromBody] CodeDevice codeDevice) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!await _repository.AddAsync(codeDevice.code, await GetDeviceAsync(codeDevice.deviceId))) { return(BadRequest()); } return(Ok()); }