public async Task <int> Create(CreateMagazineViewModel item) { var createdItem = Mapper.Map <CreateMagazineViewModel, Magazine>(item); int createdItemId = await _magazineRepository.Create(createdItem); return(createdItemId); }
public void Create(CreateMagazineViewModel magazineViewModel) { var magazine = new Magazine() { Id = magazineViewModel.Id, Name = magazineViewModel.Name, Number = magazineViewModel.Number, YearOfPublication = magazineViewModel.YearOfPublication }; _magazineRepository.Create(magazine); }
public async Task <IActionResult> Create([FromBody] CreateMagazineViewModel itemVM) { if (itemVM == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } int newItemId = await _service.Create(itemVM); itemVM.Id = newItemId; return(Ok(itemVM)); }
public IActionResult Create([FromBody] CreateMagazineViewModel magazine) { try { _magazineService.Create(magazine); return(Ok(magazine)); } catch (BusinessLogicException exception) { return(BadRequest(exception.Message)); } catch (Exception exception) { _logger.LogInformation(exception.Message); return(StatusCode((int)HttpStatusCode.InternalServerError)); } }