コード例 #1
0
ファイル: StudentService.cs プロジェクト: plurby/Registry
        public StatusTransport<StudentViewModel> SaveStudent(StudentViewModel model)
        {
            var transport = new StatusTransport<StudentViewModel>();
              var student = new Student(model);
              _context.Students.Attach(student, true);
              try
              {
            _context.SubmitChanges();
            // Retrieve most recent version.
            _context.Refresh(RefreshMode.OverwriteCurrentValues, student);
            transport.ViewModel = new StudentViewModel(student)
              { ClientId = model.ClientId };
            transport.SetSuccess();

            // Update all connected clients. Comment this line out to test
            // normal conflict resolution.
            BroadcastStudent(transport);
              }
              catch (ChangeConflictException exConflict)
              {
            // Retrieve most recent version.
            _context.Refresh(RefreshMode.OverwriteCurrentValues, student);
            transport.ViewModel = new StudentViewModel(student);

            // Mark result as stale.
            transport.SetStale(exConflict);
              }
              return transport;
        }
コード例 #2
0
ファイル: StudentViewModel.cs プロジェクト: plurby/Registry
 public StudentViewModel(Student student)
 {
     Id = student.Id;
       FirstName = student.FirstName;
       LastName = student.LastName;
       GPA = student.GPA;
       IsEnrolled = student.IsEnrolled;
       Version = Convert.ToBase64String((student.Version ?? new byte[] { }).ToArray());
 }
コード例 #3
0
 partial void DeleteStudent(Student instance);
コード例 #4
0
 partial void UpdateStudent(Student instance);
コード例 #5
0
 partial void InsertStudent(Student instance);