public async Task <ActionResult> GetUser(string userID) { NBKUser user = new NBKUser(); using (var client = new HttpClient()) { string url = string.Format("{0}/api/Login/GetUser/{1}", _servicePath, userID); client.BaseAddress = new Uri(_serviceURL); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(url); if (response.IsSuccessStatusCode) { user = await response.Content.ReadAsAsync <NBKUser>(); return(Content(JsonConvert.SerializeObject(user))); } else { HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Content("Invalid user")); } } }
public IHttpActionResult GetUser(string userID) { NBKUser user = null; using (var context = new EASEntities()) { string searchBy = string.Format("RACF\\{0}", userID); V_User_Logins loginDetails = context.V_User_Logins.Where(x => x.AssociatedAccount == searchBy).FirstOrDefault(); if (loginDetails != null) { user = new NBKUser(); user.UserID = userID; user.PartyID = loginDetails.PartyID; user.Name = loginDetails.NameEnglish; } } return(Json(user)); }