public UserSelfAdministrationLibrary(HttpContext context, Session session) { this.UserID = session.UserID; var res = DIResolver.Data.NinjectConfig.GetKernal().Get <Data.RepositoryInterfaces.IUserRepository>(); Data.Entities.UserEntity user = res.GetUser(this.UserID); this.Email = user.Email; }
public async Task <IActionResult> Create() { Data.Entities.UserEntity usuario = await _userHelper.GetUserAsync(User.Identity.Name); var cotizacion = new CotizacionViewModel() { FechaCotizacion = DateTime.UtcNow, Estados = Common.Enums.Estados.Tramite, UserId = Guid.Parse(usuario.Id), NombreProveedor = usuario.FullName, Detalle = new List <CotizacionDetalleEntity>() }; return(View(cotizacion)); }
public async Task <IActionResult> ChangeUser() { Data.Entities.UserEntity user = await _userHelper.GetUserAsync(User.Identity.Name); EditUserViewModel model = new EditUserViewModel { Address = user.Address, Document = user.Document, FirstName = user.FirstName, LastName = user.LastName, PhoneNumber = user.PhoneNumber, PicturePath = user.PicturePath, }; return(View(model)); }
public async Task <IActionResult> Register(AddUserViewModel model) { if (ModelState.IsValid) { string path = string.Empty; if (model.PictureFile != null) { path = await _imageHelper.UploadImageAsync(model.PictureFile, "Users"); } Data.Entities.UserEntity user = await _userHelper.AddUserAsync(model, path); if (user == null) { ModelState.AddModelError(string.Empty, "This email is already used."); model.UserTypes = _combosHelper.GetComboRoles(); return(View(model)); } string myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user); string tokenLink = Url.Action("ConfirmEmail", "Account", new { userid = user.Id, token = myToken }, protocol: HttpContext.Request.Scheme); Common.Models.Response response = _mailHelper.SendMail(model.Username, "Email confirmation", $"<h1>Email Confirmation</h1>" + $"To allow the user, " + $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>"); if (response.IsSuccess) { ViewBag.Message = "The instructions to allow your user has been sent to email."; return(View(model)); } ModelState.AddModelError(string.Empty, response.Message); } model.UserTypes = _combosHelper.GetComboRoles(); return(View(model)); }
public async Task <IActionResult> Register(AddUserViewModel model) { if (ModelState.IsValid) { string path = string.Empty; if (model.PictureFile != null) { path = await _imageHelper.UploadImageAsync(model.PictureFile, "User"); } Data.Entities.UserEntity user = await _userHelper.AddUserAsync(model, path); if (user == null) { ModelState.AddModelError(string.Empty, "This email is already used."); model.UserTypes = _combosHelper.GetComboRoles(); return(View(model)); } else { return(RedirectToAction("Index", "UserCreated")); } /* * LoginViewModel loginViewModel = new LoginViewModel * { * Password = model.Password, * RememberMe = false, * Username = model.Username * }; * * Microsoft.AspNetCore.Identity.SignInResult result2 = await _userHelper.LoginAsync(loginViewModel); * * if (result2.Succeeded) * { * return RedirectToAction("Index", "Home"); * }*/ } model.UserTypes = _combosHelper.GetComboRoles(); return(View(model)); }
public ViewModels.UserDashboardViewModel GetUserDashboardInformation() { CurrencyLibrary cLib = new CurrencyLibrary(); CountryLookup cLook = new CountryLookup(); var res = DIResolver.Data.NinjectConfig.GetKernal().Get <Data.RepositoryInterfaces.IUserRepository>(); Data.Entities.UserEntity user = res.GetUser(this.UserID); return(new ViewModels.UserDashboardViewModel { UserName = this.UserID, AutoUpdateTrackerDefault = user.AutoUpdateEntries, DefaultCountry = (user.DefaultCountry) ?? "", DefaultCurrencyFrom = user.DefaultCurrencyFrom, DefaultCurrencyTo = (user.DefaultCurrencyTo) ?? "", DisplayName = user.DisplayName, Email = user.Email, Countries = cLook.GetSelectList(), Currencies = cLib.CurrencyFromSelect, CurrenciesTo = cLib.GetAllowedCurrenciesSelect((user.DefaultCurrencyFrom) ?? "") }); }
public async Task <IActionResult> Register(AddUserViewModel model) { if (ModelState.IsValid) { string path = string.Empty; if (model.PictureFile != null) { path = await _imageHelper.UploadImageAsync(model.PictureFile, "Users"); } Data.Entities.UserEntity user = await _userHelper.AddUserAsync(model, path); if (user == null) { ModelState.AddModelError(string.Empty, "Este correo ya se encuentra registrado."); model.UserTypes = _combosHelper.GetComboRoles(); return(View(model)); } var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user); var tokenLink = Url.Action("ConfirmEmail", "Account", new { userid = user.Id, token = myToken }, protocol: HttpContext.Request.Scheme); var response = _mailHelper.SendMail(model.Username, "Confirmación de correo electrónico", $"<h1>Correo de confirmación</h1>" + $"Para permitir al usuario, " + $"Por favor presione click en este enlace:" + $"</br></br><a href = \"{tokenLink}\">Confirmar Email</a>"); if (response.IsSuccess) { ViewBag.Message = "Se han enviado las instrucciones al correo."; return(View(model)); } ModelState.AddModelError(string.Empty, response.Message); LoginViewModel loginViewModel = new LoginViewModel { Password = model.Password, RememberMe = false, Username = model.Username }; Microsoft.AspNetCore.Identity.SignInResult result2 = await _userHelper.LoginAsync(loginViewModel); if (result2.Succeeded) { return(RedirectToAction("Index", "Home")); } } model.UserTypes = _combosHelper.GetComboRoles(); return(View(model)); }