public PotentialUserComponent(Guid potentialUserId) { if (potentialUserId != Guid.Empty) { mifnexsoEntities = new MIFNEXSOEntities(); try { potentialUser = mifnexsoEntities.PotentialUsers.FirstOrDefault(a => a.PotentialUserId == potentialUserId); if (potentialUser == null) { potentialUser = new PotentialUser(); potentialUser.PotentialUserId = Guid.Empty; mifnexsoEntities.PotentialUsers.AddObject(potentialUser); } } catch (Exception) { throw; } } else { potentialUser = new PotentialUser(); } }
public PotentialUserComponent(string email) { if (!string.IsNullOrEmpty(email)) { mifnexsoEntities = new MIFNEXSOEntities(); try { potentialUser = mifnexsoEntities.PotentialUsers.FirstOrDefault(a => a.Email == email && (a.Deleted == false || a.Deleted == null)); if (potentialUser == null) { potentialUser = new PotentialUser(); potentialUser.Email = email; potentialUser.PotentialUserId = Guid.Empty; mifnexsoEntities.PotentialUsers.AddObject(potentialUser); } } catch (Exception) { throw; } } else { potentialUser = new PotentialUser(); } }
public ActionResult PotentialUser(PotentialUser pu, string referrerUrl, string ghRole) { try { if (ModelState.IsValid) { pu.Role = ghRole; if (pu.PotentialUserID > 0) { _trs.UpdatePotentialUser(pu); } else { _trs.SavePotentialUser(pu); } //if (string.IsNullOrEmpty(referrerUrl)) return(RedirectToAction("PotentialUsers", "Account")); //else // return Redirect(referrerUrl); } return(View(pu)); } catch (Exception ex) { Log.Error(ex.Message, ex); return(new HttpStatusCodeResult(500)); } }
public IMaybe <Jwt.TokenBundle> MaybeLogin(PotentialUser potentialUser) { var maybeUser = _userRepository.MaybeGetOne(potentialUser.Username); return(maybeUser.Case( some: user => { var isUsersAccountDisabled = !user.IsActive; if (isUsersAccountDisabled) { return None <Jwt.TokenBundle> .Exists; } var isPasswordCorrect = PasswordService.Validate(potentialUser.Password, user.Password); if (!isPasswordCorrect) { return None <Jwt.TokenBundle> .Exists; } var sesssion = _sessionCommand.Execute(new SessionCommand.Create( user: user, startedOn: DateTime.Now )); return Some <Jwt.TokenBundle> .Exists(new Jwt.TokenBundle( bearerToken: new Jwt.BearerToken(username: user.Username, role: user.Role), refreshToken: new Jwt.RefreshToken(id: sesssion.Id, startedOn: sesssion.StartedOn) )); }, none: () => None <Jwt.TokenBundle> .Exists)); }
public PotentialUserComponent() { mifnexsoEntities = new MIFNEXSOEntities(); potentialUser = new PotentialUser(); potentialUser.PotentialUserId = Guid.Empty; mifnexsoEntities.PotentialUsers.AddObject(potentialUser); }
public string GenerateTokenForPotentialUser(PotentialUser pu) { try { return(Crypto.Hash(pu.Name + pu.Email)); } catch (Exception ex) { Log.Error(ex.Message, ex); return(null); } }
public void DeletePotentialUser(PotentialUser pu) { try { _pur.Delete(pu); } catch (Exception ex) { Log.Error(ex.Message, ex); throw ex; } }
public void Delete(PotentialUser pu) { try { db.Entry(pu).State = EntityState.Deleted; db.SaveChanges(); } catch (Exception ex) { Log.Error(ex.Message, ex); throw ex; } }
public void Save(PotentialUser pu) { try { db.PotentialUsers.Add(pu); db.SaveChanges(); } catch (Exception ex) { Log.Error(ex.Message, ex); throw ex; } }
public void UpdatePotentialUser(PotentialUser pu) { try { pu.Token = GenerateTokenForPotentialUser(pu); _pur.Update(pu); } catch (Exception ex) { Log.Error(ex.Message, ex); throw ex; } }
public PotentialUser Add(PotentialUserDto potentialUserDto) { var potentialUser = new PotentialUser { Id = Guid.NewGuid(), UserCode = potentialUserDto.UserCode, FirstName = potentialUserDto.FirstName, LastName = potentialUserDto.LastName, UserRoleId = potentialUserDto.RoleId, Email = potentialUserDto.Email }; _repository.Insert(potentialUser); _repository.Save(); return(potentialUser); }
private void InsertAdmin(PotentialUser potentialUser) { var role = _repository.GetByFilter <UserRole>(x => x.Id == potentialUser.UserRoleId); if (role.Name == "Admin") { var admin = new Admin { Id = Guid.NewGuid(), LastName = potentialUser.LastName, FirstName = potentialUser.LastName, PotentialUserId = potentialUser.Id }; _repository.Insert(admin); _repository.Save(); } }
public ActionResult PotentialUser(long?id) { try { if (Request.UrlReferrer != null) { ViewBag.referrerUrl = Request.UrlReferrer.AbsoluteUri; } var potentialUser = new PotentialUser(); if (id != null && id > 0) { potentialUser = _trs.FindPotentialUser((long)id); } return(View(potentialUser)); } catch (Exception ex) { Log.Error(ex.Message, ex); return(HttpNotFound()); } }