コード例 #1
0
        public ActionResult Index(string account)
        {
            #region Comment

            //if (string.IsNullOrEmpty(account))
            //{
            //    account = Session["register-info"].ToString();
            //}
            //const string emailRegex = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";
            //const string phoneRegex = @"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$";
            //var mailRe = new Regex(emailRegex);
            //var phoneRe = new Regex(phoneRegex);
            //if (mailRe.IsMatch(account))
            //{
            //    model.User = repo.Gets().FirstOrDefault(m => m.Email.Equals(account));
            //}
            //else if (phoneRe.IsMatch(account))
            //{
            //    model.User = repo.Gets().FirstOrDefault(m => m.PhoneNumber.Equals(account));
            //}
            //else
            //{
            //    model.User = repo.Gets().FirstOrDefault(m => m.UserName.Equals(account));
            //}

            #endregion

            var model = new AboutViewModel();
            var repo = new Repository<UserModel>(DbCollection.User);
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var repoEducation = new Repository<EducationModel>(DbCollection.Education);
            var repoExperience = new Repository<ExperienceModel>(DbCollection.Experience);
            var repoExperienceEmployment = new Repository<ExperienceEmploymentModel>(DbCollection.ExperienceEmployment);
            var repoContact = new Repository<ContactModel>(DbCollection.Contact);
            var userId = !string.IsNullOrEmpty(account) ? account.Split('-').Last() : User.Identity.GetUserId();
            var user = repo.GetById(userId);
            model.User = user;
            var shareSetting = repoShare.Gets().First(m => m.UserId.Equals(userId));
            var share = new ShareViewModel
            {
                ShareSetting = shareSetting
            };
            model.Share = share;
            model.ListEducation = repoEducation.Gets().Where(m => m.UserId.Equals(userId)).ToList();
            model.Experience = repoExperience.Gets().FirstOrDefault(m => m.UserId.Equals(userId));
            model.ListExperienceEmployment = repoExperienceEmployment.Gets().Where(m => m.UserId.Equals(userId)).ToList();
            model.ListContact = repoContact.Gets().Where(m => m.UserId.Equals(userId)).ToList();
            // Read or Edit
            model.Modify = userId == User.Identity.GetUserId();
            model.FlIdUser = user.FirstName.UrlFriendly() + '-' + user.LastName.UrlFriendly() + "-" + user.Id;
            // Test Log
            Log.Error(new Exception("Test"));
            return View(model);
        }
コード例 #2
0
        // GET: Suggestion
        public ActionResult Index()
        {
            var model = new PhotosViewModel();
            var repo = new Repository<UserModel>(DbCollection.User);
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var userId = User.Identity.GetUserId();
            var user = repo.GetById(userId);
            model.User = user;
            var shareSetting = repoShare.Gets().First(m => m.UserId.Equals(userId));
            var share = new ShareViewModel
            {
                ShareSetting = shareSetting
            };
            model.Share = share;

            // Read or Edit
            model.Modify = userId == User.Identity.GetUserId();

            model.FlIdUser = user.FirstName.UrlFriendly() + '-' + user.LastName.UrlFriendly() + "-" + user.Id;
            // Test Log
            Log.Error(new Exception("Test"));
            return View(model);
        }
コード例 #3
0
 private UserModel GetOwnerUser()
 {
     var repo = new Repository<UserModel>(DbCollection.User);
     var id = User.Identity.GetUserId();
     var user = repo.GetById(id);
     return user;
 }
コード例 #4
0
        // GET: Suggestion
        public ActionResult Index()
        {
            var model = new SuggestionViewModel();
            var repo = new Repository<UserModel>(DbCollection.User);
            var repoEducation = new Repository<EducationModel>(DbCollection.Education);
            var repoSuggestion = new Repository<SuggestionModel>(DbCollection.SuggestionFriend);
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var userId = User.Identity.GetUserId();
            var user = repo.GetById(userId);
            model.User = user;
            var shareSetting = repoShare.Gets().First(m => m.UserId.Equals(userId));
            var share = new ShareViewModel
            {
                ShareSetting = shareSetting
            };
            model.Share = share;

            #region Get Suggestion List

            var userExistList =
                repoSuggestion.Gets().Where(m => m.UserId == userId).Select(m => m.UserSuggestionId).ToList();
            userExistList.Add(userId);

            // LOCATION - City
            var userLocation = new List<UserModel>();
            if (!string.IsNullOrEmpty(user.City))
            {
                var usersCity = repo.Gets().Where(m => !userExistList.Contains(m.Id.ToString()) && m.City == user.City).ToList();
                userExistList.Add(usersCity.ToString());
                // LOCATION - Country
                if (usersCity.Count < 5)
                {
                    if (!string.IsNullOrEmpty(user.Country))
                    {
                        var usersCountry =
                            repo.Gets()
                                .Where(m => m.Country == user.Country && !userExistList.Contains(user.Id.ToString()))
                                .ToList();
                        userExistList.Add(usersCountry.ToString());
                        userLocation = usersCity.Union(usersCountry).ToList();
                    }
                }
                else
                {
                    userLocation = usersCity;
                }
            }

            // EDUCTION
            var userEducation = new List<UserModel>();
            var listEducationOwner =
                repoEducation.Gets().Where(m => m.UserId.Equals(user.Id.ToString())).Select(m => m.SchoolName);
            var listUserEducationRelation = (from e in repoEducation.Gets().ToList()
                                             where listEducationOwner.Contains(e.SchoolName)
                                             select e).ToList();

            var listUserEducationString = listUserEducationRelation.Select(m => m.UserId).ToList();
            userEducation = repo.Gets().Where(m => listUserEducationString.Contains(user.Id.ToString()) && !userExistList.Contains(user.Id.ToString())).ToList();

            model.ListSuggestion = userLocation.Union(userEducation).ToList();

            #endregion

            // Read or Edit
            model.Modify = userId == User.Identity.GetUserId();

            model.FlIdUser = user.FirstName.UrlFriendly() + '-' + user.LastName.UrlFriendly() + "-" + user.Id;
            // Test Log
            Log.Error(new Exception("Test"));
            return View(model);
        }
コード例 #5
0
 public ActionResult Index(string account)
 {
     var model = new AboutViewModel();
     var repo = new Repository<UserModel>(DbCollection.User);
     var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
     var repoSystemShare = new Repository<SystemShareModel>(DbCollection.SystemShare);
     var repoEducation = new Repository<EducationModel>(DbCollection.Education);
     var repoExperience = new Repository<ExperienceModel>(DbCollection.Experience);
     var repoExperienceEmployment = new Repository<ExperienceEmploymentModel>(DbCollection.ExperienceEmployment);
     var repoContact = new Repository<ContactModel>(DbCollection.Contact);
     var repoContactType = new Repository<ContactTypeModel>(DbCollection.ContactType);
     var userId = !string.IsNullOrEmpty(account) ? account.Split('-').Last() : User.Identity.GetUserId();
     var user = repo.GetById(userId);
     model.User = user;
     var share = new ShareViewModel
     {
         ShareSetting = repoShare.Gets().First(m => m.UserId.Equals(userId)),
         ListSystemShare = repoSystemShare.Gets().Where(m => m.Enable.Equals(true)).ToList()
     };
     model.Share = share;
     model.ListEducation = repoEducation.Gets().Where(m => m.UserId.Equals(userId)).ToList();
     model.Experience = repoExperience.Gets().FirstOrDefault(m => m.UserId.Equals(userId)) ??
                        new ExperienceModel();
     model.ListExperienceEmployment = repoExperienceEmployment.Gets().Where(m => m.UserId.Equals(userId)).ToList();
     model.ListContact = repoContact.Gets().Where(m => m.UserId.Equals(userId)).ToList();
     model.ListContactType = repoContactType.Gets().ToList();
     // Read or Edit
     model.Modify = userId == User.Identity.GetUserId();
     model.FlIdUser = user.FirstName.UrlFriendly() + '-' + user.LastName.UrlFriendly() + "-" + user.Id;
     // Test Log
     Log.Error(new Exception("Test"));
     return View(model);
 }