public static Entities.StudentIEP CreateStudentIEP(StudentIEPModel model, int userId) { Debug.Assert(model.ScheduledDate != null, "model.ScheduledDate != null"); Debug.Assert(model.ScheduledDateTime != null, "model.ScheduledDateTime != null"); var result = new Entities.StudentIEP { CreatedBy = userId, CreatedOn = DateTime.Now, LastModifiedBy = userId, LastModifiedOn = DateTime.Now, DateOfMeeting = Misc.CombineDateAndTime(model.DateOfMeeting, model.DateOfMeetingTime), IsComplete = model.IsComplete, IsCurrentIEP = model.IsCurrent, ScheduledDate = Misc.CombineDateAndTime(model.ScheduledDate.Value, model.ScheduledDateTime.Value), StudentId = model.StudentId }; using (var context = DataContext.GetContext()) { context.StudentIEPs.AddObject(result); context.SaveChanges(); if (model.StudentDocumentId.HasValue) { var studentDocument = context.StudentDocuments.Single(a => a.StudentDocumentId == model.StudentDocumentId.Value); studentDocument.StudentIEPId = result.StudentIEPId; context.SaveChanges(); } } return(result); }
public static void UpdateStudentIep(StudentIEPModel model, int userId) { Debug.Assert(model.ScheduledDate != null, "model.ScheduledDate != null"); Debug.Assert(model.ScheduledDateTime != null, "model.ScheduledDateTime != null"); using (var context = DataContext.GetContext()) { var existing = context.StudentIEPs.Single(a => a.StudentIEPId == model.StudentIEPId); existing.DateOfMeeting = Misc.CombineDateAndTime(model.DateOfMeeting, model.DateOfMeetingTime); existing.IsComplete = model.IsComplete; existing.IsCurrentIEP = model.IsCurrent; existing.LastModifiedBy = userId; existing.LastModifiedOn = DateTime.Now; existing.ScheduledDate = Misc.CombineDateAndTime(model.ScheduledDate.Value, model.ScheduledDateTime.Value); context.SaveChanges(); } }