public async Task <int> DeleteStudentEvaluationAsync(StudentEvaluationModel model) { var evaluation = new StudentEvaluation { StudentId = model.StudentId, TeacherId = model.TeacherId }; using (var dataService = DataServiceFactory.CreateDataService()) { return(await dataService.DeleteStudentEvaluationAsync(evaluation)); } }
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(); } }
public async Task <int> AddOrUpdateStudentEvaluationAsync(StudentEvaluationModel model) { using (var dataService = DataServiceFactory.CreateDataService()) { StudentEvaluation evaluation = new StudentEvaluation(); UpdateEvaluationFromModel(evaluation, model); var result = await dataService.AddOrUpdateStudentEvaluationAsync(evaluation); var newEvaluation = await GetStudentEvaluationAsync(evaluation.TeacherId, evaluation.StudentId); newEvaluation.IsNew = false; model.Merge(newEvaluation); return(result); } }
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); }
private static void UpdateEvaluationFromModel(StudentEvaluation target, StudentEvaluationModel source) { target.StudentId = source.StudentId; target.TeacherId = source.TeacherId; target.Content = source.Content; }