コード例 #1
0
        /// <summary>
        /// Add a DimDatatype object to the remote database.
        /// </summary>
        /// <param name="dimDatatype"> The dimdatatype to be added</param>
        /// <returns></returns>
        public async Task PostDimDatatypeAsync(DimDatatype dimDatatype)
        {
            var client = new HttpClient();

            var         json    = JsonConvert.SerializeObject(dimDatatype);
            HttpContent content = new StringContent(json);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            content.Headers.Add("ZUMO-API-VERSION", "2.0.0");

            var response = await client.PostAsync(Constants.BaseApiAddress + "api/dimdatatype", content);

            //Debug.WriteLine(response.Content);
        }
コード例 #2
0
        public async Task <IHttpActionResult> PostAsync(DimDatatype item)
        {
            try
            {
                context.DimDatatypes.Add(item);
                await context.SaveChangesAsync();

                return(StatusCode(HttpStatusCode.Created));
            }
            catch (System.Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }
        }