public async Task Update() { Console.WriteLine("Enter Id of characteristic to update"); var id = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException()); var characteristicDto = await CreateModel(); characteristicDto.Id = id; await _characteristicManager.Update(characteristicDto); }
public async Task <ActionResult <Characteristic> > Put([FromBody] Characteristic characteristic) { try { await _characteristicManager.Update(characteristic); return(Ok(characteristic)); } catch (Exception exception) { _logger.LogError($"Error occured during editing characteristic. Exception: {exception.Message}"); return(BadRequest()); } }
public async Task <ActionResult> Edit(CharacteristicViewModel characteristicViewModel) { try { await _characteristicManager.Update(new Characteristic { Id = characteristicViewModel.Id, CategoryId = characteristicViewModel.CategoryId, Name = characteristicViewModel.Name }); return(RedirectToAction(nameof(Index))); } catch (Exception exception) { _logger.LogError($"Error occured during editing characteristic. Exception: {exception.Message}"); characteristicViewModel.CategoriesSelectList = new SelectList(await _categoryManager.GetAll(), "Id", "Name"); return(View(characteristicViewModel)); } }