Exemple #1
0
 public void Add(SchoolDBModel schoolDBModel)
 {
     var school = ToMode(schoolDBModel);
     using (JxxyContext jxxyContext = new JxxyContext())
     {
         jxxyContext.Schools.Add(school);
         jxxyContext.SaveChanges();
     }
 }
Exemple #2
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();
            }
        }
Exemple #3
0
 private static School ToMode(SchoolDBModel schoolDBModel)
 {
     Mapper.CreateMap<SchoolDBModel, School>();
     var school = Mapper.Map<School>(schoolDBModel);
     return school;
 }