public MichtavaResult Update(Student student) { if (student.ApplicationUser == null) { return(new MichtavaFailure("must attach ApplicationUser.")); } if (student.ApplicationUser.UserName == null || student.ApplicationUser.UserName == "") { return(new MichtavaFailure("חובה להזין שם משתמש.")); } if (userRepository.Get(sc => sc.UserName == student.ApplicationUser.UserName).Count() == 1 && userRepository.Get(sc => sc.UserName == student.ApplicationUser.UserName). FirstOrDefault().Id != student.ApplicationUser.Id) { return(new MichtavaFailure("לא ניתן לשנות את פרטי המשתמש - שם המשתמש כבר קיים")); } this.studentRepository.Update(student); this.studentRepository.SaveChanges(); return(new MichtavaSuccess("משתמש עודכן בהצלחה")); }
//For no ID given, return current ApplicationUser public ActionResult <ApplicationUserViewModel> Get() { var userId = HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value; var applicationUser = _repository.Get(userId); if (applicationUser == null) { return(NotFound()); } var model = new ApplicationUserViewModel { Id = applicationUser.Id, CreationDate = applicationUser.CreationDate, UserName = applicationUser.UserName, FirstName = applicationUser.FirstName, LastName = applicationUser.LastName, Departments = null, CurrentLoggedInDepartmentId = applicationUser.CurrentLoggedInDepartmentId, LockoutEnd = applicationUser.LockoutEnd, IsOranizationMaintainer = applicationUser.IsOrganizationMaintainer, CanTrack = applicationUser.CanTrack }; return(model); }
public async Task <ApplicationUserDto> Create(ApplicationUserDto model) { var existingUser = await _applicationUserRepository.Get(x => x.Email == model.Email); if (existingUser != null) { throw new Exception(Constants.Users.UserExisted); } var data = _mapper.Map <ApplicationUser>(model); var result = await _applicationUserRepository.Add(data); return(_mapper.Map <ApplicationUserDto>(result)); }
public void CreateUser(UserViewModel ApplicationUserView) { ApplicationUser Exists = UserRepository.Get(x => x.UserName == ApplicationUserView.UserName && x.Email == ApplicationUserView.Email).FirstOrDefault(); if (Exists != null) { throw new Exception("ApplicationUsername & Email already in use"); } string SecurityStamp = EncryptionService.CreateSalt(); string HassedPassword = EncryptionService.EncryptPassword(ApplicationUserView.HashedPassword, SecurityStamp); ApplicationUserView.HashedPassword = HassedPassword; ApplicationUserView.Salt = SecurityStamp; ApplicationUser ApplicationUser = new ApplicationUser() { UserName = ApplicationUserView.UserName, Email = ApplicationUserView.Email, PasswordHash = ApplicationUserView.HashedPassword, SecurityStamp = ApplicationUserView.Salt, Active = ApplicationUserView.Active }; UserRepository.Add(ApplicationUser); SaveUser(); }
// GET: /<controller>/ public async Task <IActionResult> Index() { var draughtsmen = await _repo.GetAll(); var draftList = draughtsmen.ToList(); foreach (var draughtsman in draftList) { var appuserid = draughtsman.ApplicationUserId; var appuser = _appUserRepo.Get(appuserid); // draughtsman.ApplicationUser.FirstName = appuser.FirstName; // draughtsman.ApplicationUser.LastName = appuser.LastName; // draughtsman.ApplicationUser.Address = appuser.Address; var companyid = draughtsman.CompanyId; var company = _companyRepo.Get(companyid); // draughtsman.Company.CompanyName = company.CompanyName; // draughtsman.Company.CompanyContactNo = company.CompanyContactNo; // draughtsman.Company.CompanyEmail = company.CompanyEmail; } var model = _mapper.Map <List <Draughtsman>, List <DraughtsmanViewModel> >(draughtsmen.ToList()); /*foreach (var draughtsmanVM in model) * { * byte[] logo = draughtsmanVM.Company.CompanyLogo; * Image * using (MemoryStream memoryStream = new MemoryStream(draughtsmanVM.Company.CompanyLogo, 0 , draughtsmanVM.Company.CompanyLogo.Length)) * { * * draughtsmanVM.Company.CompanyLogo = Image.FromStream.memoryStream; * } * }*/ return(View(model)); }
//GET: ApplicationUser/Details/2 public async Task <IActionResult> Details(int id) { var applicationUser = await _repo.Get(id); var model = _mapper.Map <ApplicationUser, ApplicationUserViewModel>(applicationUser); return(View(model)); }
public IQueryable <ApplicationUser> GetAllUsers() { IQueryable <ApplicationUser> userlist = _repository.Get(); int listLength = userlist.Count(); int i = 0; return(userlist); }
public void Handle(PasswordResetCommand cmd, bool useStrongPassword) { if (cmd.CommandId == null) { cmd.CommandId = Guid.NewGuid(); } var user = _applicationUserRepository.Get(cmd.ApplicationUserId); if (user != null) { user.UpdatePassword(cmd.NewPassword, cmd.NewPasswordConfirm, cmd.OldPassword, useStrongPassword); _applicationUserRepository.Save(); //fire event here... } }
public ActionResult Login([Required] string email, [Required] string password) { var applicationUser = _userRepository.Get(email); if (applicationUser == null) { return(NotFound("Usuário ou senha inválida.")); } if (!_userRepository.CheckPassword(applicationUser, password)) { return(NotFound("Usuário ou senha inválida.")); } // Gera token return(Ok(GenerateToken(applicationUser))); }
// GET: /<controller>/ public async Task <IActionResult> Index() { var tb_clients = await _repo.GetAll(); var clientList = tb_clients.ToList(); foreach (var client in clientList) { var appuserid = client.ApplicationUserId; var appuser = _appUserRepo.Get(appuserid); //client.ApplicationUser.FirstName = appuser.FirstName; //client.ApplicationUser.LastName = appuser.LastName; //client.ApplicationUser.Address = appuser.Address; var companyid = client.CompanyId; var company = _companyRepo.Get(companyid); //client.Company.CompanyName = company.CompanyName; //client.Company.CompanyContactNo = company.CompanyContactNo; //client.Company.CompanyEmail = company.CompanyEmail; } var model = _mapper.Map <List <Client>, List <ClientViewModel> >(clientList); return(View(model)); }
public IEnumerable <ApplicationUser> Get() { return(applicationUserRepository.Get().ToList()); }
//Haalt alle gebruikers op die onder een manager vallen, op basis van een managerid. public IQueryable <ApplicationUser> GetUsersByManager(long managerid) { return(_repository.Get(filter => filter.Manager == managerid && filter.IsActive == true).OrderBy(p => p.FirstName)); }
protected ApplicationUser getCurrentlyLoggedInUser(IApplicationUserRepository applicationUserRepository) { return(applicationUserRepository.Get( filter: currentUser => currentUser.UserName == this.User.Identity.Name).SingleOrDefault()); }
public ApplicationUser GetApplicationUser(string id) { var applicationUser = _applicationUserRepository.Get(id); return(applicationUser); }