public TPFAuthenticationSoapClient(EndpointConfiguration endpointConfiguration) : base(TPFAuthenticationSoapClient.GetBindingForEndpoint(endpointConfiguration), TPFAuthenticationSoapClient.GetEndpointAddress(endpointConfiguration)) { this.Endpoint.Name = endpointConfiguration.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }
public TPFAuthenticationSoapClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) : base(TPFAuthenticationSoapClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) { this.Endpoint.Name = endpointConfiguration.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }
public async Task <IActionResult> Create([Bind("Id,UserName,FirstName,LastName,Profil,IsActive")] ListUsers listUsers) { try { TPFAuthenticationSoapClient.EndpointConfiguration endpointConfiguration = new TPFAuthenticationSoapClient.EndpointConfiguration(); TPFAuthenticationSoapClient servAuth = new TPFAuthenticationSoapClient(endpointConfiguration); if ((Boolean)TempData["isValid"] == false) { IdentityUser u = await userManager.FindByNameAsync(listUsers.UserName); if (u != null) { ViewBag.IsValid = false; ModelState.AddModelError(string.Empty, "Ce Compte existe déja"); } else { GetEmployeeByLoginResponseGetEmployeeByLoginResult x = await servAuth.GetEmployeeByLoginAsync(configuration.GetSection("MySettings").GetSection("login").Value, configuration.GetSection("MySettings").GetSection("pwd").Value, listUsers.UserName); if (x != null) { System.Xml.Linq.XElement b = x.Any1; ViewBag.Result1 = b.Descendants("employee_common_name").First().Value; ViewBag.IsValid = true; listUsers.Id = b.Descendants("employee_ident").First().Value; listUsers.FirstName = b.Descendants("employee_first_name").First().Value; listUsers.LastName = b.Descendants("employee_last_name").First().Value; //listUsers.FullName = b.Descendants("employee_common_name").First().Value; //listUsers.Email = b.Descendants("email1").First().Value; return(View(listUsers)); } else { Tools.Log(listUsers.UserName); ViewBag.IsValid = false; ModelState.AddModelError(string.Empty, "Compte Inexistant!"); //return View(user); } } } else { ListUsers myuser = new ListUsers { UserName = listUsers.UserName, Email = listUsers.Email, Id = listUsers.Id, FirstName = listUsers.FirstName, LastName = listUsers.LastName }; await userManager.CreateAsync(myuser); await userManager.AddToRoleAsync(myuser, "Manager"); Tools.Historique(User.Identity.Name, "Creation d'utilisateur", "Success", "", myuser.UserName); return(RedirectToAction(nameof(Index))); } return(View(listUsers)); } catch (Exception ex) { Tools.Log("UsersController, Post Create, Utilisateur (" + User.Identity.Name + ") : " + ex.ToString()); TempData["errorMessage"] = "Impossible de creer l'utilisateur"; return(RedirectToAction(nameof(Create))); } }