Esempio n. 1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id, Action, ActionName, IsCompleted, DeviceName")] Code code)
        {
            if (id != code.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(code));
            }
            try
            {
                await _repository.UpdateAsync(id, code);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await _repository.ContainsAsync(code.Id))
                {
                    return(NotFound());
                }
                throw;
            }
            Guid deviceId = await GetDeviceIdAsync(id);

            return(RedirectToAction(nameof(Index), new { deviceId }));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutCode([FromRoute] Guid id, [FromBody] Code code)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!await _repository.UpdateAsync(id, code))
            {
                return(NoContent());
            }
            return(Ok());
        }