Esempio n. 1
0
        public int SaveSkill(ApplicantSkill skill)
        {
            using (var entities = new atmEntities())
            {
                var exist = (from a in entities.tblApplicantSkills where a.ApplicantId == skill.ApplicantId && a.SkillCd == skill.SkillCd select a).SingleOrDefault();
                if (exist != null)
                {
                    skill.ApplicantSkillId = exist.ApplicantSkillId;
                    return UpdateSkill(skill);
                }

                if (skill.ApplicantSkillId != 0) { return UpdateSkill(skill); }

                var s = new tblApplicantSkill
                {
                    AchievementCd = skill.AchievementCd,
                    ApplicantId = skill.ApplicantId,
                    CreatedBy = skill.CreatedBy,
                    CreatedDt = skill.CreatedDt,
                    LanguageSkillSpeak = skill.LanguageSkillSpeak,
                    LanguageSkillWrite = skill.LanguageSkillWrite,
                    Others = skill.Others,
                    SkillCatCd = !string.IsNullOrWhiteSpace(skill.SkillCatCd) ? skill.SkillCatCd.Trim() : skill.SkillCatCd,
                    SkillCd = !string.IsNullOrWhiteSpace(skill.SkillCd) ? skill.SkillCd.Trim() : skill.SkillCd
                };
                entities.tblApplicantSkills.Add(s);
                if (entities.SaveChanges() > 0)
                    return s.ApplicantSkillId;

            }
            return 0;
        }
Esempio n. 2
0
        public int UpdateSkill(ApplicantSkill skill)
        {
            using (var entities = new atmEntities())
            {
                var exist = (from a in entities.tblApplicantSkills where a.ApplicantSkillId == skill.ApplicantSkillId select a).SingleOrDefault();
                if (exist != null)
                {
                    exist.AchievementCd = skill.AchievementCd;
                    exist.ApplicantId = skill.ApplicantId;
                    exist.LastModifiedBy = skill.LastModifiedBy;
                    exist.LastModifiedDt = skill.LastModifiedDt;
                    exist.LanguageSkillSpeak = skill.LanguageSkillSpeak;
                    exist.LanguageSkillWrite = skill.LanguageSkillWrite;
                    exist.Others = skill.Others;
                    exist.SkillCatCd = !string.IsNullOrWhiteSpace(skill.SkillCatCd) ? skill.SkillCatCd.Trim() : skill.SkillCatCd;
                    exist.SkillCd = !string.IsNullOrWhiteSpace(skill.SkillCd) ? skill.SkillCd.Trim() : skill.SkillCd;

                    entities.SaveChanges();
                    return exist.ApplicantSkillId;
                }
            }
            return 0;
        }
Esempio n. 3
0
        public IEnumerable<ApplicantSkill> GetSkill(int applicantid)
        {
            var list = new List<ApplicantSkill>();
            using (var entities = new atmEntities())
            {
                var l = from a in entities.tblApplicantSkills where a.ApplicantId == applicantid select a;
                if (l.Any())
                {
                    foreach (var s in l)
                    {
                        var apps = new ApplicantSkill
                        {
                            AchievementCd = s.AchievementCd,
                            CreatedBy = s.CreatedBy,
                            CreatedDt = s.CreatedDt,
                            LastModifiedBy = s.LastModifiedBy,
                            LastModifiedDt = s.LastModifiedDt,
                            ApplicantId = s.ApplicantId,
                            ApplicantSkillId = s.ApplicantSkillId,
                            LanguageSkillSpeak = s.LanguageSkillSpeak,
                            LanguageSkillWrite = s.LanguageSkillWrite,
                            Others = s.Others,
                            Skill = s.tblREFSkill.Skill,
                            SkillCatCd = !string.IsNullOrWhiteSpace(s.SkillCatCd) ? s.SkillCatCd.Trim() : s.SkillCatCd,
                            SkillCd = !string.IsNullOrWhiteSpace(s.SkillCd) ? s.SkillCd.Trim() : s.SkillCd
                        };

                        if (!string.IsNullOrWhiteSpace(apps.SkillCd) && s.tblREFSkill != null)
                            apps.Skill = s.tblREFSkill.Skill;

                        list.Add(apps);
                    }
                }
            }
            return list;
        }