public void OnLoginSuccess(User user, Login login, IInput input)
        {
            var fbLogin = login as FacebookLogin;
            if (fbLogin == null)
                return;

            fbLogin.AccessToken = input.Get<string>("access_token");
        }
        /// <summary>
        /// The method is being used in order to post status on a specific user wall
        /// </summary>
        /// <param name="i_StatusToPost">The status text to post</param>
        /// <param name="i_UserToPostIn">The user to post the status to</param>
        /// <returns></returns>
        public bool postStatus(string i_StatusToPost, User i_UserToPostIn)
        {
            bool valueToReturn = true;
            try
            {
                i_UserToPostIn.PostStatus(i_StatusToPost);
            }
            catch (FacebookOAuthException OAuthException)
            {
                MessageBox.Show(OAuthException.Source + ": " + OAuthException.Message);
                valueToReturn = false;
            }

            return valueToReturn;
        }
        /// <summary>
        /// Initialization of the User Info form
        /// </summary>
        /// <param name="i_LoggedInUser">Facebook logged in User</param>
        internal void Init(User i_LoggedInUser)
        {
            this.m_LoggedUser = i_LoggedInUser;
            this.Text = m_LoggedUser.Name;
            this.picture_UserPicture.LoadAsync(m_LoggedUser.PictureNormalURL);
            this.labelUserName.Text = m_LoggedUser.Name;
            this.labelBirthdayResult.Text = m_LoggedUser.Birthday;
            this.labelHometownResult.Text = m_LoggedUser.Hometown.Name;
            this.labelEmailResult.Text = m_LoggedUser.Email;
            this.labelSexResult.Text = m_LoggedUser.Gender.Value.ToString();
            this.labelReligionResult.Text = m_LoggedUser.Religion;

            if (m_LoggedUser.RelationshipStatus.HasValue)
            {
                User.eRelationshipStatus RelationshipStatus = m_LoggedUser.RelationshipStatus.Value;
                this.labelRelationshipResult.Text = RelationshipStatus.ToString();
            }

            this.m_IsInitialized = true;
        }
Esempio n. 4
0
        private void loginAndInit()
        {
            LoginResult result = FacebookService.Login(
                "1426551137587886",
                "user_about_me",
                "user_friends",
                "friends_about_me",
                "publish_stream",
                "user_events",
                "read_stream",
                "user_status",
                "user_photos");

            if (!string.IsNullOrEmpty(result.AccessToken))
            {
                LoggedInUser = result.LoggedInUser;
                new Thread(fetchUserInfo).Start();
            }
            else
            {
                MessageBox.Show("Login failed! please try again.");
            }
        }
 private void GnsClientOnAuthenticateCompleted(object sender, AuthenticateCompletedEventArgs e)
 {
     if (e.Result != null && e.Error == null)
     {
         UserMe = e.Result;
         MainGrid.Visibility = Visibility.Visible;
         WelcomeGrid.Visibility = Visibility.Collapsed;
         _childWindow = new ChildWindowAddGameNick( _gnsClient, UserMe);
         LoadTabFriends();
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Uses DOM parsing to constitute a PhotoTag data object given the xml returned from facebook
        /// </summary>
        internal static User ParseUser(XmlNode node)
        {
            User user = new User();
            user.UserId = XmlHelper.GetNodeText(node, "uid");
            user.FirstName = XmlHelper.GetNodeText(node, "first_name");
            user.LastName = XmlHelper.GetNodeText(node, "last_name");
            user.Name = XmlHelper.GetNodeText(node, "name");

            if (!String.IsNullOrEmpty(XmlHelper.GetNodeText(node, "pic")))
            {
                user.PictureUrl = new Uri(XmlHelper.GetNodeText(node, "pic"));
            }

            user.Religion = XmlHelper.GetNodeText(node, "religion");
            DateTime tempDate;
            if (DateTime.TryParse(XmlHelper.GetNodeText(node, "birthday"), out tempDate))
            {
                user.Birthday = tempDate;
            }

            if (!String.IsNullOrEmpty(XmlHelper.GetNodeText(node, "profile_update_time"))  && double.Parse(XmlHelper.GetNodeText(node, "profile_update_time")) > 0)
            {
                user.ProfileUpdateDate = DateHelper.ConvertDoubleToDate(double.Parse(XmlHelper.GetNodeText(node, "profile_update_time"), CultureInfo.InvariantCulture));
            }

            if (!String.IsNullOrEmpty(XmlHelper.GetNodeText(node, "sex")))
            {
                user.Sex = (Gender)Enum.Parse(typeof(Gender), XmlHelper.GetNodeText(node, "sex"), true);
            }

            if (!String.IsNullOrEmpty(XmlHelper.GetNodeText(node, "relationship_status")))
            {
                user.RelationshipStatus = (RelationshipStatus)Enum.Parse(typeof(RelationshipStatus), XmlHelper.GetNodeText(node, "relationship_status").Replace(" ", "").Replace("'", ""), true);
            }

            user.SignificantOtherId = XmlHelper.GetNodeText(node, "significant_other_id");

            if (!String.IsNullOrEmpty(XmlHelper.GetNodeText(node, "political")))
            {
                user.PoliticalView = (PoliticalView)Enum.Parse(typeof(PoliticalView), XmlHelper.GetNodeText(node, "political").Replace(" ", ""), true);
            }

            user.Activities = XmlHelper.GetNodeText(node, "activities");
            user.Interests = XmlHelper.GetNodeText(node, "interests");
            user.Music = XmlHelper.GetNodeText(node, "music");
            user.TVShows = XmlHelper.GetNodeText(node, "tv");
            user.Movies = XmlHelper.GetNodeText(node, "movies");
            user.Books = XmlHelper.GetNodeText(node, "books");
            user.Quotes = XmlHelper.GetNodeText(node, "quotes");
            user.AboutMe = XmlHelper.GetNodeText(node, "about_me");

            int tempInt = 0;
            if (int.TryParse(XmlHelper.GetNodeText(node, "notes_count"), out tempInt))
            {
                user.NotesCount = tempInt;
            }
            if (int.TryParse(XmlHelper.GetNodeText(node, "wall_count"), out tempInt))
            {
                user.WallCount = tempInt;
            }

            XmlNodeList statusNodeList = ((XmlElement)node).GetElementsByTagName("status");
            user.Status.Message = XmlHelper.GetNodeText(statusNodeList[statusNodeList.Count-1], "message");
            if (!String.IsNullOrEmpty(XmlHelper.GetNodeText(statusNodeList[statusNodeList.Count - 1], "time")))
            {
                user.Status.Time = DateHelper.ConvertDoubleToDate(double.Parse(XmlHelper.GetNodeText(statusNodeList[statusNodeList.Count - 1], "time"), CultureInfo.InvariantCulture));
            }

            XmlElement xmlElement = node as XmlElement;

            //affiliations
            NetworkParser.ParseNetworks(xmlElement.GetElementsByTagName("affiliations")[0], user.Affiliations);

            //meeting_sex
            user.InterestedInGenders = ParseInterestedInGenders(xmlElement.GetElementsByTagName("meeting_sex")[0]);

            //interested_in
            user.InterstedInRelationshipTypes = ParseRelationshipTypes(xmlElement.GetElementsByTagName("meeting_for")[0]);

            //hometown_location
            user.HometownLocation = LocationParser.ParseLocation(xmlElement.GetElementsByTagName("hometown_location")[0]);

            //curent_location
            user.CurrentLocation = LocationParser.ParseLocation(xmlElement.GetElementsByTagName("current_location")[0]);

            //school_history
            user.SchoolHistory = SchoolHistoryParser.ParseSchoolHistory(xmlElement.GetElementsByTagName("hs_info")[0], xmlElement.GetElementsByTagName("education_history")[0]);

            //work_history
            user.WorkHistory = WorkParser.ParseWorkHistory(xmlElement.GetElementsByTagName("work_history")[0]);

            return user;
        }
Esempio n. 7
0
 /// <summary>
 /// Friends list changed index event
 /// </summary>
 /// <param name="sender">List box</param>
 /// <param name="e">Event Args</param>
 public void ListBoxFriends_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (sender is ListBox)
     {
         ListBox friendsListBox = sender as ListBox;
         if (null != friendsListBox.SelectedItem)
         {
             this.User = friendsListBox.SelectedItem as User;
             this.ProfilePictureBox.LoadAsync(this.User.PictureLargeURL);
             if (this.User.Albums.Count > 0)
             {
                 this.AlbumsListBox.Invoke(new Action(() => this.AlbumsListBox.Items.Clear()));
                 this.displaySelectedAlbums(this.User.Albums.ToArray());
             }
         }
     }
 }
Esempio n. 8
0
 private void initApp(LoginResult i_Results)
 {
     m_LoggedInUser = i_Results.LoggedInUser;
     new Thread(() => fetchUserInfo()).Start();
     doAfterLogin();
 }
Esempio n. 9
0
        private void LoadWorkInfoPanel(User user)
        {
            tlpWork.Controls.Clear();

            if (user.WorkHistory != null && user.WorkHistory.Count > 0)
            {
                int row = 0;

                foreach(Work job in user.WorkHistory)
                {
                    if (!String.IsNullOrEmpty(job.CompanyName))
                    {
                        tlpWork.Controls.Add(CreatePromptLabel(Facebook.Properties.Resources.lblEmployer), 0, row);
                        tlpWork.Controls.Add(CreateValueLabel(job.CompanyName), 1, row);
                        row++;
                    }
                    if (!String.IsNullOrEmpty(job.Position))
                    {
                        tlpWork.Controls.Add(CreatePromptLabel(Facebook.Properties.Resources.lblPosition), 0, row);
                        tlpWork.Controls.Add(CreateValueLabel(job.Position), 1, row);
                        row++;
                    }
                    if (job.StartDate != null)
                    {
                        StringBuilder timePeriod = new StringBuilder();
                        timePeriod.Append(job.StartDate.ToString("MM/yyyy", CultureInfo.InvariantCulture));
                        timePeriod.Append(" - ");

                        if (job.EndDate == DateTime.MinValue)
                            timePeriod.Append("Present");
                        else
                            timePeriod.Append(job.EndDate.ToString("MM/yyyy", CultureInfo.InvariantCulture));

                        tlpWork.Controls.Add(CreatePromptLabel(Facebook.Properties.Resources.lblTimePeriod), 0, row);
                        tlpWork.Controls.Add(CreateValueLabel(timePeriod.ToString()), 1, row);
                        row++;
                    }
                    if (job.Location != null)
                    {
                        tlpWork.Controls.Add(CreatePromptLabel(Facebook.Properties.Resources.lblLocation), 0, row);
                        tlpWork.Controls.Add(CreateValueLabel(job.Location.ToString()), 1, row);
                        row++;
                    }
                    if (!String.IsNullOrEmpty(job.Description))
                    {
                        tlpWork.Controls.Add(CreatePromptLabel(Facebook.Properties.Resources.lblDescription), 0, row);
                        tlpWork.Controls.Add(CreateValueLabel(job.Description), 1, row);
                        row++;
                    }

                    tlpWork.Controls.Add(new Label(), 0, row);
                    tlpWork.Controls.Add(new Label(), 1, row);
                    row++;
                }

                foreach (RowStyle rowStyle in tlpWork.RowStyles)
                {
                    rowStyle.SizeType = SizeType.AutoSize;
                }
            }
        }
        internal bool Login()
        {
            bool isLoggedIn = false;

            // Login
            m_result = FacebookService.Login(
                "523116184522448",
                "public_profile",
                "user_posts",
                "user_photos",
                "user_events");

            // Verify input
            if (!string.IsNullOrEmpty(m_result.AccessToken))
            {
                isLoggedIn = true;
                m_LoggedInUser = m_result.LoggedInUser;
            }

            return isLoggedIn;
        }
Esempio n. 11
0
        public async Task<User> RegisterJobseeker(RegisterJobseekerParams registerJobseekerParams)
        {
            Utils.CheckNullOrEmpty(new List<string> { "Email", "Token", "AccountType" }, registerJobseekerParams.Email, registerJobseekerParams.Token, registerJobseekerParams.AccountType);

            if (!Utils.IsEmail(registerJobseekerParams.Email))
            {
                throw new UserException(ErrorCode.EMAIL_INVALID.ToString());
            }

            using (AppDbContext context = new AppDbContext())
            {
                if (await context.Users.AnyAsync(p => p.Email == registerJobseekerParams.Email))
                {
                    throw new UserException(ErrorCode.EMAIL_IN_USED.ToString());
                }

                byte[] imageBytes = null;
                bool activated = true;
                string confirmationCode = string.Empty;
                if (registerJobseekerParams.AccountType == AccountType.Email)
                {
                    activated = false;
                    confirmationCode = Guid.NewGuid().ToString();
                    registerJobseekerParams.Token = UtilsCryptography.GenerateBCryptHash(registerJobseekerParams.Token);

                }
                else if (registerJobseekerParams.AccountType == AccountType.Facebook)
                {
                    try
                    {
                        FacebookClient facebookClient = new FacebookClient(registerJobseekerParams.Token);
                        await facebookClient.GetTaskAsync("me?fields=id");

                        WebClient webClient = new WebClient();
                        imageBytes = webClient.DownloadData(registerJobseekerParams.AvatarPath);
                        registerJobseekerParams.Token = null;
                    }
                    catch (Exception)
                    {
                        throw new UserException(ErrorCode.FACEBOOK_INVALID.ToString());
                    }

                }
                else
                {
                    try
                    {
                        string query = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + registerJobseekerParams.Token;
                        HttpClient client = new HttpClient();
                        await client.GetStringAsync(query);

                        WebClient webClient = new WebClient();
                        imageBytes = webClient.DownloadData(registerJobseekerParams.AvatarPath);
                        registerJobseekerParams.Token = null;
                    }
                    catch (Exception)
                    {
                        throw new UserException(ErrorCode.GOOGLE_INVALID.ToString());
                    }
                }

                User user = new User
                {
                    Id = Guid.NewGuid(),
                    Email = registerJobseekerParams.Email,
                    Password = registerJobseekerParams.Token,
                    AccountType = registerJobseekerParams.AccountType,
                    UserType = UserType.JobSeeker,
                    RegisteredDateUtc = DateTime.UtcNow,
                    IsActivated = activated,
                    ConfirmationCode = confirmationCode
                };
                context.Users.Add(user);

                Language defaultLanguage = await context.Languages.FirstOrDefaultAsync(p => p.Name == "English - United States");


                if (registerJobseekerParams.AccountType != AccountType.Email)
                {
                    registerJobseekerParams.DayOfBirthUtc = new DateTime(2000, 1, 1);
                    registerJobseekerParams.NRICType = NRICType.Citizen;
                }

                JobSeeker jobSeeker = new JobSeeker
                {
                    UserId = user.Id,
                    Avartar = imageBytes,
                    FullName = registerJobseekerParams.FullName,
                    Gender = Gender.Male,
                    NRICNumber = registerJobseekerParams.NRICNumber,
                    DateOfBirth = registerJobseekerParams.DayOfBirthUtc,
                    NRICType = registerJobseekerParams.NRICType,
                    ExperienceYear = ExperienceYear.Student,
                    LanguageId = defaultLanguage.Id,
                    CanNegotiation = true,
                    CreatedDateUtc = DateTime.UtcNow,
                    UpdatedDateUtc = DateTime.UtcNow
                };
                context.JobSeekers.Add(jobSeeker);

                await context.SaveChangesAsync();

                if (user.IsActivated)
                {
                    await EmailDelivery.SendJobSeekerRegisterCompleted(registerJobseekerParams.Email);
                }
                else
                {
                    await EmailDelivery.SendJobSeekerRegisterActivation(registerJobseekerParams.Email, confirmationCode);
                    return null;
                }

                return user;
            }
        }
Esempio n. 12
0
        private void loginAndInit()
        {
            LoginResult result = FacebookService.Login(
                m_AppId,
                "public_profile",
                "user_education_history",
                "user_birthday",
                "user_actions.video",
                "user_actions.news",
                "user_actions.music",
                "user_actions.fitness",
                "user_actions.books",
                "user_about_me",
                "user_friends",
                "publish_actions",
                "user_events",
                "user_games_activity",
                "user_hometown",
                "user_likes",
                "user_location",
                "user_managed_groups",
                "user_photos",
                "user_posts",
                "user_relationships",
                "user_relationship_details",
                "user_religion_politics",
                "user_tagged_places",
                "user_videos",
                "user_website",
                "user_work_history",
                "read_custom_friendlists",
                "read_page_mailboxes",
                "manage_pages",
                "publish_pages",
                "publish_actions",
                "rsvp_event");

            if (!string.IsNullOrEmpty(result.AccessToken))
            {
                m_LoggedInUser = result.LoggedInUser;
                fetchUserInfo();
                doAfterLogin();
            }
            else
            {
                MessageBox.Show(result.ErrorMessage);
            }
        }
Esempio n. 13
0
        internal bool Login()
        {
            bool isLoggedIn = false;

            // Login
            m_Result = FacebookService.Login(
                "523116184522448",
                "public_profile",
                "user_posts",
                "user_photos",
                "user_events");

            // Verify input
            if (!string.IsNullOrEmpty(m_Result.AccessToken))
            {
                isLoggedIn = true;
                m_LoggedInUser = m_Result.LoggedInUser;
                m_BasicUserInfo = new UserInfo();
                m_BasicUserInfo.m_Name = m_LoggedInUser.Name;
                m_BasicUserInfo.m_Bio = m_LoggedInUser.Bio;
                m_BasicUserInfo.m_ProfilePicture = m_LoggedInUser.ImageNormal;
            }

            return isLoggedIn;
        }
        private bool isLoggedIn(LoginResult i_LoginResult)
        {
            bool loggedIn = false;

            if (!string.IsNullOrEmpty(i_LoginResult.AccessToken) && string.IsNullOrEmpty(i_LoginResult.ErrorMessage))
            {
                loggedIn = true;
                m_LoggedInUser = i_LoginResult.LoggedInUser;
            }

            return loggedIn;
        }
        /// <summary>
        /// Logout the user from Facebook
        /// </summary>
        internal void LogoutFromFacebook()
        {
            m_LoggedInUser = null;
            m_LoggedIn = false;

            if (OnLoginChanged != null)
            {
                OnLoginChanged(this.LoggedIn);
            }
        }
Esempio n. 16
0
 /// <summary>
 /// Friends list changed index event
 /// </summary>
 /// <param name="sender">List box</param>
 /// <param name="e">Event Args</param>
 public void ListBoxFriends_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (sender is ListBox)
     {
         ListBox friendsListBox = sender as ListBox;
         this.User = friendsListBox.SelectedItem as User;
         this.ProfilePictureBox.LoadAsync(this.User.PictureLargeURL);
         this.displaySelectedAlbums();
     }
 }
 private void GnsClientOnRemoveGameNickCompleted(object sender, RemoveGameNickCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         UserMe = e.Result;
     }
 }
        /// <summary>
        /// On Connected
        /// </summary>
        /// <param name="task"></param>
        private static void OnConnectReceived(Task<Object> task)
        {
            try
            {
                _user = new User(task.Result.ToString());

                // Load facebook achievements and progress
                PlayerProgress.Load(_user.Id);

                // Set Authorized
                Connection |= FacebookState.Authorized;

                //string profilePictureUrl = String.Format("/{0}/picture?type={1}", _user.Id, "square");

            }
            catch (AggregateException aex)
            {
                aex.Handle((e) =>
                    {
                        if (e is FacebookOAuthException)
                        {

                        }

                        return false;
                    });
            }
        }
 private void GnsClientOnUpdateStatusCompleted(object sender, UpdateStatusCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         UserMe = e.Result;
     }
 }
Esempio n. 20
0
 private void LoadPersonalInfoPanel(User user)
 {
     SetRowValue(tlpPersonal, lblActivities, user.Activities);
     SetRowValue(tlpPersonal, lblInterests, user.Interests);
     SetRowValue(tlpPersonal, lblFavoriteMusic, user.Music);
     SetRowValue(tlpPersonal, lblFavoriteTVShows, user.TVShows);
     SetRowValue(tlpPersonal, lblFavoriteMovies, user.Movies);
     SetRowValue(tlpPersonal, lblFavoriteBooks, user.Books);
     SetRowValue(tlpPersonal, lblFavoriteQuotes, user.Quotes);
     SetRowValue(tlpPersonal, lblAboutMe, user.AboutMe);
 }
Esempio n. 21
0
        public async Task<bool> RegisterEmployer(RegisterEmployerParam registerEmployerParam)
        {
            if (!Utils.IsEmail(registerEmployerParam.Email))
            {
                throw new UserException(ErrorCode.EMAIL_INVALID.ToString());
            }

            using (AppDbContext context = new AppDbContext())
            {
                if (await context.Users.AnyAsync(p => p.Email == registerEmployerParam.Email))
                {
                    throw new UserException(ErrorCode.EMAIL_IN_USED.ToString());
                }

                Random generator = new Random();
                string password = generator.Next(100000, 999999).ToString();

                User user = new User
                {
                    Id = Guid.NewGuid(),
                    Email = registerEmployerParam.Email,
                    Password = UtilsCryptography.GenerateBCryptHash(password),
                    AccountType = AccountType.Email,
                    UserType = UserType.Employer,
                    RegisteredDateUtc = DateTime.UtcNow,
                    IsActivated = true,
                    ConfirmationCode = ""
                };
                context.Users.Add(user);

                Employer employer = new Employer
                {
                    CompanyName = registerEmployerParam.CompanyName,
                    CompanyRegistrationNumber = registerEmployerParam.CompanyRegistrationNumber,
                    ContactName = registerEmployerParam.ContactName,
                    PhoneNumber = registerEmployerParam.ContactNumber,
                    NatureOfBusiness = registerEmployerParam.NaturalOfBusiness,
                    OverView = registerEmployerParam.Message,
                    CreatedDateUtc = DateTime.UtcNow,
                    UpdatedDateUtc = DateTime.UtcNow,
                    UserId = user.Id,
                };
                context.Employers.Add(employer);

                await context.SaveChangesAsync();
                await EmailDelivery.SendEmployerRegisterCompleted(registerEmployerParam.Email, password);

                return true;
            }
        }
Esempio n. 22
0
        // authenticates and registers the user at the dobberman service
        void Register_User()
        {
            this.loading.Visibility=Visibility.Visible;
            var fb = new FacebookClient(_accessToken);

            fb.GetCompleted += (o, args) =>
            {
                if (args.Error == null)
                {
                    _me = (IDictionary<string, object>)args.GetResultData();

                    Dispatcher.BeginInvoke(
                        () =>
                        {
                            //Welcome.Text = "Welcome " + _me["first_name"] + "!";

                            DobbermanServiceClient client = new DobbermanServiceClient();
                            User user = new User()
                            {
                                Name = (string)_me["name"],
                                Email = (string)_me["email"],
                            };
                            client.CreateNewUserCompleted += new EventHandler<CreateNewUserCompletedEventArgs>(client_CreateNewUserCompleted);
                            client.CreateNewUserAsync(user);

                        });
                }
                else
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
                }
            };

            // do a GetAsync me in order to get basic details of the user.
            fb.GetAsync("me");
        }
Esempio n. 23
0
        private void LoadEducationInfoPanel(User user)
        {
            tpEducation.Controls.Clear();

            if (user.SchoolHistory != null)
            {
                if (user.SchoolHistory.HigherEducation != null)
                {
                    StringBuilder collegeText = new StringBuilder();

                    foreach (HigherEducation higherEducation in user.SchoolHistory.HigherEducation)
                    {
                        collegeText.Append(higherEducation.School);
                        collegeText.Append(" '");
                        if (higherEducation.ClassYear > 0)
                            collegeText.AppendLine(higherEducation.ClassYear.ToString(CultureInfo.InvariantCulture).Substring(2));

                        foreach (string concentration in higherEducation.Concentration)
                        {
                            collegeText.AppendLine(concentration);
                        }
                    }
                    SetRowValue(tlpEducation, lblCollege, collegeText.ToString().Trim());
                }

                if (user.SchoolHistory.HighSchool != null)
                {
                    StringBuilder highSchoolText = new StringBuilder();

                    if (!String.IsNullOrEmpty(user.SchoolHistory.HighSchool.HighSchoolOneName))
                    {
                        highSchoolText.Append(user.SchoolHistory.HighSchool.HighSchoolOneName);

                        if (user.SchoolHistory.HighSchool.GraduationYear > 0)
                        {
                            highSchoolText.Append(" '");
                            if (user.SchoolHistory.HighSchool.GraduationYear > 0)
                            {
                                highSchoolText.AppendLine(user.SchoolHistory.HighSchool.GraduationYear.ToString(CultureInfo.InvariantCulture).Substring(2));
                            }
                        }
                    }

                    if (!String.IsNullOrEmpty(user.SchoolHistory.HighSchool.HighSchoolTwoName))
                    {
                        highSchoolText.AppendLine(user.SchoolHistory.HighSchool.HighSchoolTwoName);
                    }

                    SetRowValue(tlpEducation, lblHighSchool, highSchoolText.ToString().Trim());
                }
            }
        }
 public ActionResult LoginHome(User _user, string returnurl)
 {
     int exmineeid = 0;
     if (string.IsNullOrEmpty(_user.UserName))
     {
         ModelState.AddModelError("", ErrorCode.UserNameNull);
     }
     if (string.IsNullOrEmpty(_user.Password))
     {
         ModelState.AddModelError("", ErrorCode.PasswordNull);
     }
     foreach (var item in ModelState.Values)
     {
         if (item.Errors.Count() != 0)
         {
             return View(_user);
         }
     }
     if (UserService.Login(_user, ref Username, ref Userid, ref Groupid, ref exmineeid) == true)
     {
         Session["UserName"] = Username;
         Session["UserID"] = Userid;
         Session["UserGroup"] = Groupid; Session["ExamineeID"] = exmineeid;
         return RedirectToAction("Index", "Home");
     }
     else
     {
         Session["UserName"] = null;
         Session["UserGroup"] = null;
         Session["UserID"] = null; Session["ExamineeID"] = null;
         ModelState.AddModelError("", "Tài khoản hoặc mật khẩu không đúng");
         return View(_user);
     }
 }
Esempio n. 25
0
 private void LoadPicture(User user)
 {
     pbProfilePicture.Image = user.Picture;
 }
        public ActionResult Register(User _model)
        {
            try
            {
                if (string.IsNullOrEmpty(_model.UserName))
                {
                    ModelState.AddModelError("", ErrorCode.UserNameNull);
                }
                if (string.IsNullOrEmpty(_model.Name))
                {
                    ModelState.AddModelError("", "Chưa nhập tên");
                }
                if (string.IsNullOrEmpty(_model.Password))
                {
                    ModelState.AddModelError("", ErrorCode.PasswordNull);
                }
                if (string.IsNullOrEmpty(_model.Address))
                {
                    ModelState.AddModelError("", ErrorCode.AddressNull);
                }
                if (_model.Password != _model.TempPassWordExt)
                {
                    ModelState.AddModelError("", ErrorCode.differentPassword);
                }
                if (UserService.GetByUserName(_model.UserName) != null)
                {
                    ModelState.AddModelError("", ErrorCode.existUserName);
                }
                if (UserService.GetByEmail(_model.Email) != null)
                {
                    ModelState.AddModelError("", ErrorCode.existEmail);
                }
                if (_model.Email != null && Regex.IsMatch(_model.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z") == false)
                {
                    ModelState.AddModelError("", ErrorCode.NotValidEmail);
                }
                if (_model.Phone != null && Regex.IsMatch(_model.Phone, @"\d+") == false)
                {
                    ModelState.AddModelError("", ErrorCode.NotValidPhoneNumber);
                }
                if (string.IsNullOrEmpty(_model.Phone))
                {
                    ModelState.AddModelError("", "Số điện thoại không được trống");
                }
                foreach (var item in ModelState.Values)
                {
                    if (item.Errors.Count() != 0)
                    {
                        return View(_model);
                    }
                }
                _model.Active = true;
                _model.GroupIDExt = 1;
                string pass = _model.Password;
                long userid =this.UserService.Save(_model);
                _model.Password = pass;
                int exmineeid = 0;
                if (userid != -1)
                {

                    if (UserService.Login(_model, ref Username, ref Userid, ref Groupid, ref exmineeid) == true)
                    {
                        Session["UserName"] = Username;
                        Session["UserID"] = Userid;
                        Session["UserGroup"] = Groupid;
                        Session["ExamineeID"] = exmineeid;
                        return RedirectToAction("Profile", "User");
                    }
                    return RedirectToAction("Index", "Home");
                }

                ModelState.AddModelError("", ErrorCode.Error);
                return View(_model);
            }
            catch
            {
                ModelState.AddModelError("", ErrorCode.UserNameNull);
                return View(_model);
            }
        }
Esempio n. 27
0
        private void LoadBasicInfoPanel(User user)
        {
            lblName.Text = user.Name;
            lblLocation.Text = user.CurrentLocation.ToString();

            SetRowValue(tlpBasic, lblSex, EnumHelper.GetEnumDescription(user.Sex));
            SetRowValue(tlpBasic, lblInterestedIn, EnumHelper.GetEnumCollectionDescription(user.InterestedInGenders));
            SetRowValue(tlpBasic, lblRelationshipStatus, EnumHelper.GetEnumDescription(user.RelationshipStatus));
            SetRowValue(tlpBasic, lblLookingFor, EnumHelper.GetEnumCollectionDescription(user.InterstedInRelationshipTypes));
            if (user.Birthday != null)
            {
                SetRowValue(tlpBasic, lblBirthday, user.Birthday.Value.ToString("MMMM d, yyyy", CultureInfo.InvariantCulture));
            }
            else
            {
                SetRowValue(tlpBasic, lblBirthday, string.Empty);
            }
            SetRowValue(tlpBasic, lblHometown, user.HometownLocation.ToString());
            SetRowValue(tlpBasic, lblPoliticalViews, EnumHelper.GetEnumDescription(user.PoliticalView));
            SetRowValue(tlpBasic, lblReligiousViews, user.Religion);
        }
Esempio n. 28
0
 public Utilities(User i_LoggedInUser)
 {
     m_LoggedInUser = i_LoggedInUser;
 }