Esempio n. 1
0
        public async Task <IReadOnlyList <UserJobTitleDto> > GetJobtitlesAsync()
        {
            using (_dbContextScopeFactory.CreateReadOnly())
            {
                var jobTitles = await _userJobTitleRepository.GetListUserJobTitle();

                return(_mapper.Map <List <UserJobTitleDto> >(jobTitles));
            }
        }
        public async Task <IReadOnlyList <UserDepartmentDto> > GetCachedUserDepartmentDtos(bool clearCache = false)
        {
            if (_allUserDepartmentDtos == null || clearCache)
            {
                using (_dbContextScopeFactory.CreateReadOnly())
                {
                    var allUserDeptModels = await _userDepartmentRepository.GetAllUserDepartments();

                    var allItem     = _mapper.Map <List <UserDepartmentDto> >(allUserDeptModels);
                    var allJobTitle = await _userJobTitleRepository.GetListUserJobTitle();

                    var allUserDtos = _userServices.GetUsers();
                    var allDeptDtos = await _departmentServices.GetDepartmentsAsync();

                    ConvertToUserDepartmentDto(allItem, allJobTitle, allUserDtos, allDeptDtos);
                    _allUserDepartmentDtos = allItem;
                }
            }
            return(_allUserDepartmentDtos);
        }