public async Task <IActionResult> EditUserDocumentation(UserDocumentationEditViewModel model) { if (ModelState.IsValid) { try { var obj = _db.ApplicationUser.FirstOrDefault(u => u.Id == model.Id); if (obj == null) { return(NotFound()); } DocumentationDtos objCertificationInformationDtos = new DocumentationDtos(); objCertificationInformationDtos.Id = model.Id; objCertificationInformationDtos.isDocumentationFill = true; if (model.CancellerdChequeImg != null && model.CancellerdChequeImg.Length > 0) { using (var ms = new MemoryStream()) { model.CancellerdChequeImg.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); objCertificationInformationDtos.CancellerdChequeImg = s; ms.Close(); } } if (model.Ceritification != null && model.Ceritification.Length > 0) { using (var ms = new MemoryStream()) { model.Ceritification.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); objCertificationInformationDtos.Ceritification = s; ms.Close(); } } if (model.CompanyRegCeritificate != null && model.CompanyRegCeritificate.Length > 0) { using (var ms = new MemoryStream()) { model.CompanyRegCeritificate.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); objCertificationInformationDtos.CompanyRegCeritificate = s; ms.Close(); } } if (model.VisitingCardImg != null && model.VisitingCardImg.Length > 0) { using (var ms = new MemoryStream()) { model.VisitingCardImg.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); objCertificationInformationDtos.VisitingCardImg = s; ms.Close(); } } if (model.aadharBackImg != null && model.aadharBackImg.Length > 0) { using (var ms = new MemoryStream()) { model.aadharBackImg.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); objCertificationInformationDtos.aadharBackImg = s; ms.Close(); } } if (model.aadharFrontImg != null && model.aadharFrontImg.Length > 0) { using (var ms = new MemoryStream()) { model.aadharFrontImg.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); objCertificationInformationDtos.aadharFrontImg = s; ms.Close(); } } if (model.pancardImg != null && model.pancardImg.Length > 0) { using (var ms = new MemoryStream()) { model.pancardImg.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); objCertificationInformationDtos.pancardImg = s; ms.Close(); } } #region "API CALL" string url = SD.APIBaseUrl + "user/UpdateUserDocumentation"; var request = new HttpRequestMessage(HttpMethod.Patch, url); if (objCertificationInformationDtos != null) { request.Content = new StringContent( JsonConvert.SerializeObject(objCertificationInformationDtos), Encoding.UTF8, "application/json"); } else { //return false; } var client = _clientFactory.CreateClient(); //if (token != null && token.Length != 0) //{ // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); //} HttpResponseMessage response = await client.SendAsync(request); if (response.StatusCode == System.Net.HttpStatusCode.NoContent || response.StatusCode == System.Net.HttpStatusCode.OK) { TempData["success"] = "Record Update successfully"; // return true; } else { TempData["error"] = "Record Not Update"; // return false; } #endregion // string path1 = SD.APIBaseUrl + "user/UpdateCertificationInformation"; //bool res = await _userRegistrationAPIRepository.UpdateAsync(path1, objCertificationInformationDtos); } catch { } var user = await _userManager.FindByIdAsync(model.Id); var roles = await _userManager.GetRolesAsync(user); //if (roles[0].ToString() == "Admin") if (model.loginType == "Admin") { return(RedirectToAction(nameof(Index))); } else { return(RedirectToAction("Profile", "UserLogin", new { area = "Admin", id = model.Id })); } } else { return(View(model)); } }