public ActionResult ResetPassword1(string rt) { if (SessionManager.IsUserLoggedIn) { return(RedirectToAction("Index", "Home")); } else { try { UserInfoRepository repo = new UserInfoRepository(); if (repo.IsValidResetToken(rt)) { ViewBag.data = rt; return(View()); } else { TempData["Msg"] = "Invalid password reset token!"; return(RedirectToAction("Index")); } } catch (Exception ex) { return(RedirectToAction("Index")); } } }
public UserResponseBO Authenticate(UserBO userBO) { using (var db = new dbGSCasinoContext()) { UserAuthRepository userAuthRepository = new UserAuthRepository(); TblUserAuth userAuth = userAuthRepository.Get(userBO, db); UserInfoRepository userInfoRepository = new UserInfoRepository(); TblUserInfo userInfo = userInfoRepository.Get(userAuth, db); UserWalletRepository userWalletRepository = new UserWalletRepository(); List <UserWalletBO> userWallet = userWalletRepository.GetBO(userAuth, db); UserRoleRepository userRoleRepository = new UserRoleRepository(); TblUserRole userRole = userRoleRepository.Get(userAuth, db); UserResponseBO userAuthResponse = new UserResponseBO(); userAuthResponse.UserInfo = userInfo; userAuthResponse.UserWallet = userWallet; userAuthResponse.UserAuth = userAuth; userAuthResponse.UserRole = userRole; return(userAuthResponse); } }
public bool Create(UserBO userBO) { using (var db = new dbGSCasinoContext()) { using (var transaction = db.Database.BeginTransaction()) { UserInfoRepository userInfoRepository = new UserInfoRepository(); TblUserInfo userInfo = userInfoRepository.Create(userBO, db); UserAuthRepository userAuthRepository = new UserAuthRepository(); TblUserAuth userAuth = userAuthRepository.Create(userBO, userInfo, db); UserRoleRepository userRoleRepository = new UserRoleRepository(); userRoleRepository.Create(userAuth, db); // CREATE USER WALLETS UserWalletAppService userWallet = new UserWalletAppService(); userWallet.Create(userAuth, db); transaction.Commit(); return(true); } } }
public ActionResult Create(UserInfoModel model) { if (model.ConfirmPassword != model.Password) { ModelState.AddModelError("Password", "Your passwords must match"); } if (model.Password.Length < 5) { ModelState.AddModelError("Password", "Password must be at least 5 characters"); } if (model.Password.Length > 30) { ModelState.AddModelError("Password", "Password must be between 5 and 30 characters"); } if (!ModelState.IsValid) { model.ValidationErrors = GetValidationErrors(ModelState); return(View("~/Views/Registration/User.cshtml", model)); } UserInfoRepository repo = new UserInfoRepository(); model.Roles = JsonConvert.DeserializeObject <Role[]>(model.RoleString); repo.Save(model); return(RedirectToAction("Edit", new { id = model.Id, Message = "Your employee was successfully created." })); }
public async Task <ActionResult> ChangeUserInfo() { var userId = User.Identity.GetUserId(); var userInfo = await UserInfoRepository.FindById(userId); return(View(userInfo)); }
public ActionResult Edit(int id) { UserInfoRepository repo = new UserInfoRepository(); UserInfoModel model = repo.Get(id); return(View("~/Views/Registration/User.cshtml", model)); }
public List <WorkItemDto> GetIncompleteItemsByUserIdList(int serverId, int employeeId, List <int> employeeIdList) { TeamServer server = null; List <WorkItem> workItems = null; List <WorkItemDto> workItemsDtoList = new List <WorkItemDto>(); UserServerInfo userServerInfo = null; try { using (TeamServerRepository teamServerRepository = new TeamServerRepository()) { server = teamServerRepository.GetById(serverId); if (server == null) { throw new Exception(string.Format("Invalid Server Id : {0}", serverId)); } } UserInfo userInfo = null; using (UserInfoRepository userInfoRepository = new UserInfoRepository()) { userInfo = userInfoRepository.Find(x => x.EmployeeId == employeeId); if (userInfo == null) { throw new Exception(string.Format("User with Employee ID {0} Not Found", employeeId)); } } List <string> serverUserIdList = new List <string>(); using (UserServerInfoRepository userServerInfoRepository = new UserServerInfoRepository()) { userServerInfo = userServerInfoRepository.FindLocal(x => x.EmployeeId == employeeId && x.TfsId == serverId); if (userServerInfo == null) { throw new Exception(string.Format("User with employee id : {0} is not registered with server id : {1}", employeeId, serverId)); } string test = userServerInfoRepository.Filter(x => employeeIdList.Contains(x.EmployeeId)) .Select(x => x.UserId).Aggregate((current, next) => "'" + current + "' OR "); string credentialHash = userServerInfo.CredentialHash; string url = server.Url; string query = "Select * From WorkItems " + "Where [System.AssignedTo] = @me " + "AND ([System.State] = 'To Do' OR [System.State] = 'In Progress')" + "Order By [State] Asc, [Changed Date] Desc"; workItems = _teamServerManagementService.GetWorkItemByQuery(query, url, credentialHash); } foreach (WorkItem workItem in workItems) { workItemsDtoList.Add(workItem.ToDto()); } return(workItemsDtoList); } catch (Exception ex) { logger.Error(ex); throw; } }
public override void OnControlLoaded() { IUserInfoRepository repository = new UserInfoRepository(); //repository.ValidateUser("Lee"); //GetList(); InitGrid(); }
public UserController(UserInfoRepository repository, TaskManageRepository marepository, ILogger <UserController> logger, IMemoryCache cache, Config config) { this._repository = repository; this._marepository = marepository; this._logger = logger; this._cache = cache; this._config = config; }
public UserSessionDto Login(string userId, string password) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentException("User Id cannot be null", nameof(userId)); } if (string.IsNullOrEmpty(password)) { throw new ArgumentException("Password cannot be null", nameof(password)); } UserLogin userLoginEntity = null; using (UserLoginRepository userLoginRepository = new UserLoginRepository()) { string securePassword = password.Encrypt(); userLoginEntity = userLoginRepository.Find(x => x.UserId == userId && x.Password == securePassword); if (userLoginEntity == null) { throw new ApplicationException("Invalid UserId/Password"); } } using (UserInfoRepository repository = new UserInfoRepository()) { UserInfo userInfo = repository.Find(x => x.UserId == userId); if (userInfo == null) { throw new ApplicationException("User Info not found."); } string sessionId = Guid.NewGuid().ToString(); using (UserSessionRepository userSessionRepository = new UserSessionRepository()) { UserSession userSession = new UserSession { UserId = userId, SessionId = sessionId, ValidFrom = DateTime.Now, ExpiresOn = DateTime.Now.AddDays(1) }; userSessionRepository.Insert(userSession); } return(new UserSessionDto() { SessionId = sessionId, User = new UserInfoDto() { FirstName = userInfo.FirstName, LastName = userInfo.LastName, Email = userInfo.EMail, UserId = userInfo.UserId, Gender = userInfo.Gender } }); } }
private async Task <HttpResponseMessage> HandleO365ConnectorCardActionQuery(Activity activity) { var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl)); var userInfo = UserInfoRepository.GetUserInfo(activity.From.Id); // Validate for Sing In if (userInfo == null || userInfo.ExpiryTime < DateTime.Now) { var reply = activity.CreateReply(); SigninCard plCard = RootDialog.GetSignInCard(); reply.Attachments.Add(plCard.ToAttachment()); await connectorClient.Conversations.ReplyToActivityWithRetriesAsync(reply); return(new HttpResponseMessage(System.Net.HttpStatusCode.OK)); } var email = string.Empty; var member = connectorClient.Conversations.GetConversationMembersAsync(activity.Conversation.Id).Result.AsTeamsChannelAccounts().FirstOrDefault(); if (member != null) { email = member.Email; } // Get O365 connector card query data. Task <Task> task = new Task <Task>(async() => { O365ConnectorCardActionQuery o365CardQuery = activity.GetO365ConnectorCardActionQueryData(); Activity replyActivity = activity.CreateReply(); switch (o365CardQuery.ActionId) { case "Custom": // Get Passenger List & Name var teamDetails = Newtonsoft.Json.JsonConvert.DeserializeObject <CustomTeamData>(o365CardQuery.Body); await CreateTeam(connectorClient, activity, userInfo, teamDetails.TeamName, teamDetails.Members.Split(';').ToList()); break; case "Flight": var flightDetails = Newtonsoft.Json.JsonConvert.DeserializeObject <O365BodyValue>(o365CardQuery.Body); await CreateTeam(connectorClient, activity, userInfo, "Flight-" + flightDetails.Value, GetMemberList(email)); // await AttachClassWisePassengerList(classInfo.Value, replyActivity, $"Passengers with {classInfo.Value} tickets"); break; default: break; } }); task.Start(); return(new HttpResponseMessage(System.Net.HttpStatusCode.OK)); }
public void TextDapperContext() { DbEntityMap.InitMapCfgs(); IDapperContext dapperContext = new DapperContext(new NameValueCollection() { ["aa.dataSource.AaCenter.connectionString"] = "Data Source =.; Initial Catalog = AaCenter;User ID = sa; Password = lee2018;", ["aa.dataSource.AaCenter.provider"] = "SqlServer" }); IUserInfoRepository _userInforepository = new UserInfoRepository(); IVillageRepository villageRepository = new VillageRepository(); villageRepository.Insert(new Village { Id = Guid.NewGuid(), VillageName = "aa", GmtCreate = DateTime.Now, GmtModified = DateTime.Now }); var model = villageRepository.Get(new Guid("6D880321-DB17-4B32-9F0A-CE9F3F25AA01")); model.VillageName = "bbb"; villageRepository.Update(model); //var obj = _userInforepository.Insert(new UserInfo() //{ // RealName = "111", // UserName = "******", // GmtCreate=DateTime.Now, // LastLoginDate=DateTime.Now, // GmtModified=DateTime.Now //}); var users = _userInforepository.QueryAll(); var userList = _userInforepository.From(sql => sql.Select() .Where(p => p.RealName.Contains("成")) .OrderBy(x => x.SysNo) .Page(1, 20) ); var count = userList.ToList().Count(); //动态where Expression <Func <UserInfo, bool> > expression = p => p.RealName == "成天"; var where = DynamicWhereExpression.Init <UserInfo>(); where = where.And(x => x.RealName == "成天"); var dynamicUsers = _userInforepository.From(sql => sql.Select() .Where(where) .OrderBy(x => x.SysNo) .Page(1, 20) ); var count2 = dynamicUsers.ToList().Count(); }
public void DeleteTest() { UserInfoRepository deleteuserinfo = new UserInfoRepository(); UserInfo userinfo = new UserInfo(); userinfo.ID = 23; bool isTrue = deleteuserinfo.DeleteEntities(userinfo); Assert.AreEqual(true, isTrue); }
public void TextDapperContext() { DbEntityMap.InitMapCfgs(); IDapperContext dapperContext = new DapperContext(new NameValueCollection() { ["aa.dataSource.AaCenter.connectionString"] = "Data Source =.; Initial Catalog = AaCenter;User ID = sa; Password = 123;", ["aa.dataSource.AaCenter.provider"] = "SqlServer" }); IUserInfoRepository _userInforepository = new UserInfoRepository(); var users = _userInforepository.QueryAll(); }
public async Task <ActionResult> ChangeUserInfo(UserInfo model) { if (ModelState.IsValid) { await UserInfoRepository.Upsert(model); return(RedirectToAction("Index", "Home")); } // Появление этого сообщения означает наличие ошибки; повторное отображение формы return(View(model)); }
public void UpdateTest() { UserInfoRepository updateuserInfo = new UserInfoRepository(); UserInfo userinfo = new UserInfo(); userinfo.ID = 23; userinfo.UName = "韩迎龙"; userinfo.Pwd = "shit"; bool isTure = updateuserInfo.UpdateEntities(userinfo); Assert.AreEqual(true, isTure); }
public void ShowTest() { //TODO:初始化为适当的值 UserInfoRepository target = new UserInfoRepository(); UserInfo userinfo = new UserInfo(); userinfo.Pwd = "citsoft"; userinfo.UName = "hyl"; var addUserInfo = target.AddEntities(userinfo); Assert.AreEqual(true, addUserInfo.ID > 0); }
/// <summary> /// 更新用户信息 /// </summary> /// <param name="parameter">参数</param> private async Task UpdateUserInfoAsync(UserParameter parameter) { var entity = await UserInfoRepository.FindAsync(parameter.Id); if (entity == null) { throw new Warning("用户不存在"); } entity.Name = parameter.Nickname; entity.Gender = parameter.Gender; await UserInfoRepository.UpdateAsync(entity); }
public int RegisterServer(int serverId, string userId, string serverUserId, string serverPassword, string serverDomain) { TeamServer teamServerEntity; try { using (TeamServerRepository teamServerRepository = new TeamServerRepository()) { teamServerEntity = teamServerRepository.GetById(serverId); if (teamServerEntity == null) { throw new Exception("Invalid server id"); } } using (UserInfoRepository userInfoRepository = new UserInfoRepository()) { UserInfo userInfoEntity = userInfoRepository.Find(x => x.UserId == userId); if (userInfoEntity == null) { throw new Exception("Invalid user id"); } } using (UserServerInfoRepository userServerInfoRepository = new UserServerInfoRepository()) { UserServerInfo userServerInfoEntity = userServerInfoRepository.Find( x => x.UserId.ToUpper() == userId.ToUpper() && x.TfsId == serverId); if (userServerInfoEntity != null) { throw new Exception(string.Format("Server {0} is already registered to the user {1} .", serverId, userId)); } // Dependency Injection of Team Service. NetworkCredential credential = new NetworkCredential(serverUserId, serverPassword, serverDomain); string hash = JsonConvert.SerializeObject(credential).Encrypt(); _authenticationService.Authenticate(serverId, hash); userServerInfoEntity = new UserServerInfo() { UserId = userId, TfsId = serverId, TfsUserId = serverUserId, CredentialHash = hash }; return(userServerInfoRepository.Insert(userServerInfoEntity)); } } catch (Exception ex) { _logger.Error(ex); throw; } }
public UnitOfWork(DatabaseContext context) { _context = context; Users = new UserRepository(_context); UsersInfo = new UserInfoRepository(_context); Roles = new RoleRepository(_context); UsersHasRoles = new UserHasRoleRepository(_context); Messages = new MessageRepository(_context); Friendships = new FriendshipRepository(_context); Games = new GameRepository(_context); UsersGames = new UserHasGameRepository(_context); }
public override SysUser GetModel(string sysId) { var sysUser = base.GetModel(sysId); if (sysUser == null) { return(null); } sysUser.UserInfo = UserInfoRepository.GetModel(sysId); return(sysUser); }
public ResponseResult ValidateUser(Login pLogin) { try { UserInfoRepository userInfoRepo = new UserInfoRepository(); return(userInfoRepo.ValidateUser(pLogin.UserName, "", "", true, true)); } catch (Exception ex) { CustomUtility.HandleException(ex); return(ResponseResult.GetErrorObject()); } }
public TblUserInfo Get(TblUserAuth userAuth) { using (var db = new Minny_Casino_AffiliateContext()) { using (var transaction = db.Database.BeginTransaction()) { UserInfoRepository userInfoRepository = new UserInfoRepository(); TblUserInfo userInfo = userInfoRepository.Get(userAuth, db); return(userInfo); } } }
public TblUserInfo Get(TblUserAuth userAuth) { using (var db = new dbWorldCCityContext()) { using (var transaction = db.Database.BeginTransaction()) { UserInfoRepository userInfoRepository = new UserInfoRepository(); TblUserInfo userInfo = userInfoRepository.Get(userAuth, db); return(userInfo); } } }
public WorkItemDto GetWorkItemById(int taskId, int serverId, string userId) { TeamServer server = null; UserServerInfo userServerInfo = null; try { using (TeamServerRepository teamServerRepository = new TeamServerRepository()) { server = teamServerRepository.GetById(serverId); if (server == null) { throw new Exception(string.Format("Invalid Server Id : {0}", serverId)); } } UserInfo userInfo = null; using (UserInfoRepository userInfoRepository = new UserInfoRepository()) { userInfo = userInfoRepository.Find(x => x.UserId != null && x.UserId.ToUpper() == userId.ToUpper()); if (userInfo == null) { throw new Exception(string.Format("User with ID {0} Not Found", userId)); } } using (UserServerInfoRepository userServerInfoRepository = new UserServerInfoRepository()) { userServerInfo = userServerInfoRepository.FindLocal( x => x.UserId != null && x.UserId.ToUpper() == userId.ToUpper() && x.TfsId == serverId); if (userServerInfo == null) { throw new Exception(string.Format("User : {0} is not registered with server id : {1}", userId, serverId)); } string credentialHash = userServerInfo.CredentialHash; string url = server.Url; WorkItem workItem = _teamServerManagementService.GetWorkItemById(taskId, url, credentialHash); if (workItem != null) { return(workItem.ToEntity(serverId).ToDto(workItem.Id)); } } return(null); } catch (Exception ex) { _logger.Error(ex); throw; } }
public string Get(string name, int page = 1, int pagesize = 20) { long count = 0; var list = UserInfoRepository.LoadAll(); count = list.Count; var obj = new { total = count, list = list.Where(m => (m.real_name.Equals(name) || string.IsNullOrEmpty(name))).Skip((page - 1) * pagesize).Take(pagesize) }; return(JsonConvert.SerializeObject(obj)); }
public ActionResult Login() { UserInfoRepository repo = new UserInfoRepository(); int id = int.Parse(requestWrapper.Form("Id")); string password = requestWrapper.Form("Password"); if (repo.Login(id, password)) { sessionWrapper.Set(ME, repo.Get(id)); Session.Timeout = 60; return(RedirectToAction("Menu", "Home")); } return(RedirectToAction("Index", "Home", new { ErrorMessage = "Invalid credentials. Try to login again or contact the site administrator." })); }
public virtual async Task <HttpResponseMessage> Post([FromBody] Activity activity) { // check if activity is of type message if (activity != null && activity.GetActivityType() == ActivityTypes.Message) { await Conversation.SendAsync(activity, () => new RootDialog()); } else if (activity.IsO365ConnectorCardActionQuery()) { // this will handle the request coming any action on Actionable messages return(await HandleO365ConnectorCardActionQuery(activity)); } else if (activity != null && activity.GetActivityType() == ActivityTypes.Invoke && activity.Name == "signin/verifyState") { var stateInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <SateValue>(activity.Value.ToString()); // var userInfo = // userData.SetProperty<string>("AccessToken", activity.Value.ToString()); UserInfoRepository.AddUserInfo(new UserInfo() { userId = activity.From.Id, accessToken = stateInfo.state, ExpiryTime = DateTime.Now.AddSeconds(3450) }); //3450 var reply = activity.CreateReply(); reply.Text = "You are successfully signed in. Now, you can use the 'create team' command."; // Get Email Id. var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl)); var email = string.Empty; var member = connectorClient.Conversations.GetConversationMembersAsync(activity.Conversation.Id).Result.AsTeamsChannelAccounts().FirstOrDefault(); if (member != null) { email = member.Email; } var card = RootDialog.GetFilter(email); reply.Attachments.Add(card); await connectorClient.Conversations.ReplyToActivityAsync(reply); } else { HandleSystemMessage(activity); } return(new HttpResponseMessage(System.Net.HttpStatusCode.Accepted)); }
private static void checkUser(out DTO.User user) { var userRepo = new UserInfoRepository(DTO.Enums.BackEndOrFrontEndEnum.FrontEnd); var userDbManager = new UserDbManager(userRepo); user = userDbManager.GetUserByUsername(Environment.UserName); //A null user would mean the current Windows username doesn't exist in the User_Login_Info table if (user == null) { Console.Clear(); Console.WriteLine("Sorry, but you are not currently an authorized user. Please speak to the database administrator if you believe you have " + "seen this message in error. Press enter to exit."); Console.ReadLine(); } }
public ActionResult Update(UserInfoModel model) { ModelState["Password"].Errors.Clear(); ModelState["ConfirmPassword"].Errors.Clear(); if (!ModelState.IsValid) { model.ValidationErrors = GetValidationErrors(ModelState); return(View("~/Views/Registration/User.cshtml", model)); } UserInfoRepository repo = new UserInfoRepository(); model.Roles = JsonConvert.DeserializeObject <Role[]>(model.RoleString); repo.Save(model); return(RedirectToAction("Edit", new { id = model.Id, Message = "Your employee was successfully created." })); }