Пример #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);
        }
 public ActionResult Add(string id)
 {
     var repo = new Repository<SuggestionModel>(DbCollection.SuggestionFriend);
     var userId = User.Identity.GetUserId();
     var suggestion = new SuggestionModel
     {
         UserId = userId,
         UserSuggestionId = id,
         Created = DateTime.Now.ToString(),
         Enable = true
     };
     repo.Insert(suggestion);
     return Json(new { result = true });
 }
 public static Repository OpenRepository(DirectoryInfo workspace)
 {
     string rPath = Path.Combine(workspace.FullName, Global.RepositoryDirName);
     if (Directory.Exists(rPath))
     {
         RepositoryConfig conf = ReadRepositoryConfig(workspace);
         var r = new Repository(workspace);
         r.CurrentBranch = BranchManager.ReadBranch(workspace, conf.CurrentBranch);
         r.Remote = conf.Remote;
         SetCurrentWorkspaceDir(r.Workspace);
         WriteRepositoryConfig(workspace, r);
         return r;
     }
     return null;
 }
 // создает новый репозиторий в этой директории
 public static Repository CreateNewRepository(DirectoryInfo workspace)
 {
     string rPath = Path.Combine(workspace.FullName, Global.RepositoryDirName);
     if (!Directory.Exists(rPath))
     {
         var r = new Repository(workspace);
         Directory.CreateDirectory(rPath);
         Directory.CreateDirectory(r.BranchesDir.FullName);
         Directory.CreateDirectory(r.SnapshotDir.FullName);
         r.CurrentBranch = BranchManager.CreateMaster(workspace);
         SnapshotInfo s = SnapshotManager.CreateSnapshot(workspace, null);
         CommitUtil.Commit(s, workspace, Global.InitialCommitMessage);
         SetCurrentWorkspaceDir(r.Workspace);
         WriteRepositoryConfig(workspace, r);
         return r;
     }
     return null;
 }
Пример #5
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);
        }
Пример #6
0
 public void Create(string dir)
 {
     _r = RepositoryManager.CreateNewRepository(new DirectoryInfo(dir));
 }
Пример #7
0
        public ActionResult SettingEducation()
        {
            var model = new SettingEducationViewModel();
            var repoEducation = new Repository<EducationModel>(DbCollection.Education);
            model.ListEducation = repoEducation.Gets().Where(m => m.UserId.Equals(User.Identity.GetUserId())).ToList();

            #region Share
            var share = new ShareViewModel();
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var repoSystemShare = new Repository<SystemShareModel>(DbCollection.SystemShare);
            share.ShareSetting = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.ListSystemShare = repoSystemShare.Gets().Where(m => m.Enable.Equals(true)).ToList();
            model.Share = share;
            #endregion

            return PartialView("_EducationPartial", model);
        }
Пример #8
0
        public ActionResult SettingContact()
        {
            var model = new SettingContactViewModel();
            var repo = new Repository<ContactModel>(DbCollection.Contact);
            model.ListContact = repo.Gets().Where(m => m.UserId.Equals(User.Identity.GetUserId())).ToList();
            var repoContactType = new Repository<ContactTypeModel>(DbCollection.ContactType);
            model.ListContactType = repoContactType.Gets();
            #region Share
            var share = new ShareViewModel();
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var repoSystemShare = new Repository<SystemShareModel>(DbCollection.SystemShare);
            share.ShareSetting = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.ListSystemShare = repoSystemShare.Gets().Where(m => m.Enable.Equals(true)).ToList();
            model.Share = share;
            #endregion

            return PartialView("_ContactPartial", model);
        }
Пример #9
0
        public ActionResult SettingDetails(SettingBasicPostViewModel model)
        {
            var repo = new Repository<UserModel>(DbCollection.User);
            var user = GetOwnerUser();
            user.Personal = true;
            user.AdditionalInfo = model.User.AdditionalInfo;
            user.Modified = DateTime.Now.ToString();
            repo.Update(user);

            // Update ShareSetting
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var share = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.Detail = model.ShareSetting.Detail;
            repoShare.Update(share);
            return Json(new { result = true, model });
        }
Пример #10
0
        public ActionResult SettingBusinessHeadOffice(SettingBusinessPostViewModel model)
        {
            var repo = new Repository<UserModel>(DbCollection.User);
            var user = GetOwnerUser();
            user.Business = true;
            user.BAddress = model.User.BAddress;
            user.BTelephone = model.User.BTelephone;
            user.BWebsite = model.User.BWebsite;
            user.BEmail = model.User.BEmail;
            user.BContactPerson = model.User.BContactPerson;
            repo.Update(user);

            // Update ShareSetting
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var share = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.BusinessCompanyName = model.ShareSetting.BusinessCompanyName;
            share.BusinessDateOfFormation = model.ShareSetting.BusinessDateOfFormation;
            share.BusinessRegistrationNo = model.ShareSetting.BusinessRegistrationNo;
            repoShare.Update(share);
            return Json(new { result = true, model });
        }
Пример #11
0
        public ActionResult SettingBusinessMoreInfo(SettingBusinessPostViewModel model)
        {
            var repo = new Repository<UserModel>(DbCollection.User);
            var user = GetOwnerUser();
            user.Business = true;
            user.BCompanyField = model.User.BCompanyField;
            user.BOverview = model.User.BOverview;
            repo.Update(user);

            // Update ShareSetting
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var share = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.BusinessCompanyName = model.ShareSetting.BusinessCompanyName;
            share.BusinessDateOfFormation = model.ShareSetting.BusinessDateOfFormation;
            share.BusinessRegistrationNo = model.ShareSetting.BusinessRegistrationNo;
            repoShare.Update(share);
            return Json(new { result = true, model });
        }
Пример #12
0
 private UserModel GetOwnerUser()
 {
     var repo = new Repository<UserModel>(DbCollection.User);
     var id = User.Identity.GetUserId();
     var user = repo.GetById(id);
     return user;
 }
Пример #13
0
 public void OpenLast()
 {
     if (File.Exists(Global.RepositoryManagerConfigFilePath))
         _r = RepositoryManager.OpenLastRepository();
 }
Пример #14
0
        public ActionResult SettingEducation(SettingEducationPostViewModel model)
        {
            var repo = new Repository<EducationModel>(DbCollection.Education);
            if (model.ListEducation != null)
            {
                foreach (var item in model.ListEducation)
                {
                    item.UserId = User.Identity.GetUserId();
                    if (item.Id != new ObjectId("000000000000000000000000"))
                    {
                        repo.Update(item);
                    }
                    else
                    {
                        repo.Insert(item);
                    }
                }
            }

            // Delete
            if (!string.IsNullOrEmpty(model.Delete))
            {
                var listStrLineElements = model.Delete.Split(';').ToList();
                foreach (var itemDetail in listStrLineElements)
                {
                    repo.Delete(MyConstants.ConvertToObjectId(itemDetail));
                }
            }

            // Update ShareSetting
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var share = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.Education = model.ShareSetting.Education;
            repoShare.Update(share);
            return Json(new { result = true, model });
        }
Пример #15
0
        public ActionResult SettingExperience(SettingExperiencePostViewModel model)
        {
            var repo = new Repository<ExperienceModel>(DbCollection.Experience);
            var repoEmployment = new Repository<ExperienceEmploymentModel>(DbCollection.ExperienceEmployment);

            #region Experience
            var experience = repo.Gets().FirstOrDefault(m => m.UserId.Equals(User.Identity.GetUserId()));
            if (experience != null)
            {
                experience.Occupation = model.Experience.Occupation;
                experience.Skill = model.Experience.Skill;
                repo.Update(experience);
            }
            else
            {
                experience = new ExperienceModel
                {
                    UserId = User.Identity.GetUserId(),
                    Occupation = model.Experience.Occupation,
                    Skill = model.Experience.Skill
                };
                repo.Insert(experience);
            }
            #endregion

            if (model.ListExperienceEmployment != null)
            {
                foreach (var item in model.ListExperienceEmployment)
                {
                    item.UserId = User.Identity.GetUserId();
                    if (item.Id != new ObjectId("000000000000000000000000"))
                    {
                        repoEmployment.Update(item);
                    }
                    else
                    {
                        repoEmployment.Insert(item);
                    }
                }
            }

            // Delete
            if (!string.IsNullOrEmpty(model.Delete))
            {
                var listStrLineElements = model.Delete.Split(';').ToList();
                foreach (var itemDetail in listStrLineElements)
                {
                    repoEmployment.Delete(MyConstants.ConvertToObjectId(itemDetail));
                }
            }

            // Update ShareSetting
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var share = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.Occupation = model.ShareSetting.Occupation;
            share.Skill = model.ShareSetting.Skill;
            share.Employment = model.ShareSetting.Employment;
            repoShare.Update(share);
            return Json(new { result = true, model });
        }
Пример #16
0
        public ActionResult SettingContact(SettingContactPostViewModel model)
        {
            var repo = new Repository<ContactModel>(DbCollection.Contact);
            if (model.ListContact != null)
            {
                foreach (var item in model.ListContact)
                {
                    item.UserId = User.Identity.GetUserId();
                    if (item.Id != new ObjectId("000000000000000000000000"))
                    {
                        // Delete if empty data
                        var isDelete = string.IsNullOrEmpty(item.Type);
                        if (!string.IsNullOrEmpty(item.Content))
                        {
                            isDelete = false;
                        }
                        if (isDelete)
                        {
                            repo.Delete(item.Id);
                        }
                        else
                        {
                            repo.Update(item);
                        }
                    }
                    else
                    {
                        repo.Insert(item);
                    }
                }
            }

            // Delete
            if (!string.IsNullOrEmpty(model.Delete))
            {
                var listStrLineElements = model.Delete.Split(';').ToList();
                foreach (var itemDetail in listStrLineElements)
                {
                    repo.Delete(MyConstants.ConvertToObjectId(itemDetail));
                }
            }

            // Update ShareSetting
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var share = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.ContactHome = model.ShareSetting.ContactHome;
            share.ContactWork = model.ShareSetting.ContactWork;
            repoShare.Update(share);
            return Json(new { result = true, model });
        }
 public static void WriteRepositoryConfig(DirectoryInfo workspace, Repository r)
 {
     string rConfFilePath = Path.Combine(workspace.FullName, Global.RepositoryConfigFilePath);
     string xml = XmlUtility.Obj2XmlStr(r.GetConfiguration());
     File.WriteAllText(rConfFilePath, xml);
 }
Пример #18
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);
 }
Пример #19
0
 public ActionResult GetPopularCategory()
 {
     var repo = new Repository<PopularCategoryModel>(DbCollection.PopularCategory);
     var result = repo.Gets().ToList();
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Пример #20
0
        public ActionResult Job(JobModel model)
        {
            var repo = new Repository<JobModel>(DbCollection.Job);
            var result = 1;
            try
            {
                repo.Insert(model);
            }
            catch (Exception ex)
            {
                result = -100;
            }

            return Json(result);
        }
Пример #21
0
        public ActionResult SettingExperience()
        {
            var model = new SettingExperienceViewModel();
            var repo = new Repository<ExperienceModel>(DbCollection.Experience);
            var repoEmployment = new Repository<ExperienceEmploymentModel>(DbCollection.ExperienceEmployment);
            var experience = repo.Gets().FirstOrDefault(m => m.UserId.Equals(User.Identity.GetUserId()));
            if (experience != null)
            {
                model.Occupation = experience.Occupation;
                model.Skill = experience.Skill;
            }
            model.ListExperienceEmployment = repoEmployment.Gets().Where(m => m.UserId.Equals(User.Identity.GetUserId())).ToList();

            #region Share
            var share = new ShareViewModel();
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var repoSystemShare = new Repository<SystemShareModel>(DbCollection.SystemShare);
            share.ShareSetting = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.ListSystemShare = repoSystemShare.Gets().Where(m => m.Enable.Equals(true)).ToList();
            model.Share = share;
            #endregion

            return PartialView("_ExperiencePartial", model);
        }
        // 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);
        }
Пример #23
0
 public ActionResult SettingFlName(UserModel model)
 {
     var repo = new Repository<UserModel>(DbCollection.User);
     var user = GetOwnerUser();
     user.FirstName = model.FirstName;
     user.LastName = model.LastName;
     user.Modified = DateTime.Now.ToString();
     repo.Update(user);
     return Json(new { result = true, model });
 }
Пример #24
0
        public ActionResult SettingBasicInfo(SettingBasicPostViewModel model)
        {
            var repo = new Repository<UserModel>(DbCollection.User);
            var user = GetOwnerUser();
            user.Personal = true;
            user.Birthday = model.User.Birthday;
            user.Gender = model.User.Gender;
            user.NewGender = user.Gender == "Custom" ? model.User.NewGender : string.Empty;
            user.CountryId = model.User.CountryId;
            user.Country = model.User.Country;
            user.CityId = model.User.CityId;
            user.City = model.User.City;
            user.Modified = DateTime.Now.ToString();
            repo.Update(user);

            // Update ShareSetting
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var share = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.Birthday = model.ShareSetting.Birthday;
            share.Gender = model.ShareSetting.Gender;
            share.Country = model.ShareSetting.Country;
            share.City = model.ShareSetting.City;
            repoShare.Update(share);
            return Json(new { result = true, model });
        }
Пример #25
0
        public ActionResult SettingBasicInfo()
        {
            var model = new SettingBasicViewModel
            {
                User = GetOwnerUser()
            };

            #region Share
            var share = new ShareViewModel();
            var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting);
            var repoSystemShare = new Repository<SystemShareModel>(DbCollection.SystemShare);
            share.ShareSetting = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId()));
            share.ListSystemShare = repoSystemShare.Gets().Where(m => m.Enable.Equals(true)).ToList();
            model.Share = share;
            #endregion

            return PartialView("_BasicInfoPartial", model);
        }
Пример #26
0
 public void Open(string path)
 {
     _r = RepositoryManager.OpenRepository(new DirectoryInfo(path));
 }