public ICollection <ProgramDTO> GetUsersPrograms(ProgramDTO newProgram, String userName) { ActionResponse response = new ActionResponse(); ProgramRepository repository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>(); int UserId = GetCurrentUser().UserId; ICollection <Program> wantedPrograms; if (GetCurrentUser().Permission == (int)Enums.PermissionsType.Admin) { wantedPrograms = repository.GetALL(); } else { wantedPrograms = repository.Query().Where(CurrProgram => CurrProgram.UserPrograms.Any(currUser => currUser.UserId == UserId)).ToList(); } ICollection <ProgramDTO> ProgramDrills = wantedPrograms.Select <Program, ProgramDTO>(currProgram => ConvertEntityTODTO(currProgram)).ToList(); return(ProgramDrills); }
public ICollection <ProgramDTO> GetAllPrograms(ProgramDTO newProgram) { ActionResponse response = new ActionResponse(); ProgramRepository repository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>(); ICollection <Program> wantedPrograms = repository.GetALL(); ICollection <ProgramDTO> ProgramDrills = wantedPrograms .Select <Program, ProgramDTO>(currProgram => ConvertEntityTODTO(currProgram)).ToList(); return(ProgramDrills); }