コード例 #1
0
        public async Task <IActionResult> PostAsync(int partnerId, [FromBody] SavePromoResource resource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            var promo = _mapper.Map <SavePromoResource, Promo>(resource);

            promo.PartnerId = partnerId;
            var result = await _promoService.SaveAsync(promo);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            var promoResource = _mapper.Map <Promo, PromoResource>(result.Resource);

            return(Ok(promoResource));
        }