public List <Doctolib> getListDoctorsBySpecialityAndLocation(string speciality, string location, string page) { List <Doctolib> lst = new List <Doctolib>(); Doctolib doctor; if (location == null) { location = "france"; } if (page == null) { page = "0"; } if (speciality == null) { speciality = "medecin-generaliste"; } HtmlWeb web = new HtmlWeb(); HtmlDocument doc; try { doc = web.Load("https://www.doctolib.fr/" + speciality + "/" + location + "?page=" + page); } catch { try { doc = web.Load("https://www.doctolib.fr/" + speciality + "/france?page=" + page); } catch { doc = web.Load("https://www.doctolib.fr/medecin-generaliste/france?page=" + page); } } var Names = doc.DocumentNode.SelectNodes("//a[@class='dl-search-result-name js-search-result-path']/div").ToList(); var Specialties = doc.DocumentNode.SelectNodes("//div[@class='dl-search-result-subtitle']").ToList(); var Address = doc.DocumentNode.SelectNodes("//div[@class='dl-text dl-text-body']").ToList(); HtmlNodeCollection Images = doc.DocumentNode.SelectNodes("//img[@src]"); HtmlNodeCollection Paths = doc.DocumentNode.SelectNodes("//a[@class='dl-search-result-name js-search-result-path']"); for (var i = 0; i < Names.LongCount(); i++) { HtmlAttribute pathDoctor = Paths[i].Attributes["href"]; HtmlAttribute src = Images[i].Attributes["src"]; doctor = new Doctolib() { name = Names[i].InnerText.Replace("'", "'"), img = src.Value, speciality = Specialties[i].InnerText.Replace("'", "'"), address = Address[i].InnerText.Replace("'", "'"), path = pathDoctor.Value }; lst.Add(doctor); } return(lst); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new Doctor { UserName = model.Email, doctolib = 0, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, specialityDocotor = model.specialityDocotor, rpps = model.RPPS, Role = "Doctor", status = 0, address = model.address }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { if (serviceDoctolib.RegisterWithDoctolib(user.FirstName + " " + user.LastName, user.specialityDocotor, user.rpps)) { user.status = 1; Doctolib doc = serviceDoctolib.getDoctorByPath(serviceDoctolib.getPath(user.FirstName + " " + user.LastName, user.specialityDocotor, user.rpps)); user.address = doc.address; user.Img = doc.img; user.doctolib = 1; } user.LockoutEnabled = false; await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); await this.UserManager.AddToRoleAsync(user.Id, "Doctor"); return(RedirectToAction("Login", "Account")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }