public void TestInicialSubasta() { IDALUsuario iu = new DALUsuarioEF(); Usuario u = new Usuario { UsuarioID = "userPrueba" }; iu.AgregarUsuario(u, urlTest); u = new Usuario { UsuarioID = "otroUserPrueba" }; iu.AgregarUsuario(u, urlTest); }
public async Task <ActionResult> ExternalLoginCallback(string returnUrl) { var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) { return(RedirectToAction("Login")); } // Sign in the user with this external login provider if the user already has a login var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent : false); switch (result) { case SignInStatus.Success: IDALUsuario dalU = new DALUsuarioEF(); Usuario userChebay; try { userChebay = dalU.ObtenerUsuario(loginInfo.Email, Session["Tienda_Nombre"].ToString()); Session["Usuario"] = userChebay; } catch (Exception e) { userChebay = new Usuario { UsuarioID = loginInfo.Email, Email = loginInfo.Email }; try { Debug.WriteLine(e.Message); dalU.AgregarUsuario(userChebay, Session["Tienda_Nombre"].ToString()); Session["Usuario"] = userChebay; } catch (Exception e2) { Debug.WriteLine(e2.Message); ViewBag.ErrorMessage = e2.Message; return(View("Error")); } } if (userChebay != null) { } return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false })); case SignInStatus.Failure: default: // If the user does not have an account, then prompt the user to create an account ViewBag.ReturnUrl = returnUrl; ViewBag.LoginProvider = loginInfo.Login.LoginProvider; return(View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email })); } }
public async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Manage")); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await AuthenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("ExternalLoginFailure")); } var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user); if (result.Succeeded) { result = await UserManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { IDALUsuario dalU = new DALUsuarioEF(); Usuario userNuevo = new Usuario { UsuarioID = model.Email, Email = model.EmailNotification }; dalU.AgregarUsuario(userNuevo, Session["Tienda_Nombre"].ToString()); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return(View(model)); }