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); }
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(); } } }
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))); }
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)); }
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)); }
/// <summary> /// Получает факультет по идентификатору. /// </summary> /// <param name="id">Идентификатор.</param> /// <returns>Факультет.</returns> public FacultyItem GetById(int id) { return(_facultyRepository.Get(id)); }