示例#1
0
        public async Task <(bool, ModelStateDictionary)> UpdateAsync(PlayerUpdReqM playerUpdReqM, ModelStateDictionary modelStateDictionary)
        {
            string playerUpdReqMAsString = JsonConvert.SerializeObject(playerUpdReqM);

            StringContent stringContent = new StringContent(playerUpdReqMAsString, Encoding.UTF8, "application/json");

            (string updateResp, string errorMessage) = await httpClientManager.PutAsync <string>(endpointOptions?.Value.Endpoint, stringContent);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                modelStateDictionary.AddModelError("Player", _Failed_ToUpdatePlayer);
            }

            return(string.IsNullOrEmpty(updateResp), modelStateDictionary);
        }
        public async Task <IActionResult> Edit(EditPlayerVM editPlayerVM)
        {
            if (ModelState.IsValid)
            {
                PlayerUpdReqM playerUpdReqM = mapper.Map <EditPlayerVM, PlayerUpdReqM>(editPlayerVM);

                (bool success, ModelStateDictionary modelStateDictionary) = await playersServiceManager.UpdateAsync(playerUpdReqM, ModelState);

                if (modelStateDictionary.IsValid)
                {
                    return(RedirectToAction("Index"));
                }
            }

            return(RedirectToAction("Index", ModelState));
        }