private void EditScheduledOffering(StudentServiceOfferingScheduleModel viewModel, StudentAssignedOffering existing, EducationSecurityPrincipal user) { existing.LastModifyingUser = user.Identity.User; existing.LastModifyTime = DateTime.Now; viewModel.CopyTo(existing); StudentAssignedOfferingRepository.Update(existing); }
public void Create(EducationSecurityPrincipal user, ServiceOfferingScheduleModel viewModel) { if (user == null) { throw new ArgumentNullException("user"); } if (viewModel == null) { throw new ArgumentNullException("viewModel"); } if (!ServiceOfferingRepository.Items.Any(s => s.Id == viewModel.ServiceOfferingId && s.IsActive)) { throw new EntityNotFoundException("Selected Service Offering was not found."); } ServiceOffering offering = ServiceOfferingRepository.Items.Single(s => s.Id == viewModel.ServiceOfferingId && s.IsActive); IEnumerable <Student> students = StudentRepository.Items.Include(s => s.School).Where(s => viewModel.SelectedStudents.Contains(s.Id)); IPermission permission = PermissionFactory.Current.Create("ScheduleOffering", students, offering); permission.GrantAccess(user); User userEntity = user.Identity.User; List <int> studentIds = viewModel.SelectedStudents.ToList(); foreach (int studentId in studentIds) { var studentAssignedOffering = new StudentAssignedOffering { StudentId = studentId, CreatingUserId = userEntity.Id, IsActive = true }; viewModel.CopyTo(studentAssignedOffering); StudentAssignedOfferingRepository.Add(studentAssignedOffering); } RepositoryContainer.Save(); }
private StudentAssignedOffering CreateNewStudentAssignedOffering(Student student, ServiceUploadModel model, EducationSecurityPrincipal user) { var newOffering = new StudentAssignedOffering(); newOffering.Student = student; newOffering.StudentId = student.Id; newOffering.CreatingUser = user.Identity.User; newOffering.ServiceOfferingId = model.ServiceOfferingId; newOffering.StartDate = DateTime.Now; newOffering.CreateTime = DateTime.Now; newOffering.IsActive = true; StudentAssignedOfferingRepository.Add(newOffering); return(newOffering); }
private void CreateNewStudentAssignedOffering(Student student, ServiceUploadModel model, DateTime?startDate, DateTime?endDate, string notes, EducationSecurityPrincipal user) { var newOffering = new StudentAssignedOffering() { StudentId = student.Id, CreatingUser = user.Identity.User, ServiceOfferingId = model.ServiceOfferingId, StartDate = startDate, EndDate = endDate, Notes = notes, IsActive = true }; StudentAssignedOfferingRepository.Add(newOffering); }
public void Delete(EducationSecurityPrincipal user, int scheduledOfferingId) { StudentAssignedOffering assignment = StudentAssignedOfferingRepository.Items. Include(s => s.ServiceOffering.ServiceType). Include(s => s.Attendances). Include(s => s.Student.School). SingleOrDefault(s => s.Id == scheduledOfferingId); if (assignment == null || !assignment.IsActive) { throw new EntityNotFoundException("Requested assignment was not found"); } IPermission permission = PermissionFactory.Current.Create("DeleteScheduledOffering", assignment); permission.GrantAccess(user); assignment.IsActive = false; StudentAssignedOfferingRepository.Update(assignment); RepositoryContainer.Save(); }