Esempio n. 1
0
        public IEnumerable <UserDTO> GetAllEntities()
        {
            var entities = userRepo.Get();
            var dtos     = _mapper.Map <IEnumerable <User>, IEnumerable <UserDTO> >(entities);

            return(dtos);
        }
 private async Task DeleteControlsFromControlCollection(IList <Group> groups, CancellationToken token)
 {
     await _editGroupBoardFirst.GroupCollection.DeleteControls(
         groups,
         EFGenericRepository.Get <Group>(),
         token);
 }
Esempio n. 3
0
        public void updateDataGrid()
        {
            db = new ApplicationContext();


            // создаем репозиторий типов комнат, для работы с бд
            db.RoomTypes.Load();
            EFGenericRepository <Entity.RoomTypes> roomTypesRepo = new EFGenericRepository <Entity.RoomTypes>(db);

            roomTypesList = (List <Entity.RoomTypes>)roomTypesRepo.Get();

            // создаем репозиторий комнат, для работы с бд
            db.Rooms.Load();
            EFGenericRepository <Entity.Rooms> roomsRepo = new EFGenericRepository <Entity.Rooms>(db);

            roomsList = (List <Entity.Rooms>)roomsRepo.Get();
            // Т.к. EF не хочет устанавливать внешние связи, придется делать связи вручную
            foreach (Entity.Rooms room in roomsList)
            {
                room.customInit(db.RoomTypes);
            }

            DataGrid_rooms.ItemsSource = roomsList;

            findRowsByFilter();
        }
 public override async void GroupBoard_LoadAddGroupBoard(object sender, EventArgs e)
 {
     await _groupBoardSecond.CurrentStudentControlCollection.AddControls(
         EFGenericRepository.Get <Student>(s => s.GroupId == null).ToArray(),
         currentStudentView,
         CancellationToken.None);
 }
Esempio n. 5
0
        public IEnumerable <TaskCategoryDTO> GetAllEntities()
        {
            var entities = taskCategoryRepo.Get();
            var dtos     = mapper.Map <IEnumerable <TaskCategory>, IEnumerable <TaskCategoryDTO> >(entities);

            return(dtos);
        }
Esempio n. 6
0
        private async void GroupBoard_UpdateView(object sender, EventArgs e)
        {
            groupBoard.DisableCurrentStudentPanel();
            groupBoard.DisableAddedStudentPanel();

            await AddControlsToControlCollection(
                EFGenericRepository.GetEntitiesWithState <Student>(EntityState.Added, s => s.GroupId == null).ToArray(),
                CancellationToken.None);

            //для студентов, которые были загружены с бд и в процессе были исключены из группы
            await AddControlsToControlCollection(
                EFGenericRepository.Get <Student>(s => s.GroupId == null).ToArray(),
                CancellationToken.None);

            await DeleteControlsFromControlCollection(
                EFGenericRepository.GetEntitiesWithState <Student>(EntityState.Deleted, s => s.GroupId == null),
                CancellationToken.None);

            await UpdateControlsFromControlCollection(
                EFGenericRepository.GetEntitiesWithState <Student>(EntityState.Modified).ToArray(),
                CancellationToken.None);

            groupBoard.EnableCurrentStudentPanel();
            groupBoard.EnableAddedStudentPanel();
        }
        public override async Task <Student[]> GetStudentWithExceptedAddedStudent(string condition, string searchCriteria,
                                                                                  CancellationToken token)
        {
            return(await Task.Factory.StartNew(() =>
            {
                var students = (IEnumerable <Student>)EFGenericRepository.Get <Student>(s => s.GroupId == null).ToArray();

                var existGroup = EFGenericRepository.Get <Group>(g => g.Name == groupBoard.GetNameOfGroup).FirstOrDefault();
                var currentStudent = existGroup?.Students;
                if (currentStudent != null)
                {
                    students = students.Union(currentStudent);
                }

                if (condition != string.Empty)
                {
                    students = students.Where(searchCriteria, condition);
                }

                if (groupBoard.AddedStudentControlCollection.Count == 0)
                {
                    return students.ToArray();
                }

                var addedStudents = groupBoard.AddedStudentControlCollection
                                    .Cast <IStudentView>()
                                    .Select(s => EFGenericRepository.Find <Student>(s.Id));

                return students.Except(addedStudents).ToArray();
            }, token));
        }
Esempio n. 8
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 идентификатор дочернего элемента первого уровня
                        });
                    }
                }
            }
        }
Esempio n. 9
0
 private static async Task <TResult[]> GetViews <TEntity, TResult>(string searchCriteria, string conditionFilter,
                                                                   CancellationToken token)
     where TEntity : class, IEntity
     where TResult : class, IEntity
 {
     return(await Task.Factory.StartNew(() => EFGenericRepository.Get <TEntity>(searchCriteria, conditionFilter)
                                        .GetViews <TEntity, TResult>().ToArray(), token));
 }
Esempio n. 10
0
        public IEnumerable <TopUserDTO> GetTop5Users()
        {
            //TODO: change select query when rating field will be added to user table
            var entities = _users.Get(t => t.Id != 0, 5);
            var dtos     = mapper.Map <IEnumerable <User>, IEnumerable <TopUserDTO> >(entities);

            return(dtos);
        }
Esempio n. 11
0
        public static List <RoomTypes> init_RoomTypes(DbContext db)
        {
            // создаем репозиторий типов комнат, для работы с бд
            db.Set <RoomTypes>().Load();
            EFGenericRepository <Entity.RoomTypes> roomTypesRepo = new EFGenericRepository <Entity.RoomTypes>(db);

            return((List <Entity.RoomTypes>)roomTypesRepo.Get());
        }
Esempio n. 12
0
        public static List <Entity.Clients> init_Clients(DbContext db)
        {
            // создаем репозиторий комнат, для работы с бд
            db.Set <Clients>().Load();
            EFGenericRepository <Entity.Clients> clientsRepo = new EFGenericRepository <Entity.Clients>(db);
            List <Entity.Clients> tmpList = (List <Entity.Clients>)clientsRepo.Get();

            return(tmpList);
        }
        private void EditStudentBoardFirst_LoadEditStudentBoardFirst(object sender, EventArgs e)
        {
            var students        = EFGenericRepository.Get <Student>().ToArray();
            var studentControls = _editStudentView.CreateListViews(students.Length);

            for (int i = 0; i < students.Length; i++)
            {
                _editStudentBoardFirst.StudentControlCollection.Add((Control)studentControls[i].FillView(students[i]));
            }
        }
Esempio n. 14
0
        public PublicationHouseViewModel GetPublicationHouse(int?id)
        {
            PublicationHouse publicationHouse = _publicationServiceRepository.Get(id.Value);

            if (publicationHouse == null)
            {
                throw new ValidationException("Publication House not found", "");
            }
            return(Mapper.Map <PublicationHouse, PublicationHouseViewModel>(publicationHouse));
        }
Esempio n. 15
0
        // GET: Org/Delete
        public ActionResult Delete(string id)
        {
            EFGenericRepository <Org> Orgs = new EFGenericRepository <Org>(DbContext);
            Org model = Orgs.Get(x => x.Id == id);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_DeletePartial", model));
            }
            return(View(model));
        }
        private Student[] GetStudentsWithConditions(string condition, string searchCriteria)
        {
            if (condition == string.Empty)
            {
                return(EFGenericRepository.Get <Student>().ToArray());
            }

            return(EFGenericRepository.Get <Student>()
                   .Where(searchCriteria, condition)
                   .ToArray());
        }
Esempio n. 17
0
        private void StudentBoard_LoadBoard(object sender, EventArgs e)
        {
            var groups         = (IList <Group>)EFGenericRepository.Get <Group>().ToList();
            var listGroupViews = _groupView.CreateListViews(groups.Count);

            for (var i = 0; i < listGroupViews.Length; i++)
            {
                var groupView = (IGroupView)listGroupViews[i].FillView(groups[i]);

                _studentBoard.GroupsCollection.Add((Control)groupView);
            }
        }
Esempio n. 18
0
        private async Task DeleteControlsFromControlCollection(IEnumerable <Student> students, CancellationToken token)
        {
            await groupBoard.AddedStudentControlCollection.DeleteControls(
                students,
                EFGenericRepository.Get <Student>(),
                token);

            await groupBoard.CurrentStudentControlCollection.DeleteControls(
                students,
                EFGenericRepository.Get <Student>(),
                token);
        }
        private void EditGroupBoardFirst_LoadEditGroupBoardFirst(object sender, EventArgs e)
        {
            var groups         = (IList <Group>)EFGenericRepository.Get <Group>().ToList();
            var listGroupViews = _groupView.CreateListViews(groups.Count);

            for (int i = 0; i < listGroupViews.Length; i++)
            {
                var groupView = (IGroupView)listGroupViews[i].FillView(groups[i]);

                _editGroupBoardFirst.GroupCollection.Add((Control)groupView);
            }
        }
Esempio n. 20
0
        // инициализируем таблицу Заказы (вручную т.к. EF не хочет подтягивать зависимые сущности)
        public static List <Order_entity> init_Orders(DbContext db)
        {
            // создаем репозиторий комнат, для работы с бд
            db.Set <Order_entity>().Load();
            EFGenericRepository <Order_entity> orderRepo = new EFGenericRepository <Order_entity>(db);
            List <Order_entity> tmpList = (List <Order_entity>)orderRepo.Get();

            foreach (Order_entity order in tmpList)
            {
                order.customInit(db.Set <Clients>(), db.Set <Rooms>());
            }
            return(tmpList);
        }
Esempio n. 21
0
        public int CountWeekend(DateTime StartDay, DateTime EndDay, string TeamName)
        {
            int             Count   = 0;
            List <Vacation> list    = Vacationrepository.Get(i => i.TeamName == TeamName).ToList();;
            List <Vacation> listTwo = list.Where(i => (ChackWeekend(StartDay, EndDay, i.FirstDate, i.SecontDate, TeamName, i.TeamName))).ToList();

            if (list == null)
            {
                return(0);
            }
            Count = listTwo.Count();
            return(Count);
        }
Esempio n. 22
0
        public IEnumerable <NotificationDTO> GetNotifications()
        {
            var notifications = notiRepo.Get();

            if (notifications == null)
            {
                return(null);
            }

            var dtos = _mapper.Map <IEnumerable <Notification>, IEnumerable <NotificationDTO> >(notifications);

            return(dtos);
        }
Esempio n. 23
0
        private void StudentInfo_FormLoad(object sender, EventArgs e)
        {
            var student = EFGenericRepository.FindById <Students>(studentInfo.SutdentId);

            studentInfo.FirstName  = student.FirstName;
            studentInfo.LastName   = student.LastName;
            studentInfo.MiddleName = student.MiddleName;

            var marks = from s in EFGenericRepository.Get <Students>().Where(st => st.Id == student.Id)
                        join m in EFGenericRepository.Get <Marks>() on s.Id equals m.IdSt
                        select m;

            studentInfo.GridDataSource = marks.ToList();
        }
        private async Task <Group[]> GetGroups(string conditions, CancellationToken token)
        {
            return(await Task.Run(() =>
            {
                if (conditions != string.Empty)
                {
                    return EFGenericRepository.Get <Group>(s => s.Name.ToUpperInvariant()
                                                           .Contains(conditions.ToUpperInvariant()))
                    .ToArray();
                }

                return EFGenericRepository.Get <Group>().ToArray();
            }, token));
        }
Esempio n. 25
0
        public BrochureViewModel GetBrochure(int?id)
        {
            if (id == null)
            {
                throw new ValidationException("Id brochure not found", "");
            }
            var brochure = _brochureRepository.Get(id.Value);

            if (brochure == null)
            {
                throw new ValidationException("Brochure not found", "");
            }
            return(Mapper.Map <Brochure, BrochureViewModel>(brochure));
        }
        public MagazineViewModel GetMagazine(int?id)
        {
            if (id == null)
            {
                throw new ValidationException("Id magazine not found", "");
            }
            var magazine = _magazineRepository.Get(id.Value);

            if (magazine == null)
            {
                throw new ValidationException("Magazine not found", "");
            }
            return(Mapper.Map <Magazine, MagazineViewModel>(magazine));
        }
Esempio n. 27
0
        public AuthorViewModel GetAuthor(int?id)
        {
            if (id == null)
            {
                throw new ValidationException("Id author not found", "");
            }
            var author = _authorRepository.Get(id.Value);

            if (author == null)
            {
                throw new ValidationException("Author not found", "");
            }
            return(Mapper.Map <Author, AuthorViewModel>(author));
        }
Esempio n. 28
0
        public static List <Entity.Rooms> init_Rooms(DbContext db)
        {
            // создаем репозиторий комнат, для работы с бд
            db.Set <Rooms>().Load();
            EFGenericRepository <Entity.Rooms> roomsRepo = new EFGenericRepository <Entity.Rooms>(db);
            List <Entity.Rooms> tmpList = (List <Entity.Rooms>)roomsRepo.Get();

            // Т.к. EF не хочет устанавливать внешние связи, придется делать связи вручную
            foreach (Entity.Rooms room in tmpList)
            {
                room.customInit(db.Set <RoomTypes>());
            }

            return(tmpList);
        }
        public Customer GetTaskCustomer(int taskId)
        {
            int userId = 0;
            IEnumerable <TaskHistory> history = historyRepo.Get();

            foreach (TaskHistory s in history)
            {
                if (s.TaskId == taskId)
                {
                    userId = (int)s.TaskCustomerId;
                }
            }
            var dtos = mapper.Map <User, Customer>(userRepo.FindById(userId));

            return(dtos);
        }
        public IEnumerable <CommentDTO> GetComments(int taskId)
        {
            IEnumerable <Comment> MyComments = commentRepo.Get();
            List <CommentDTO>     result     = new List <CommentDTO>();

            foreach (var s in MyComments)
            {
                if ((int)s.TaskId == taskId)
                {
                    var dtos = mapper.Map <Comment, CommentDTO>(s);
                    dtos.UserName = mapper.Map <User, Customer>(userRepo.FindById(dtos.UserId)).Name;
                    result.Add(dtos);
                }
            }
            return(result);
        }