コード例 #1
0
            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);
            }
コード例 #2
0
ファイル: Utils.cs プロジェクト: BadgerTadger/DSM
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
 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;
 }
コード例 #6
0
        public void TestBadRequestWithResponseId()
        {
            var caughtException = Assert.Throws <BadRequestException>(
                () => UserPerson.Get()
                );

            Assert.NotNull(caughtException.ResponseId);
        }
コード例 #7
0
        public void UnFriend(string userId, string friendId)
        {
            UserPerson user1 = m_userDictionary[userId];
            UserPerson user2 = m_userDictionary[friendId];

            user1.UnFriend(friendId);
            user2.UnFriend(userId);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: Client.cs プロジェクト: anhtv13/SignalR_Project
        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)
            {
            }
        }
コード例 #11
0
        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}", "");
            }
        }
コード例 #12
0
        public IHttpActionResult GetUserPerson(int id)
        {
            UserPerson userPerson = db.UserPerson.Find(id);

            if (userPerson == null)
            {
                return(NotFound());
            }

            return(Ok(userPerson));
        }
コード例 #13
0
ファイル: FarmAppService.cs プロジェクト: Betoso99/FarmApp
        public async Task <UserPerson> RegisterUserAsync(UserPerson userPerson)
        {
            var response = await farmAppApi.RegisterUser(userPerson);

            if (response.IsSuccessStatusCode)
            {
                return(response.Content);
            }

            return(null);
        }
コード例 #14
0
 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);
 }
コード例 #15
0
        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);
        }
コード例 #16
0
        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));
        }
コード例 #17
0
ファイル: FarmAppService.cs プロジェクト: Betoso99/FarmApp
        public async Task <UserPerson> GetUserAsync(int userId)
        {
            var response = await farmAppApi.GetUser(userId);

            if (response.IsSuccessStatusCode)
            {
                UserPerson user = response.Content;

                return(user);
            }

            return(null);
        }
コード例 #18
0
    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");
            }
        }
    }
コード例 #19
0
        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);
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        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();
        }
コード例 #22
0
ファイル: LogsPageViewModel.cs プロジェクト: Betoso99/FarmApp
        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());
        }
コード例 #23
0
        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);
        }
コード例 #24
0
    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;
            }
        }
    }
コード例 #25
0
        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);
        }
コード例 #26
0
        /**
         * @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);
        }
コード例 #27
0
ファイル: RunOnce.cs プロジェクト: BadgerTadger/DSM
        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);
                }
            }
        }
コード例 #28
0
        /**
         * @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);
        }
コード例 #29
0
 public SessionServer(Id id, SessionToken sessionToken, UserPerson userPerson)
 {
     Id           = id;
     SessionToken = sessionToken;
     UserPerson   = userPerson;
 }
コード例 #30
0
ファイル: MyHub.cs プロジェクト: anhtv13/SignalR_Project
 /**
  * @overview: logout of the chat system
  */
 public void Logout(UserPerson up)
 {
 }