예제 #1
0
        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
파일: Student.cs 프로젝트: plurby/Registry
 public Student(StudentViewModel model)
 {
     Id = model.Id;
       FirstName = model.FirstName;
       LastName = model.LastName;
       GPA = model.GPA;
       IsEnrolled = model.IsEnrolled;
       Version = Convert.FromBase64String(model.Version);
 }
예제 #3
0
 public StatusTransport<StudentViewModel> Save(StudentViewModel model)
 {
     return _studentService.SaveStudent(model);
 }
예제 #4
0
 public JsonResult Save(StudentViewModel model)
 {
     return new JsonResult { Data = _studentService.SaveStudent(model) };
 }