public async Task <ActionResult <Manufacturer> > Post([FromBody] Manufacturer manufacturer) { try { await _manufacturerManager.Add(manufacturer); return(Ok(manufacturer)); } catch (Exception exception) { _logger.LogError($"Error occured during creating manufacturer. Exception: {exception.Message}"); return(BadRequest()); } }
public async Task <IActionResult> Create(ManufacturerViewModel manufacturerViewModel) { try { await _manufacturerManager.Add(_mapper.Map <ManufacturerViewModel, Manufacturer>(manufacturerViewModel)); return(RedirectToAction(nameof(Index))); } catch (Exception exception) { _logger.LogError($"Error occured during creating manufacturer. Exception: {exception.Message}"); return(View(manufacturerViewModel)); } }
public async Task Add() { var manufacturerDto = await CreateModel(); await _manufacturerManager.Add(manufacturerDto); }