public static Entities.StudentEvaluation CreateStudentEvaluation(StudentEvaluationModel model, int userId) { Debug.Assert(model.ScheduledDate != null, "model.ScheduledDate != null"); var result = new Entities.StudentEvaluation { CreatedBy = userId, CreatedOn = DateTime.Now, LastModifiedBy = userId, LastModifiedOn = DateTime.Now, ScheduledDate = model.ScheduledDate.Value, DateCompleted = model.DateCompleted, StudentId = model.StudentId }; using (var context = DataContext.GetContext()) { context.StudentEvaluations.AddObject(result); context.SaveChanges(); } return result; }
public static void UpdateStudentEvaluation(StudentEvaluationModel model, int userId) { Debug.Assert(model.ScheduledDate != null, "model.ScheduledDate != null"); using (var context = DataContext.GetContext()) { var existing = context.StudentEvaluations.Single(a => a.StudentEvaluationId == model.StudentEvaluationId); existing.DateCompleted = model.DateCompleted; existing.LastModifiedBy = userId; existing.LastModifiedOn = DateTime.Now; existing.ScheduledDate = model.ScheduledDate.Value; context.SaveChanges(); } }