private void detach_ConcreteLessonPupilDetails(ConcreteLessonPupilDetails entity) { this.SendPropertyChanging(); entity.Pupil = null; }
public Action CreateLessons() { var startDate = JournalContext.Quarters.First(q => q.QuarterID == 0).StartDate; var endDate = JournalContext.Quarters.First(q => q.QuarterID == 3).EndDate; var dates = new Dictionary<DayOfWeek, List<DateTime>>(); var curDate = startDate; while(curDate <= endDate) { List<DateTime> values; if(!dates.TryGetValue(curDate.DayOfWeek, out values)) { values = new List<DateTime>(); dates.Add(curDate.DayOfWeek, values); } values.Add(curDate); curDate = curDate.AddDays(1); } var lessonTimes = JournalContext.LessonTimes.ToArray(); if (!JournalContext.SchoolConfigurations.Any(sc => sc.Key == ConfigurationTableHelper.Timetable)) { foreach (var lesson in JournalContext.JournalLessons) { List<DateTime> values; if (dates.TryGetValue(DateHelper.GetDayOfWeek(lesson.DayOfWeek), out values)) { foreach (var date in values) { var starTime = lessonTimes[lesson.Order].StartTime; DateTime lessonStartTime = date + new TimeSpan(starTime.Hour, starTime.Minute, starTime.Second); // время начала урока var concreteLesson = JournalContext.ConcreteLessons.FirstOrDefault(c => c.LessonOrder == lesson.Order && c.DayOfWeek == lesson.DayOfWeek && c.Date == lessonStartTime && c.JournalID == lesson.JournalID); if (concreteLesson == null) { concreteLesson = new ConcreteLesson(); concreteLesson.LessonOrder = lesson.Order; concreteLesson.JournalID = lesson.JournalID; concreteLesson.DayOfWeek = lesson.DayOfWeek; concreteLesson.Date = lessonStartTime; JournalContext.ConcreteLessons.InsertOnSubmit(concreteLesson); } foreach (var pupil in lesson.Journal.Pupils) { if (!JournalContext.ConcreteLessonPupilDetails.Any(c => c.ConcreteLesson.ID == concreteLesson.ID && c.Pupil.PupilID == pupil.PupilID)) // TODO: check this { var concreteLessonPupilDetails = new ConcreteLessonPupilDetails(); concreteLessonPupilDetails.ConcreteLesson = concreteLesson; concreteLessonPupilDetails.PupilID = pupil.PupilID; JournalContext.ConcreteLessonPupilDetails.InsertOnSubmit(concreteLessonPupilDetails); } } } } } } try { //JournalContext.SchoolConfigurations.InsertOnSubmit(new SchoolConfiguration //{ // Key = ConfigurationTableHelper.Timetable, // Value = "Created" //}); JournalContext.SubmitChanges(); } catch (Exception e) { } return null; }
partial void DeleteConcreteLessonPupilDetails(ConcreteLessonPupilDetails instance);
partial void InsertConcreteLessonPupilDetails(ConcreteLessonPupilDetails instance);
private void attach_ConcreteLessonPupilDetails(ConcreteLessonPupilDetails entity) { this.SendPropertyChanging(); entity.ConcreteLesson = this; }
public ActionResult InlineEditingUpdatePartial(ConcreteLessonPupilDetails pupilDetails, string subjectName, int? rowIndex, int? columnIndex, bool? isResetGridViewPageIndex) { if (ModelState.IsValid) { try { var record = JournalContext.ConcreteLessonPupilDetails.First( pd => pd.ConcreteLessonID == pupilDetails.ConcreteLessonID && pd.PupilID == pupilDetails.PupilID); // TODO: update entity record.Mark1 = pupilDetails.Mark1; record.Mark2 = pupilDetails.Mark2; record.IsAbsent = pupilDetails.IsAbsent; JournalContext.SubmitChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else ViewData["EditError"] = "Пожалуйста исправьте ошибки."; var lessons = GetLessons(subjectName); object dataObject = rowIndex != null && columnIndex != null ? PivotGridExtension.CreateDrillDownDataSource(DrillDownPivotGridSettings, lessons, columnIndex.Value, rowIndex.Value) : null; return PartialView("GridViewPartial", dataObject); }
partial void InsertConcreteLessonPupilDetails(ConcreteLessonPupilDetails instance) { if (!ConcreteLessonPupilDetails.Contains(instance)) ExecuteDynamicInsert(instance); }