Пример #1
0
        public void Edit(ServiceAttendanceModel viewModel, EducationSecurityPrincipal user)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            var updatedServiceAttendance = ServiceAttendanceRepository.Items.Include(s => s.StudentAssignedOffering).SingleOrDefault(s => s.Id == viewModel.Id);

            if (updatedServiceAttendance == null)
            {
                throw new EntityNotFoundException();
            }
            IPermission permission = PermissionFactory.Current.Create("EditServiceAttendance", updatedServiceAttendance.StudentAssignedOffering);

            permission.GrantAccess(user);
            viewModel.CopyTo(updatedServiceAttendance);
            updatedServiceAttendance.LastModifyingUser = user.Identity.User;
            updatedServiceAttendance.LastModifyTime    = DateTime.Now;
            ServiceAttendanceRepository.Update(updatedServiceAttendance);
            RepositoryContainer.Save();
        }
        private void Create(StudentAssignedOffering studentAssignedOffering, DateTime dateAttended, Subject subject, decimal duration, string notes, EducationSecurityPrincipal user)
        {
            var newAttendance = new ServiceAttendance();

            newAttendance.StudentAssignedOffering = studentAssignedOffering;
            newAttendance.DateAttended            = dateAttended;
            newAttendance.Subject      = subject;
            newAttendance.Duration     = duration;
            newAttendance.Notes        = notes;
            newAttendance.CreatingUser = user.Identity.User;
            ServiceAttendanceRepository.Add(newAttendance);
        }
Пример #3
0
        public void Delete(int id, EducationSecurityPrincipal user)
        {
            var serviceAttendanceToDelete = ServiceAttendanceRepository.Items.Include(s => s.StudentAssignedOffering).SingleOrDefault(s => s.Id == id);

            if (serviceAttendanceToDelete == null)
            {
                throw new EntityNotFoundException("Specified Service Attendance does not exist");
            }
            IPermission permission = PermissionFactory.Current.Create("DeleteServiceAttendance", serviceAttendanceToDelete.StudentAssignedOffering);

            permission.GrantAccess(user);
            ServiceAttendanceRepository.Remove(serviceAttendanceToDelete);
            RepositoryContainer.Save();
        }
Пример #4
0
        public void Create(ServiceAttendanceModel viewModel, EducationSecurityPrincipal user)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            var         studentAssignedOffering = StudentAssignedOfferingRepository.Items.Single(s => s.Id == viewModel.StudentAssignedOfferingId);
            IPermission permission = PermissionFactory.Current.Create("CreateServiceAttendance", studentAssignedOffering);

            permission.GrantAccess(user);
            ServiceAttendance serviceAttendance = new ServiceAttendance
            {
                CreatingUser = user.Identity.User
            };

            viewModel.CopyTo(serviceAttendance);
            ServiceAttendanceRepository.Add(serviceAttendance);
            RepositoryContainer.Save();
        }