Esempio n. 1
0
        // Post
        public async Task <string> AddNewProjectAsync(ApiProjectSubmitVm model)
        {
            string uri = this.config.UrlProjectConection + "/Post";
            // string uri = this.config.UrlProjectConection + "/CreateSubmit";

            var jsonQuery = JsonConvert.SerializeObject(model);

            var contentSend = new StringContent(jsonQuery, Encoding.UTF8, "application/json");

            HttpResponseMessage response = null;
            var mes = "";

            try
            {
                // --> Api -> Project-> [HttpPost]Post
                // "https://localhost:5001/Project"
                response = await httpClient.PostAsync(uri, contentSend);

                var content = response.Content;
                response.EnsureSuccessStatusCode();
                string result = content.ReadAsStringAsync().Result;

                mes = JsonConvert.DeserializeObject <string>(result);
            }
            catch (Exception ex)
            {
                mes = ex.Message;
            }
            return(mes);
        }
Esempio n. 2
0
        public string Post([FromBody] ApiProjectSubmitVm model)
        {
            var res = apiService.AddNewProjectAsync(model).Result;

            return(res);
        }