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);
        }
Exemplo n.º 2
0
        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());
            }
        }
Exemplo n.º 3
0
        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));
            }
        }