示例#1
0
文件: CRUD.cs 项目: thilehoffer/CSM
        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;
        }
示例#2
0
文件: CRUD.cs 项目: thilehoffer/CSM
 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();
     }
 }