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); }
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))); } }
public async Task <IActionResult> PostSubscription([FromBody] SubscriptionDto value) { return(Ok(await _serviceReference.AddAsync(Mapper.Map <Subscription>(value)))); }