Пример #1
0
        public void CreateRecord(EntitiesDTO entity, OperationsDTO operation, string userId, int entityId, bool success)
        {
            var record = new RecordDTO
            {
                UserId       = userId,
                Entity       = entity,
                Operation    = operation,
                Successfully = success,
                EntityId     = entityId,
                DateTime     = DateTime.Now
            };

            CreateRecord(record);
        }
        protected override SaveableViewModel GetViewModel(EntitiesDTO.BaseEntityDTO entity)
        {
            if (entity == null)
                return null;
            SaveableViewModel viewModel;
            if (entity is TeacherDTO && !(lastViewModel is TeacherPracticesViewModel))
                viewModel = new TeacherLecturesViewModel(UserInterop, ControllerInterop, Dispatcher, entity as TeacherDTO);
            else if (entity is TeacherDTO)
                viewModel = new TeacherPracticesViewModel(UserInterop, ControllerInterop, Dispatcher, entity as TeacherDTO);
            else if (entity is LectureDTO)
                viewModel = new LectureViewModel(UserInterop, ControllerInterop, Dispatcher, entity as LectureDTO);
            else if (entity is PracticeTeacherDTO)
                viewModel = new PracticeTeacherViewModel(UserInterop, ControllerInterop, Dispatcher, entity as PracticeTeacherDTO);
            else
                viewModel = null;

            OnIsVisibleChanged();

            return viewModel;
        }
        protected override SaveableViewModel GetViewModel(EntitiesDTO.BaseEntityDTO entity)
        {
            if (entity is LectureDTO)
            {
                if (lectureDataViewModel == null)
                {
                    lectureDataViewModel = new LectureDataViewModel(UserInterop, ControllerInterop, Dispatcher, entity as LectureDTO);
                    lectureDataViewModel.PropertyChanged += lectureDataViewModel_PropertyChanged;
                    lectureDataViewModel.WorkspaceChanged += (vm) =>
                        {
                            if (WorkspaceChanged != null)
                                WorkspaceChanged(vm);
                        };
                }
                else
                    lectureDataViewModel.InitControl(entity as LectureDTO);
                return lectureDataViewModel;
            }

            if (entity is PracticeTeacherDTO)
            {
                if (practiceDataViewModel == null)
                {
                    practiceDataViewModel = new PracticeDataViewModel(UserInterop, ControllerInterop, Dispatcher, entity as PracticeTeacherDTO);
                    practiceDataViewModel.WorkspaceChanged += (vm) =>
                    {
                        if (WorkspaceChanged != null)
                            WorkspaceChanged(vm);
                    };
                }
                else
                    practiceDataViewModel.InitControl(entity as PracticeTeacherDTO);
                return practiceDataViewModel;
            }

            return null;
        }
 protected override SaveableViewModel GetViewModel(EntitiesDTO.BaseEntityDTO entity)
 {
     SystemUserDTO user = entity as SystemUserDTO;
     if (user != null)
     {
         switch (user.Role)
         {
             case UserRoles.MainAdmin:
                 return new MainAdminViewModel(UserInterop, ControllerInterop, Dispatcher, user);
             case UserRoles.MainSecretary:
                 return new MainSecretaryViewModel(UserInterop, ControllerInterop, Dispatcher, user);
             case UserRoles.InstituteAdmin:
                 return new InstituteAdminViewModel(UserInterop, ControllerInterop, Dispatcher, user as InstituteAdminDTO);
             case UserRoles.InstituteSecretary:
                 return new InstituteSecretaryViewModel(UserInterop, ControllerInterop, Dispatcher, user as InstituteSecretaryDTO);
             case UserRoles.FacultyAdmin:
                 return new FacultyAdminViewModel(UserInterop, ControllerInterop, Dispatcher, user as FacultyAdminDTO);
             case UserRoles.FacultySecretary:
                 return new FacultySecretaryViewModel(UserInterop, ControllerInterop, Dispatcher, user as FacultySecretaryDTO);
             case UserRoles.Teacher:
                 return new TeacherViewModel(UserInterop, ControllerInterop, Dispatcher, user as TeacherDTO);
             case UserRoles.Student:
                 return new StudentViewModel(UserInterop, ControllerInterop, Dispatcher, user as StudentDTO);
             default:
                 throw new NotImplementedException();
         }
     }
     return null;
 }