예제 #1
0
        public async Task <int> Create(CreateMagazineViewModel item)
        {
            var createdItem   = Mapper.Map <CreateMagazineViewModel, Magazine>(item);
            int createdItemId = await _magazineRepository.Create(createdItem);

            return(createdItemId);
        }
예제 #2
0
        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));
        }
예제 #4
0
 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));
     }
 }