コード例 #1
0
        public void Delete(Guid id)
        {
            Models.DBObjects.Schedule dbScheduleModel = dbContext.Schedules.FirstOrDefault(m => m.ScheduleId == id);

            dbContext.Schedules.DeleteOnSubmit(dbScheduleModel);
            dbContext.SubmitChanges();
        }
コード例 #2
0
        public void Update(ScheduleModel scheduleModel)
        {
            Models.DBObjects.Schedule dbScheduleModel = dbContext.Schedules.FirstOrDefault(m => m.ScheduleId == scheduleModel.ScheduleId);

            if (scheduleModel != null)
            {
                dbScheduleModel.ScheduleId = scheduleModel.ScheduleId;
                dbScheduleModel.Day        = scheduleModel.Day;
                dbScheduleModel.StudentId  = scheduleModel.StudentId;
                dbScheduleModel.TeacherId  = scheduleModel.TeacherId;
                dbScheduleModel.ClassId    = scheduleModel.ClassId;

                dbContext.SubmitChanges();
            }
        }
コード例 #3
0
        public ScheduleModel GetScheduleById(Guid id)
        {
            Models.DBObjects.Schedule dbScheduleModel = dbContext.Schedules.FirstOrDefault(m => m.ScheduleId == id);

            ScheduleModel scheduleModel = new ScheduleModel();

            if (dbScheduleModel != null)
            {
                scheduleModel.ScheduleId = dbScheduleModel.ScheduleId;
                scheduleModel.Day        = dbScheduleModel.Day;
                scheduleModel.StudentId  = dbScheduleModel.StudentId;
                scheduleModel.TeacherId  = dbScheduleModel.TeacherId;
                scheduleModel.ClassId    = dbScheduleModel.ClassId;
            }
            return(scheduleModel);
        }
コード例 #4
0
        public void Insert(ScheduleModel scheduleModel)
        {
            scheduleModel.ScheduleId = Guid.NewGuid();

            if (scheduleModel != null)
            {
                Models.DBObjects.Schedule dbScheduleModel = new Models.DBObjects.Schedule();

                dbScheduleModel.ScheduleId = scheduleModel.ScheduleId;
                dbScheduleModel.Day        = scheduleModel.Day;
                dbScheduleModel.StudentId  = scheduleModel.StudentId;
                dbScheduleModel.TeacherId  = scheduleModel.TeacherId;
                dbScheduleModel.ClassId    = scheduleModel.ClassId;

                dbContext.Schedules.InsertOnSubmit(dbScheduleModel);
                dbContext.SubmitChanges();
            }
        }