Ejemplo n.º 1
0
        public static string AddUserSkill(string[] Skills, string[] LanuagesKnown)
        {
            UserProfileInfo userProfileInfo = new UserProfileInfo();
            string          message         = Constant.CONST_SKILL_INFORMATION_FAILURE;

            if (SessionWrapper.LoggedUser == null)
            {
                return(message = Constant.SESSION_EXPIRE);
            }
            int count = 0;

            try
            {
                UserSkill userSkill = new UserSkill();
                userSkill.UserId = SessionWrapper.LoggedUser.UserId;

                userSkill.UserAdditionalSkills = new List <UserAdditionalSkill>();
                UserAdditionalSkill userAdditional;
                while (count < Skills.Length)
                {
                    if (!String.IsNullOrEmpty(Skills[count]))
                    {
                        userAdditional       = new UserAdditionalSkill();
                        userAdditional.Skill = Skills[count].Trim();
                        userSkill.UserAdditionalSkills.Add(userAdditional);
                    }
                    count++;
                }


                userSkill.UserLanuagesKnowns = new List <UserLanuagesKnown>();
                UserLanuagesKnown userLanguages;
                count = 0;
                while (count < LanuagesKnown.Length)
                {
                    if (!String.IsNullOrEmpty(LanuagesKnown[count]))
                    {
                        userLanguages         = new UserLanuagesKnown();
                        userLanguages.Lanuage = LanuagesKnown[count].Trim();
                        userSkill.UserLanuagesKnowns.Add(userLanguages);
                    }
                    count++;
                }
                userProfileInfo = UserSkillHelper.SaveUserSkill(userSkill);
            }
            catch { }

            if (userProfileInfo.IsFirstRecord)
            {
                message = Constant.CONST_SKILL_ADD_SUCCESS;
            }
            else
            {
                message = Constant.CONST_SKILL_SUCCESS;
            }

            return(message);
        }
Ejemplo n.º 2
0
        public static bool DeleteUserSkill(int AdditionalSkillId)
        {
            bool isDeleted = false;

            try
            {
                Repository <UserAdditionalSkill> repository = new Repository <UserAdditionalSkill>("AdditionalSkillId");
                UserAdditionalSkill additionalSkill         = repository.SelectByKey(AdditionalSkillId.ToString());
                if (additionalSkill != null)
                {
                    repository.Delete(additionalSkill);
                    repository.Save();
                    isDeleted = true;
                }
            }
            catch { }
            return(isDeleted);
        }
Ejemplo n.º 3
0
        public static UserProfileInfo SaveUserSkill(UserSkill userSkill)
        {
            //bool isAdded = false;
            UserProfileInfo userProfileInfo = new UserProfileInfo();

            try
            {
                Repository <UserSkill> userSkillRepo = new Repository <UserSkill>("UserId");
                UserSkill userSkillInfo = userSkillRepo.SelectByKey(userSkill.UserId.ToString());
                if (userSkillInfo == null)
                {
                    userSkillRepo.Add(userSkill);
                    userSkillRepo.Save();
                    userProfileInfo.IsFirstRecord = true;
                }
                else
                {
                    int count = 0;
                    userProfileInfo.IsFirstRecord = false;
                    if (userSkill.UserAdditionalSkills != null)
                    {
                        UserAdditionalSkill AdditionalSkill;
                        Repository <UserAdditionalSkill>     AdditionalSkillRepository = new Repository <UserAdditionalSkill>();
                        ISpecification <UserAdditionalSkill> userAdditionalSkillSpc    = new Specification <UserAdditionalSkill>(u => u.UserSkillId == userSkillInfo.UserSkillId);
                        Repository <UserAdditionalSkill>     userAdditionalSkillRep    = new Repository <UserAdditionalSkill>();
                        IList <UserAdditionalSkill>          userAdditionalSkillList   = userAdditionalSkillRep.SelectAll(userAdditionalSkillSpc);

                        while (count < userSkill.UserAdditionalSkills.Count)
                        {
                            if (count < userAdditionalSkillList.Count)
                            {
                                if (userAdditionalSkillList[count] != null)
                                {
                                    userAdditionalSkillList[count].Skill = userSkill.UserAdditionalSkills[count].Skill;
                                    userAdditionalSkillRep.Save();
                                    count++;
                                }
                            }
                            else
                            {
                                AdditionalSkill             = new UserAdditionalSkill();
                                AdditionalSkill.Skill       = userSkill.UserAdditionalSkills[count].Skill;
                                AdditionalSkill.UserSkillId = userSkillInfo.UserSkillId;
                                AdditionalSkillRepository.Add(AdditionalSkill);
                                AdditionalSkillRepository.Save();
                                count++;
                            }
                        }
                    }

                    if (userSkill.UserLanuagesKnowns != null)
                    {
                        UserLanuagesKnown Lanuages;
                        Repository <UserLanuagesKnown>     LanuagesRepository    = new Repository <UserLanuagesKnown>();
                        ISpecification <UserLanuagesKnown> userLanuagesKnownSpc  = new Specification <UserLanuagesKnown>(u => u.UserSkillId == userSkillInfo.UserSkillId);
                        Repository <UserLanuagesKnown>     userLanuagesKnownRep  = new Repository <UserLanuagesKnown>();
                        IList <UserLanuagesKnown>          userLanuagesKnownList = userLanuagesKnownRep.SelectAll(userLanuagesKnownSpc);

                        count = 0;

                        while (count < userSkill.UserLanuagesKnowns.Count)
                        {
                            if (count < userLanuagesKnownList.Count)
                            {
                                if (userLanuagesKnownList[count] != null)
                                {
                                    userLanuagesKnownList[count].Lanuage = userSkill.UserLanuagesKnowns[count].Lanuage;
                                    userLanuagesKnownRep.Save();
                                    count++;
                                }
                            }
                            else
                            {
                                Lanuages             = new UserLanuagesKnown();
                                Lanuages.Lanuage     = userSkill.UserLanuagesKnowns[count].Lanuage;
                                Lanuages.UserSkillId = userSkillInfo.UserSkillId;
                                LanuagesRepository.Add(Lanuages);
                                LanuagesRepository.Save();
                                count++;
                            }
                        }
                    }
                    //isAdded = true;
                }
            }
            catch { }
            return(userProfileInfo);
        }