Esempio n. 1
0
 public async Task <IEnumerable <IGrouping <char, FacultyDTO> > > GetByUniversityAsync(int universityId)
 {
     return((await _facultyRepository.Get()
             .Where(s => s.UniversityId == universityId)
             .OrderBy(s => s.Name)
             .ToListAsync())
            .Select(s => new FacultyDTO(s)).GroupBy(s => s.Name.ToArray().First()));
 }
        public IEnumerable <FacultyDTO> GetAll()
        {
            var faculties = _facultyRepository.Get();

            var mapped = faculties.Select(Mapper.Map <FacultyDTO>).ToList();

            return(mapped);
        }
Esempio n. 3
0
 public void DeleteFaculty(Faculty faculty)
 {
     using (var scope = Db.BeginWork())
     {
         var baseFaculty = _facultyRepository.Get(u => u.Id == faculty.Id);
         if (baseFaculty != null)
         {
             _facultyRepository.Delete(baseFaculty);
             scope.SaveChanges();
         }
     }
 }
Esempio n. 4
0
        public async Task <PaginatedList <FacultyModel> > Get(SearchModel model)
        {
            var spec = model.ToSpecification <Faculty>();

            var entities = await repository.Get(spec);

            var count = await repository.CountAsync();

            return(new PaginatedList <FacultyModel>(
                       model.PageIndex,
                       entities.Count,
                       count,
                       mapper.Map <IList <FacultyModel> >(entities)));
        }
Esempio n. 5
0
        public async Task Execute(UpdateFacultyInput input)
        {
            if (input == null)
            {
                outputPort.WriteError(""); return;
            }

            if (await facultyRepository.Get(input.UpdateFaculty.Id) == null)
            {
                outputPort.NotFound(""); return;
            }

            bool success = await facultyRepository.Update(input.UpdateFaculty);

            outputPort.Standart(new UpdateFacultyOutput(success));
        }
Esempio n. 6
0
        public IActionResult Groups(int facultyId)
        {
            // Get list of faculties groups.
            var groups = _repository.Groups(facultyId);
            // Get list of students without groups.
            var membersWithoutGroups = _repository.Members(facultyId).Where(m => m.GroupId == null);

            FacultiesGroupsViewModel model = new FacultiesGroupsViewModel
            {
                FacultyTitle         = _repository.Get(facultyId).Title,
                Groups               = groups,
                MembersWithoutGroups = membersWithoutGroups
            };

            if (facultyId != 0)
            {
                return(View(model));
            }

            return(View(model));
        }
        public async Task Execute(GetFacultiesInput input)
        {
            var result = await facultyRepository.Get();

            outputPort.Standart(new GetFacultiesOutput(result));
        }
Esempio n. 8
0
 /// <summary>
 /// Получает факультет по идентификатору.
 /// </summary>
 /// <param name="id">Идентификатор.</param>
 /// <returns>Факультет.</returns>
 public FacultyItem GetById(int id)
 {
     return(_facultyRepository.Get(id));
 }