public async Task <byte[]> ExportActivityForHQOwner(Guid userId, Guid headQuarterId, Nullable <Guid> schoolId) { Entities.School headQuarter = await _unitOfWork.Schools.GetByIdIncludeClasses(headQuarterId); List <Guid> schoolIds = new List <Guid> { headQuarter.Id }; IEnumerable <Entities.School> efSchools = await _unitOfWork.Schools.FindIncludeClasses(s => s.ParentId.Equals(headQuarterId)); efSchools.Prepend(headQuarter); IEnumerable <School> schools = _mapper.Map <IEnumerable <Entities.School>, IEnumerable <School> >(efSchools); schools = schools.Where(s => !schoolId.HasValue || s.Id.Equals(schoolId.Value)); byte[] result; using (var package = new ExcelPackage()) { foreach (var school in schools) { await AppendSheetForEachSchool(package.Workbook.Worksheets, school); } result = package.GetAsByteArray(); } return(result); }
public School GetById(Guid schoolId) { Entities.School efSchool = _unitOfWork.Schools.SingleOrDefault(c => c.Id.Equals(schoolId)); School school = _mapper.Map <Entities.School, School>(efSchool); return(school); }