private Result <UserPerson> InitiateAccout(CreatePersonAccountCommand request) { var curDate = _dateTime.Now; var result = new UserPerson() { UserId = request.Email ?? request.UserId, Person = new Person() { FirstName = request.FirstName, LastName = request.LastName, ModifiedDate = curDate, } }; if (request.Email != null) { result.Person.PersonContact = new[] { new PersonContact() { Name = "Email", Value = request.Email, Url = $"mailto:{request.Email}", ModifiedDate = curDate } }; } return(result); }
public static Guid?SetUserID() { Guid?retVal = null; People person = new People(Utils.ConnectionString()); List <People> personList = person.GetPeopleBySurnameForenameEmail("Cantrell", "Daren", "*****@*****.**"); if (personList.Count == 1) { UserPerson userPerson = new UserPerson(Utils.ConnectionString()); List <UserPerson> userPeople = userPerson.GetUser_PersonByPerson_ID(personList[0].Person_ID); if (userPeople.Count == 1) { retVal = userPeople[0].User_ID; } else { LogToFile("Multiple users exist with the same Person ID"); } } else { LogToFile("Multiple people exist with the same forename, surname and email address"); } return(retVal); }
public Person CreatePerson(string firstName, string lastName) { var person = new Person() { Id = new long(), FirstName = firstName, LastName = lastName, IsRemoved = false, IsActive = false, Created = DateTime.Now, Creator = Thread.CurrentPrincipal.Identity.GetUserId <long>() }; Add(person); var result = new UserPerson() { PersonId = person.Id, Person = person }; person.Users.Add(result); var context = new DefaultContext(); context.UserPersons.Add(result); return(person); }
public IHttpActionResult PutUserPerson(int id, UserPerson userPerson) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userPerson.idUserPerson) { return(BadRequest()); } db.Entry(userPerson).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserPersonExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private static void SetPersonProperties(PersonDetailsVm model, UserPerson person) { person.DateOfBirth = model.DateOfBirth.GetValueOrDefault(); person.AddressLine1 = model.AddressLine1; person.AddressLine2 = model.AddressLine2; person.Gender = model.Gender; person.City = model.City; }
public void TestBadRequestWithResponseId() { var caughtException = Assert.Throws <BadRequestException>( () => UserPerson.Get() ); Assert.NotNull(caughtException.ResponseId); }
public void UnFriend(string userId, string friendId) { UserPerson user1 = m_userDictionary[userId]; UserPerson user2 = m_userDictionary[friendId]; user1.UnFriend(friendId); user2.UnFriend(userId); }
public void RemoveAdmin(string userId, string groupId) { Group g = m_groupDictionary[groupId]; UserPerson u = m_userDictionary[userId]; g.RemoveAdmin(userId); //m_myHub.SendMessage(g.Name, "removed admin " + u.DisplayName); }
public void AddMember(string userId, string groupId) { Group g = m_groupDictionary[groupId]; UserPerson u = m_userDictionary[userId]; g.AddMember(userId); //gui thong tin //m_myHub.SendMessage(g.Name, "added member " + u.DisplayName); }
private void ConnectAsync() { Connection = new HubConnection(ServerURI); m_ChatFormDictionary = new Dictionary <string, ChatForm>(); m_UserDictionary = new Dictionary <string, UserPerson>(); HubProxy = Connection.CreateHubProxy("MyHub"); HubProxy.On <string, char>("BroadcastOnlineStatus", (displayName, status) => Invoke((Action)(() => ChangeStatus(displayName, status)))); HubProxy.On <Messages>("SendMessageToClient", (message) => Invoke((Action)(() => AppearMessage(message)))); HubProxy.On <List <Messages> >("SendOfflineMessage", (offlineMessage) => Invoke((Action)(() => AppearOfflineMessage(offlineMessage)))); try { Connection.Start().ContinueWith(task => { if (task.IsFaulted) { //Connection error Invoke((MethodInvoker) delegate { MessageBox.Show(task.Exception.Message); }); } else { //connected Invoke((MethodInvoker) delegate { label3.Text = "Connected to server at " + ServerURI + ""; up = new UserPerson(m_userName, m_passWord) { Status = 'O' }; getUserList(); bool m_result = HubProxy.Invoke <bool>("Login", up).Result; string connectionId = HubProxy.Invoke <string>("GetConnectionId").Result; if (m_result == false) { MessageBox.Show("Log in failed."); } else { //MessageBox.Show(connectionId); showUserList(); buttonLogin.Enabled = false; } }); } }); } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { _connString = ConfigurationManager.ConnectionStrings["SSSDbConnDev"].ConnectionString; Common.ConnString = _connString; if (!FoundSystemAdmin()) { MembershipCreateStatus outstatus; MembershipUser newUser = Membership.CreateUser(AdminName, AdminPW, AdminEmail, PWQuestion, PWAnswer, true, out outstatus); if (!Roles.RoleExists(AdminRole)) { Roles.CreateRole(AdminRole); } Roles.AddUserToRole(AdminName, AdminRole); string strUser_ID = newUser.ProviderUserKey.ToString(); Guid newUserId = new Guid(strUser_ID); //Guid newUserId = (Guid)newUser.ProviderUserKey; Addresses address = new Addresses(_connString); address.Address_1 = "Grasmere"; address.Address_2 = "Findon Road"; address.Address_Town = "Findon"; address.Address_City = string.Empty; address.Address_County = "West Sussex"; address.Address_Postcode = "BN14 0RD"; Guid?address_ID = (Guid?)address.Insert_Address(newUserId); if (address_ID != null) { People person = new People(_connString); person.Person_Forename = "Daren"; person.Person_Surname = "Cantrell"; person.Address_ID = address_ID; person.Person_Mobile = "07880 883089"; person.Person_Landline = "01903 877336"; person.Person_Email = AdminEmail; Guid?person_ID = person.Insert_Person(newUserId); if (person_ID != null) { UserPerson userPerson = new UserPerson(_connString); userPerson.User_ID = newUserId; userPerson.Person_ID = (Guid)person_ID; Guid?user_Person_ID = userPerson.Insert_User_Person(newUserId); } } RunOnceMessage.Text = string.Format("System Admin setup correctly {0}", ""); } else { RunOnceMessage.Text = string.Format("System Admin already setup {0}", ""); } }
public IHttpActionResult GetUserPerson(int id) { UserPerson userPerson = db.UserPerson.Find(id); if (userPerson == null) { return(NotFound()); } return(Ok(userPerson)); }
public async Task <UserPerson> RegisterUserAsync(UserPerson userPerson) { var response = await farmAppApi.RegisterUser(userPerson); if (response.IsSuccessStatusCode) { return(response.Content); } return(null); }
public Builder.Player AddPlayer(UserPerson user, bool isHost, Game game) { Builder.Player player = new Builder.Player { UserPerson = user, IsHost = isHost, Game = game }; Session.Save(player); return(player); }
public void AddUserToPerson(User user, Person person) { var userPerson = new UserPerson() { UserId = user.Id, User = user, PersonId = person.Id, Person = person }; DataContext.UserPersons.Add(userPerson); }
public IHttpActionResult PostUserPerson(UserPerson userPerson) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.UserPerson.Add(userPerson); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = userPerson.idUserPerson }, userPerson)); }
public async Task <UserPerson> GetUserAsync(int userId) { var response = await farmAppApi.GetUser(userId); if (response.IsSuccessStatusCode) { UserPerson user = response.Content; return(user); } return(null); }
protected void Page_Load(object sender, EventArgs e) { _connString = ConfigurationManager.ConnectionStrings["SSSDbConnDev"].ConnectionString; Common.ConnString = _connString; MessageLabel.Text = string.Empty; GetCommon(); if (!Page.IsPostBack) { Guid person_ID; if (!string.IsNullOrEmpty(User_Person_ID)) { divUpdateDetails.Visible = false; } else { MembershipUser userInfo = Membership.GetUser(); Guid user_ID = (Guid)userInfo.ProviderUserKey; UserPerson userPerson = new UserPerson(_connString); List <UserPerson> lnkUserPerson; lnkUserPerson = userPerson.GetUser_PersonByUser_ID(user_ID); if (lnkUserPerson.Count > 0) { Guid?user_Person_ID = (Guid?)lnkUserPerson[0].User_Person_ID; Guid?newPerson_ID = (Guid?)lnkUserPerson[0].Person_ID; if (user_Person_ID != null) { User_Person_ID = user_Person_ID.ToString(); Common.User_Person_ID = User_Person_ID; } if (newPerson_ID != null) { Person_ID = newPerson_ID.ToString(); Common.New_User_ID = Person_ID; } divUpdateDetails.Visible = false; } } if (!string.IsNullOrEmpty(Person_ID)) { person_ID = new Guid(Person_ID); PopulatePerson(person_ID); } else { string returnChars = Common.AppendReturnChars(Request.QueryString, "upi"); Server.Transfer("~/ShowAdmin/PersonSetup.aspx?" + returnChars + "&p=nu"); } } }
public AdminChatPage(string name) { InitializeComponent(); _name = name; Title = _name; _person = AdminServices.userPeople.Where(p => p.Name == _name).FirstOrDefault(); sendButton.Clicked += SendButton_ClickedAsync; ChatClientService.OnMessageRecieved += ChatClientService_OnMessageRecieved1; ReelMessages(_person.Messages); }
public IHttpActionResult DeleteUserPerson(int id) { UserPerson userPerson = db.UserPerson.Find(id); if (userPerson == null) { return(NotFound()); } db.UserPerson.Remove(userPerson); db.SaveChanges(); return(Ok(userPerson)); }
public void Run(string[] args) { var environmentType = ShareLib.DetermineEnvironmentType(args); ShareLib.PrintHeader(); var bunq = new BunqLib(environmentType); var callbackUrl = ShareLib.GetCallbackUrlFromArgsOrStdIn(args); Console.Out.WriteLine(); Console.Out.WriteLine($" | Adding Callback URL: {callbackUrl}"); Console.Out.WriteLine(); Console.Out.WriteLine(" ..."); Console.Out.WriteLine(); if (BunqContext.UserContext.isOnlyUserCompanySet()) { UserCompany.Update( notificationFilters: UpdateAllNotificationFilter( BunqContext.UserContext.UserCompany.NotificationFilters, callbackUrl ) ); } else if (BunqContext.UserContext.IsOnlyUserPersonSet()) { UserPerson.Update( notificationFilters: UpdateAllNotificationFilter( BunqContext.UserContext.UserPerson.NotificationFilters, callbackUrl ) ); } else { throw new BunqException("Unexpected user type found."); } Console.Out.WriteLine(); Console.Out.WriteLine(" | Callback URL added"); Console.Out.WriteLine(); Console.Out.WriteLine(" | Check your changed overview"); Console.Out.WriteLine(); Console.Out.WriteLine(); bunq.UpdateContext(); }
public LogsPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IFarmAppService farmAppService, IDialogService dialogService) : base(navigationService) { Title = LogsPageTitle; _navigationService = navigationService; _pageDialogService = pageDialogService; _farmAppApiService = farmAppService; _dialogService = dialogService; PickerGender(); User = new User(); UserPerson = new UserPerson(); LogInCommand = new Command(async() => await OnLogin()); SingUpCommand = new Command(async() => await OnSignUp()); }
public async Task <bool> Register(RegisterCommandModel model) { var storeUser = new UserPerson { FirstName = model?.FirstName, LastName = model?.LastName, Email = model?.Email, UserName = model?.Username, PhoneNumber = model?.PhoneNumber, DateOfBirth = model.DateOfBirth, State = model?.State, City = model?.City }; var isCreated = await _userManager.CreateAsync(storeUser, model.Password); if (isCreated.Succeeded) { if (model.Email == "*****@*****.**" || model.Email == "*****@*****.**") { var claims = new List <Claim> { new Claim("FullName", model.FirstName + ", " + model.LastName), new Claim("Admin", model.Email), new Claim("ContentEditor", "Edit"), new Claim("DateOfBirth", model.DateOfBirth.ToString()) }; await _userManager.AddClaimsAsync(storeUser, claims); } else { var claims = new List <Claim> { new Claim("FullName", model.FirstName + ", " + model.LastName), new Claim("DateOfBirth", model.DateOfBirth.ToString()) }; await _userManager.AddClaimsAsync(storeUser, claims); } await _signInManager.SignInAsync(storeUser, false, null); return(true); } return(false); }
protected void btnUpdate_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(User_Person_ID)) { MembershipUser userInfo = Membership.GetUser(); Guid user_ID = (Guid)userInfo.ProviderUserKey; Guid person_ID = new Guid(Person_ID); Guid user_Person_ID = new Guid(User_Person_ID); UserPerson userPerson = new UserPerson(_connString, user_Person_ID); if (userPerson.Person_ID.ToString() != Person_ID) { userPerson.User_ID = user_ID; userPerson.Person_ID = person_ID; bool success = userPerson.Update_User_Person(user_Person_ID, user_ID); if (success) { MessageLabel.Text = "Updated Successfully."; } } else { MessageLabel.Text = "No changes made. - Update cancelled."; } } else { MembershipUser userInfo = Membership.GetUser(); Guid user_ID = (Guid)userInfo.ProviderUserKey; Guid person_ID = new Guid(Person_ID); UserPerson userPerson = new UserPerson(_connString); userPerson.User_ID = user_ID; userPerson.Person_ID = person_ID; Guid?user_Person_ID = userPerson.Insert_User_Person(user_ID); if (user_Person_ID != null) { User_Person_ID = user_Person_ID.ToString(); MessageLabel.Text = "Added Successfully."; StoreCommon(); divUpdateDetails.Visible = false; } } }
public UserPerson AddAndOrLoadUser(string name) { UserPerson user; if (!DoesPlayerExist(name)) { user = new UserPerson { NickName = name }; Session.Save(user); } else { user = Session.Query <UserPerson>().Where(u => u.NickName == name).First(); } return(user); }
/** * @overview: Login to the system * @effects: * 1. Check username and password match * 2. Set session * 3. Set status */ public bool Login(UserPerson user) { if (m_userDictionary.ContainsKey(user.Id)) { if (m_userDictionary[user.Id].Password == user.Password) { //set session for user Id m_userDictionary[user.Id].ConnectionId = m_myHub.GetConnectionId(); user.ConnectionId = m_userDictionary[user.Id].ConnectionId; m_userDictionary[user.Id].Status = user.Status; if (user.Status == 'O') { SendOfflineMessage(user.Id); m_myHub.BroadcastOnlineStatus(m_userDictionary[user.Id].DisplayName, m_userDictionary[user.Id].Status, m_userDictionary[user.Id].ConnectionId); } return(true); } } return(false); }
public void CreateAdmin() { Guid newUserId = Program.UserID(); Addresses address = new Addresses(_connString); address.Address_1 = "Grasmere"; address.Address_2 = "Findon Road"; address.Address_Town = "Findon"; address.Address_City = string.Empty; address.Address_County = "West Sussex"; address.Address_Postcode = "BN14 0RD"; Guid?address_ID = (Guid?)address.Insert_Address(newUserId); if (address_ID != null) { People person = new People(_connString); person.Person_Forename = "Daren"; person.Person_Surname = "Cantrell"; person.Address_ID = address_ID; person.Person_Mobile = "07880 883089"; person.Person_Landline = "01903 877336"; person.Person_Email = AdminEmail; Guid?person_ID = person.Insert_Person(newUserId); if (person_ID != null) { UserPerson userPerson = new UserPerson(_connString); userPerson.User_ID = newUserId; userPerson.Person_ID = (Guid)person_ID; Guid?user_Person_ID = userPerson.Insert_User_Person(newUserId); } } }
/** * @overview Add toan bo user co trong he thong */ private void InitUserDict() { UserPerson u1 = new UserPerson("1", "123") { DisplayName = "Nguyen Van A", Status = 'F' }; UserPerson u2 = new UserPerson("2", "123") { DisplayName = "Tran Van B", Status = 'F' }; UserPerson u3 = new UserPerson("3", "123") { DisplayName = "Pham Van C", Status = 'F' }; UserPerson u4 = new UserPerson("4", "123") { DisplayName = "Trinh Van D", Status = 'F' }; m_userDictionary.Add(u1.Id, u1); m_userDictionary.Add(u2.Id, u2); m_userDictionary.Add(u3.Id, u3); m_userDictionary.Add(u4.Id, u4); }
public SessionServer(Id id, SessionToken sessionToken, UserPerson userPerson) { Id = id; SessionToken = sessionToken; UserPerson = userPerson; }
/** * @overview: logout of the chat system */ public void Logout(UserPerson up) { }