Пример #1
0
        private async void AddStudentBoard_SaveButton(object sender, EventArgs e)
        {
            var selectedGroupView = _addStudentBoard.GroupsCollection
                                    .Cast <IGroupView>()
                                    .FirstOrDefault(gv => gv.IsSelected);

            var student = new Student
            {
                Id                  = new Random(Guid.NewGuid().GetHashCode()).Next(),
                FirstName           = _addStudentBoard.GetFirstName.Trim(),
                LastName            = _addStudentBoard.GetLastName.Trim(),
                MiddleName          = _addStudentBoard.GetMiddleName.Trim(),
                Сitizenship         = _addStudentBoard.GetCitizenship.Trim(),
                FirstPhoto          = _addStudentBoard.GetFirstPhoto.ConvertImageToByteArr(),
                SecondPhoto         = _addStudentBoard.GetSecondPhoto.ConvertImageToByteArr(),
                DateOfBirth         = _addStudentBoard.DateOfBirth.Trim(),
                Height              = _addStudentBoard.GetGrowth,
                Weight              = _addStudentBoard.GetWeight,
                KnowledgeOfLanguage = _addStudentBoard.GetKnowledgeOfLanguage.Trim(),

                GroupId = selectedGroupView?.Id
            };

            EFGenericRepository.Create(student);

            // todo: ? (now without group)
            // if (selectedGroup != null)
            // {
            //   await _addStudentBoard.GroupsCollection.UpdateControls(new[] {selectedGroup}, _groupView,
            //     CancellationToken.None);
            //   EFGenericRepository.Update(selectedGroup);
            // }
        }
Пример #2
0
        private bool AddGroupBoard_SaveClick()
        {
            if (string.IsNullOrWhiteSpace(_addGroupBoard.GetNameOfGroup) ||
                _addGroupBoard.GetGroupPhoto == null ||
                _addGroupBoard.AddedStudentControlCollection.Count == 0)
            {
                return(false);
            }

            var students = new List <Student>();

            foreach (IStudentView studentView in _addGroupBoard.AddedStudentControlCollection)
            {
                students.Add(EFGenericRepository.Find <Student>(studentView.Id));
            }

            var group = new Group
            {
                Id       = new Random(Guid.NewGuid().GetHashCode()).Next(),
                Name     = _addGroupBoard.GetNameOfGroup,
                Students = students,
                Photo    = _addGroupBoard.GetGroupPhoto.ConvertImageToByteArr()
            };

            EFGenericRepository.Create(group);

            _addGroupBoard.ClearView();
            _addGroupBoard.AddedStudentControlCollection.Clear();

            return(true);
        }
Пример #3
0
        public void SortMethod()
        {
            // Получаем список основных каталогов
            IEnumerable <catalog> catalog = ICatalog.Get();

            // Используем их для начала работы
            foreach (var Catalog in catalog)
            {
                // Добавляем основные каталоги
                ICatalog_level.Create(new catalog_level()
                {
                    name        = Catalog.name,
                    description = Catalog.description
                });

                // Загружаем дочерний элемент
                foreach (var Catalog_aggregate in ICatalog_aggregate.GetWithInclude(a => a.catalog_model).Where(a => a.catalog_id == Catalog.Id))
                {
                    // Получаем id первого созданного родительского элемента
                    int MainId = ICatalog_level.Get().Where(a => a.parent_id == null).LastOrDefault().id;

                    // Добавляем дочерний элемент первого уровня
                    ICatalog_level.Create(new catalog_level()
                    {
                        name        = Catalog_aggregate.name,
                        description = Catalog_aggregate.description,
                        parent_id   = MainId // Присваиваем ему идентификатор родителя
                    });

                    // Находим новый Id дочернего элемента первого уровня
                    int?newId = ICatalog_level.Get().Where(x => x.parent_id == MainId).LastOrDefault().id;

                    // Используем дочерний элемент второго уровня
                    foreach (var Catalog_model in Catalog_aggregate.catalog_model)
                    {
                        // Добавляем дочерний элемент второго уровня
                        ICatalog_level.Create(new catalog_level()
                        {
                            name        = Catalog_model.model,
                            description = Catalog_model.description,
                            parent_id   = newId // Присваиваем дочернему элементу второго уровня, Id идентификатор дочернего элемента первого уровня
                        });
                    }
                }
            }
        }
Пример #4
0
        private void AddSubjectForm_SaveButton(object sender, EventArgs e)
        {
            Subjects subjects = new Subjects {
                Name = addSubjectForm.subjectName
            };

            EFGenericRepository.Create(subjects);
        }
Пример #5
0
        private void Student_SaveClick(object sender, EventArgs e)
        {
            student.FirstName  = addStudentBoard.FirstName;
            student.LastName   = addStudentBoard.LastName;
            student.MiddleName = addStudentBoard.MiddleName;
            student.Marks      = marks;
            EFGenericRepository.Create(student);

            EFGenericRepository.SaveChanges();
        }
Пример #6
0
 public bool CreateMagazine(MagazineViewModel magazineViewModel)
 {
     try
     {
         Magazine magazine = Mapper.Map <MagazineViewModel, Magazine>(magazineViewModel);
         _magazineRepository.Create(magazine);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #7
0
 public bool CreateBrochure(BrochureViewModel brochureViewModel)
 {
     try
     {
         Brochure brochure = Mapper.Map <BrochureViewModel, Brochure>(brochureViewModel);
         _brochureRepository.Create(brochure);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #8
0
 public bool CreatePublicationHouse(PublicationHouseViewModel publicationHouseViewModel)
 {
     try
     {
         PublicationHouse publicationHouse = Mapper.Map <PublicationHouseViewModel, PublicationHouse>(publicationHouseViewModel);
         _houseRepository.Create(publicationHouse);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #9
0
 public void CreateUser(string login, string password)
 {
     if (GetUserByLogin(login) == null)
     {
         UserDTO dto = new UserDTO();
         dto.Name         = " ";
         dto.Sur_Name     = " ";
         dto.Birth_Date   = new DateTime();
         dto.Phone_Number = null;
         dto.Email        = " ";
         dto.Login        = login;
         dto.Password     = password;
         dto.UserRoleId   = 1;
         var user = _mapper.Map <UserDTO, User>(dto);
         userRepo.Create(user);
     }
 }
 public void AddMagazine(MagazineViewModel magazineViewModel)
 {
     _magazineRepository.Create(Mapper.Map <MagazineViewModel, Magazine>(magazineViewModel));
 }
Пример #11
0
 public void AddAuthor(AuthorViewModel authorViewModel)
 {
     _authorRepository.Create(Mapper.Map <AuthorViewModel, Author>(authorViewModel));
 }
Пример #12
0
 public void AddPublicationHouse(PublicationHouseViewModel publicationHouseViewModel)
 {
     _publicationServiceRepository.Create(Mapper.Map <PublicationHouseViewModel, PublicationHouse>(publicationHouseViewModel));
 }
Пример #13
0
 public void AddBrochure(BrochureViewModel brochureViewModel)
 {
     _brochureRepository.Create(Mapper.Map <BrochureViewModel, Brochure>(brochureViewModel));
 }