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 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 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 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);
        }
        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 });
        }