示例#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
 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) };
 }