コード例 #1
0
        public async Task <HttpResponseMessage> Post(CreateSubscriptionModel model)
        {
            // Create subscription
            CompanySubscription subscription = await _subscriptionService.AddAsync(UserId, model);

            Subscription        subscriptionResponse = _mapper.Map <CompanySubscription, Subscription>(subscription);
            HttpResponseMessage response             = Request.CreateResponse(HttpStatusCode.Created, subscriptionResponse);

            return(response);
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] SubscriptionPostRequestModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var subscription = _mapper.Map <Subscription>(model);
                subscription = await _subscriptionService.AddAsync(subscription, model.Password);

                return(Created(HttpContext.Request.QueryString.Value.TrimEnd('/') + "/" + subscription.UserId,
                               subscription));
            }
            catch (Exception e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ErrorModelInternalError(e)));
            }
        }
コード例 #3
0
 public async Task <IActionResult> PostSubscription([FromBody] SubscriptionDto value)
 {
     return(Ok(await _serviceReference.AddAsync(Mapper.Map <Subscription>(value))));
 }