示例#1
0
        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 }));
        }
示例#2
0
        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());
        }