/// <summary> /// Update subscription data /// </summary> /// <param name="id"></param> /// <param name="subscription"></param> /// <returns></returns> public HttpResponseMessage Put(int id, [FromBody] Models.SubscriptionSubmission subscription) { var model = new SubscriptionService.Subscription { Name = subscription.Name, PriceIncVatAmount = subscription.Price, Price = subscription.Price, CallMinutes = subscription.Callminutes }; using (var client = new SubscriptionServiceClient()) { var result = client.GetById(id); if (result == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Subscription id is not found")); } model.Identifier = result.Identifier; model.Id = result.Id; client.Put(model); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage Post([FromBody] Models.SubscriptionSubmission subscription) { var model = new SubscriptionService.Subscription { Name = subscription.Name, PriceIncVatAmount = subscription.Price, Price = subscription.Price, CallMinutes = subscription.Callminutes }; using (var client = new SubscriptionServiceClient()) { var subscriptionId = client.Create(model); var response = Request.CreateResponse(HttpStatusCode.Created); var uri = Url.Link("SubscriptionApi", new { id = subscriptionId }); response.Headers.Location = new Uri(uri); return(response); } return(Request.CreateResponse(HttpStatusCode.OK)); }