Exemple #1
0
        public async Task <ActionResult <Characteristic> > Post([FromBody] Characteristic characteristic)
        {
            try
            {
                await _characteristicManager.Add(characteristic);

                return(Ok(characteristic));
            }
            catch (Exception exception)
            {
                _logger.LogError($"Error occured during creating characteristic. Exception: {exception.Message}");
                return(BadRequest());
            }
        }
Exemple #2
0
        public async Task <ActionResult> Create(CharacteristicViewModel characteristicViewModel)
        {
            try
            {
                await _characteristicManager.Add(_mapper.Map <CharacteristicViewModel, Characteristic>(characteristicViewModel));

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception exception)
            {
                _logger.LogError($"Error occured during creating characteristic. Exception: {exception.Message}");
                characteristicViewModel.CategoriesSelectList = new SelectList(await _categoryManager.GetAll(), "Id", "Name");
                return(View(characteristicViewModel));
            }
        }
        public async Task Add()
        {
            var characteristicDto = await CreateModel();

            await _characteristicManager.Add(characteristicDto);
        }