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); }
// 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); }
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); }
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 }); }
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); }
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 }); }
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); }
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 }); }
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); }
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 }); }
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 }); }
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 }); }
// 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); }
public ActionResult GetPopularCategory() { var repo = new Repository<PopularCategoryModel>(DbCollection.PopularCategory); var result = repo.Gets().ToList(); return Json(result, JsonRequestBehavior.AllowGet); }
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); }
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 }); }