示例#1
0
        public async Task <IActionResult> Create([Bind] TeamMappingResponse teamMappingResponse)
        {
            ResponseTeamMappingDTO responseTeamMember = new ResponseTeamMappingDTO
            {
                CreatedBy    = teamMappingResponse.CreatedBy,
                DistrictCode = teamMappingResponse.DistrictCode,
                MappingId    = teamMappingResponse.MappingId,
                TeamMemberId = teamMappingResponse.TeamMemberId
            };

            string url = $"{CoreApiUrl}ResponseTeamMappings/Add";

            var accessToken = await HttpContext.GetTokenAsync("access_token");

            var response = await HttpRequestFactory.Post(accessToken, url, responseTeamMember);

            if (response.StatusCode == HttpStatusCode.Created)
            {
                AppContextHelper.SetToastMessage("Response team member has been successfully mapped", MessageType.Success, 1, Response);
                return(RedirectToAction(nameof(Index), new { teamMemberId = _teamMemberId, teamMemberName = _teamMemberName }));
            }
            else
            {
                AppContextHelper.SetToastMessage("Failed to map response team member", MessageType.Danger, 1, Response);
                ModelState.AddModelError("", HttpResponseHandler.Process(response));
            }
            ViewBag.TeamMemberName = _teamMemberName;
            return(View(teamMappingResponse));
        }
示例#2
0
        private async Task <TeamMappingResponse> getResponseTeamMapping(int mappingId)
        {
            string url = $"{CoreApiUrl}ResponseTeamMappings/GetById?mappingId={mappingId}";
            var    responseTeamMember = new TeamMappingResponse();

            var accessToken = await HttpContext.GetTokenAsync("access_token");

            var response = await HttpRequestFactory.Get(accessToken, url);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                responseTeamMember = response.ContentAsType <TeamMappingResponse>();
            }
            else
            {
                ModelState.AddModelError("", HttpResponseHandler.Process(response));
            }
            return(responseTeamMember);
        }