public async Task <int> UpdateCustomer(Customer customer) { sw.Start(); try { LoggingClass.LogServiceInfo("service called", "UpdateCustomer"); var uri = new Uri(ServiceURL + "UpdateCustomer/"); var content = JsonConvert.SerializeObject(customer); var cont = new StringContent(content, System.Text.Encoding.UTF8, "application/json"); string Token = CurrentUser.GetAuthToken(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Token); var response = await client.PostAsync(uri, cont); // In debug mode it do not work, Else it works LoggingClass.LogServiceInfo("service responce", "UpdateCustomer"); //var result = response.Content.ReadAsStringAsync().Result; } catch (Exception exe) { LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString()); } sw.Stop(); LoggingClass.LogTime("The total time to start and end the service UpdateCustomer", "The timer ran for " + sw.Elapsed.TotalSeconds); return(1); }
public async Task <CustomerResponse> UpdateMail(string email, string userid) { sw.Start(); CustomerResponse output = null; try { var uri = new Uri(ServiceURL + "UpdateEmailAddress/" + email + "/user/" + userid); var content = JsonConvert.SerializeObject(email); var cont = new StringContent(content, System.Text.Encoding.UTF8, "application/json"); string Token = CurrentUser.GetAuthToken(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Token); var response = await client.GetStringAsync(uri).ConfigureAwait(false); output = JsonConvert.DeserializeObject <CustomerResponse>(response); } catch (Exception ex) { LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace); } sw.Stop(); LoggingClass.LogServiceInfo("Service " + sw.Elapsed.TotalSeconds, "Email Update Service"); return(output); }
public async Task <CustomerResponse> ContinueService(CustomerResponse customer) { sw.Start(); CustomerResponse output = null; try { var uri = new Uri(ServiceURL + "ContinueClick/"); var content = JsonConvert.SerializeObject(customer); var cont = new StringContent(content, System.Text.Encoding.UTF8, "application/json"); string Token = CurrentUser.GetAuthToken(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Token); var response = await client.PostAsync(uri, cont).ConfigureAwait(false); if (response.IsSuccessStatusCode) { var tokenJson = await response.Content.ReadAsStringAsync(); output = JsonConvert.DeserializeObject <CustomerResponse>(tokenJson); } //var result = response.Content.ReadAsStringAsync().Result; } catch (Exception ex) { LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace); } sw.Stop(); LoggingClass.LogServiceInfo("Service " + sw.Elapsed.TotalSeconds, "Continue Service"); //Console.WriteLine("UpdateCustomer service Time Elapsed"+sw.Elapsed.TotalSeconds); return(output); }