Beispiel #1
0
 public void Add(SchoolDBModel schoolDBModel)
 {
     var school = ToMode(schoolDBModel);
     using (JxxyContext jxxyContext = new JxxyContext())
     {
         jxxyContext.Schools.Add(school);
         jxxyContext.SaveChanges();
     }
 }
Beispiel #2
0
 public List<SchoolDBModel> GetSchools()
 {
     using (JxxyContext jxxyContext = new JxxyContext())
     {
         var dbSchools = (from school in jxxyContext.Schools     
                          orderby school.CreatedDate descending
                         select school).ToList();
        
         return FromModels(dbSchools);                
     }
 }
Beispiel #3
0
        public void Delete(string id)
        {
            using (JxxyContext jxxyContext = new JxxyContext())
            {
                var schoolDB = (from school in jxxyContext.Schools
                                where school.Id == id
                                select school).FirstOrDefault();

                jxxyContext.Schools.Remove(schoolDB);
                jxxyContext.SaveChanges();
            }
        }
Beispiel #4
0
        public TeacherDBModel GetTeacher(string userName)
        {
            using (JxxyContext jxxyContext = new JxxyContext())
            { 
                var dbTeacher = (from teacher in jxxyContext.Teachers
                               where teacher.LoginName == userName
                               select teacher).FirstOrDefault();

                if(dbTeacher != null)
                {
                    return FromMode(dbTeacher);
                }

                return null;
            }
        }
Beispiel #5
0
        public SchoolDBModel GetSchoolById(string id)
        {
            using (JxxyContext jxxyContext = new JxxyContext())
            {
                var dbSchool = (from school in jxxyContext.Schools
                                 where school.Id == id
                                 select school).FirstOrDefault();

                if (dbSchool != null)
                {
                    return FromModel(dbSchool);
                }

                return null;
            }
        }
Beispiel #6
0
        public void Update(SchoolDBModel schoolDBModel)
        {            
            using (JxxyContext jxxyContext = new JxxyContext())
            {
                var schoolDB = (from school in jxxyContext.Schools
                             where school.Id == schoolDBModel.Id
                             select school).FirstOrDefault();

                schoolDB.Name = schoolDBModel.Name;
                schoolDB.Address = schoolDBModel.Address;
                schoolDB.Remark = schoolDBModel.Remark;
                schoolDB.UpdatedBy = schoolDBModel.UpdatedBy;
                schoolDB.UpdatedDate = DateTime.Now;

                jxxyContext.SaveChanges();
            }
        }