예제 #1
0
        public int UpdateSport(ApplicantSport sport)
        {
            using (var entities = new atmEntities())
            {
                var exist = (from a in entities.tblApplicantSportAssocs where a.ApplicantSportAssocId == sport.ApplicantSportAssocId select a).SingleOrDefault();
                if (exist != null)
                {
                    exist.AchievementCd = sport.AchievementCd;
                    exist.ApplicantId = sport.ApplicantId;
                    exist.Others = sport.Others;
                    exist.Year = sport.Year;
                    exist.LastModifiedBy = sport.LastModifiedBy;
                    exist.LastModifiedDt = sport.LastModifiedDt;

                    entities.SaveChanges();
                    return exist.ApplicantSportAssocId;
                }
            }
            return 0;
        }
예제 #2
0
        public IEnumerable<ApplicantSport> GetSport(int applicantid)
        {
            var list = new List<ApplicantSport>();
            using (var entities = new atmEntities())
            {
                var l = from a in entities.tblApplicantSportAssocs where a.ApplicantId == applicantid select a;
                if (l.Any())
                {
                    foreach (var s in l)
                    {
                        var appsa = new ApplicantSport
                        {
                            AchievementCd = !string.IsNullOrWhiteSpace(s.AchievementCd) ? s.AchievementCd.Trim() : s.AchievementCd,
                            ApplicantId = s.ApplicantId,
                            ApplicantSportAssocId = s.ApplicantSportAssocId,
                            CreatedBy = s.CreatedBy,
                            CreatedDt = s.CreatedDt,
                            LastModifiedBy = s.LastModifiedBy,
                            LastModifiedDt = s.LastModifiedDt,
                            Others = s.Others,
                            SportAssocId = s.SportAssocId,
                            Year = s.Year
                        };
                        if (s.SportAssocId.HasValue && s.tblREFSportAndAssociation != null)
                        {
                            appsa.SportAndAssociation = new SportAndAssociation()
                            {
                                SportAssocId = s.tblREFSportAndAssociation.SportAssocId,
                                SportAssociatName = s.tblREFSportAndAssociation.SportAssociatName,
                                SportAssociatType = s.tblREFSportAndAssociation.SportAssociatType,
                                ActiveInd = s.tblREFSportAndAssociation.ActiveInd,
                            };
                        }

                        list.Add(appsa);
                    }
                }
            }
            return list;
        }
예제 #3
0
        public int SaveSport(ApplicantSport sport)
        {
            using (var entities = new atmEntities())
            {
                // to cater Other category
                if (sport.SportAssocId != 99)
                {
                    var exist = (from a in entities.tblApplicantSportAssocs where a.ApplicantId == sport.ApplicantId && a.SportAssocId != null && a.SportAssocId == sport.SportAssocId select a).SingleOrDefault();
                    if (exist != null)
                    {
                        sport.ApplicantSportAssocId = exist.ApplicantSportAssocId;
                        return UpdateSport(sport);
                    }
                }

                if (sport.ApplicantSportAssocId != 0) { return UpdateSport(sport); }

                var s = new tblApplicantSportAssoc
                {
                    AchievementCd = sport.AchievementCd,
                    ApplicantId = sport.ApplicantId,
                    CreatedBy = sport.CreatedBy,
                    CreatedDt = sport.CreatedDt,
                    Others = sport.Others,
                    SportAssocId = sport.SportAssocId,
                    Year = sport.Year
                };
                entities.tblApplicantSportAssocs.Add(s);
                if (entities.SaveChanges() > 0)
                    return s.ApplicantSportAssocId;

            }
            return 0;
        }
예제 #4
0
        public ApplicantSport GetApplicantSportAndKokos(int applicantsportid)
        {
            if (applicantsportid != 0)
            {
                using (var entities = new atmEntities())
                {
                    var exist = (from a in entities.tblApplicantSportAssocs where a.ApplicantSportAssocId == applicantsportid select a).SingleOrDefault();
                    if (null != exist)
                    {
                        var apps = new ApplicantSport()
                        {
                            AchievementCd = !string.IsNullOrWhiteSpace(exist.AchievementCd) ? exist.AchievementCd.Trim() : exist.AchievementCd,
                            ApplicantId = exist.ApplicantId,
                            ApplicantSportAssocId = exist.ApplicantSportAssocId,
                            CreatedBy = exist.CreatedBy,
                            CreatedDt = exist.CreatedDt,
                            LastModifiedBy = exist.LastModifiedBy,
                            LastModifiedDt = exist.LastModifiedDt,
                            Others = exist.Others,
                            Year = exist.Year,
                            SportAssocId = exist.SportAssocId,
                        };

                        if (exist.SportAssocId.HasValue && exist.tblREFSportAndAssociation != null)
                        {
                            apps.SportAndAssociation = new SportAndAssociation()
                            {
                                ActiveInd = exist.tblREFSportAndAssociation.ActiveInd,
                                CreatedBy = exist.tblREFSportAndAssociation.CreatedBy,
                                CreatedDt = exist.tblREFSportAndAssociation.CreatedDt,
                                LastModifiedBy = exist.tblREFSportAndAssociation.LastModifiedBy,
                                LastModifiedDt = exist.tblREFSportAndAssociation.LastModifiedDt,
                                SportAssocId = exist.tblREFSportAndAssociation.SportAssocId,
                                SportAssociatName = exist.tblREFSportAndAssociation.SportAssociatName,
                                SportAssociatType = exist.tblREFSportAndAssociation.SportAssociatType
                            };
                        }

                        return apps;
                    }
                }
            }
            return null;
        }