예제 #1
0
        public async Task <ActionResult <List <CommodityViewModel> > > Post([FromBody] CommodityAddOrUpdateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequestWithModelStateErrors());
            }
            var entity = _mapper.Map <Commodity>(model);
            await _commodityRepository.AddAsync(entity);

            _commodityRepository.Entiry(entity).Reference(x => x.Unit).Load();
            return(Ok(_mapper.Map <CommodityViewModel>(entity)));
        }