public async Task <IActionResult> TeamMembersForAdmin(bool isDeleteFailed, string error) { var user = await StaticDataHandler.GetSessionDetails(); var requestUrl = $"{BaseUrl}{apiUriTeamMembers}/GetTeamMembersForAdmin"; TeamMembersVM teamMembers = new TeamMembersVM(_configuration); using (var client = new HttpClient()) { client.BaseAddress = new Uri(requestUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", user.Token); HttpResponseMessage response = await client.GetAsync(requestUrl); OutputHandler outputHandler = new OutputHandler(); if (response.StatusCode == HttpStatusCode.OK) { if (isDeleteFailed) //This is coming from delete function if anything wrong happens there, throw error { outputHandler.IsErrorOccured = true; outputHandler.Message = "Delete failed! Something went wrong, please contact techarch team"; } else { outputHandler.IsErrorOccured = false; } teamMembers.OutputHandler = outputHandler; teamMembers.TeamMembersDTO = await response.Content.ReadAsAsync <IEnumerable <TeamMembersDTO> >(); } else if (response.StatusCode == HttpStatusCode.Unauthorized) { teamMembers.OutputHandler.IsErrorOccured = true; teamMembers.OutputHandler.Message = "You're not Authorized to perfom this task"; } else { outputHandler.IsErrorOccured = false; }; }; //teamMembers.Branches = await StaticDataHandler.GetTeamMemberCategory(BaseUrl); return(View(teamMembers)); }
public async Task <IActionResult> TeamMembers() { var requestUrl = $"{BaseUrl}{apiUriTeamMembers}/GetTeamMembers"; TeamMembersVM teamMembers = new TeamMembersVM(_configuration); using (var client = new HttpClient()) { client.BaseAddress = new Uri(requestUrl); HttpResponseMessage response = await client.GetAsync(requestUrl); if (response.StatusCode == HttpStatusCode.OK) { teamMembers.TeamMembersDTO = await response.Content.ReadAsAsync <IEnumerable <TeamMembersDTO> >(); } ; }; teamMembers.BranchDTO = await StaticDataHandler.GetBranches(BaseUrl); return(View(teamMembers)); }