Ejemplo n.º 1
0
        //获得城市下拉选项直到车间
        public List <object> GetCityCascaderOptionsTilWorkshop()
        {
            var            cityQuery = _cityRepository.GetAll().Where(c => c.IsDeleted == false);
            List <City>    cities1   = cityQuery.ToList();
            List <CityDto> cities    = ObjectMapper.Map <List <CityDto> >(cities1);
            List <object>  result    = new List <object>();

            result.Add(new { value = "全部", label = "全部" });
            foreach (CityDto c in cities)
            {
                List <object>     children     = new List <object>();
                var               factoryQuery = _factoryRepository.GetAll().Where(f => f.IsDeleted == false).Where(f => f.City.CityName == c.CityName);
                List <Factory>    factories1   = factoryQuery.ToList();
                List <FactoryDto> factories    = ObjectMapper.Map <List <FactoryDto> >(factories1);
                children.Add(new { value = "全部", label = "全部" });
                foreach (FactoryDto f in factories)
                {
                    List <object>      subchildren   = new List <object>();
                    var                workshopQuery = _workshopRepository.GetAll().Where(w => w.IsDeleted == false).Where(w => w.Factory.FactoryName == f.FactoryName);
                    List <Workshop>    workshops1    = workshopQuery.ToList();
                    List <WorkshopDto> workshops     = ObjectMapper.Map <List <WorkshopDto> >(workshops1);
                    subchildren.Add(new { value = "全部", label = "全部" });
                    foreach (WorkshopDto w in workshops)
                    {
                        subchildren.Add(new { value = w.WorkshopName, label = w.WorkshopName });
                    }
                    children.Add(new { value = f.FactoryName, label = f.FactoryName, Workshop = subchildren });
                }
                result.Add(new { value = c.CityName, label = c.CityName, Factory = children });
            }

            return(result);
        }
Ejemplo n.º 2
0
        public PagedResultDto <WorkshopDto> GetByCity(string CityName)
        {
            var cityQuery = _cityRepository.GetAll().Where(c => c.CityName == CityName).Where(g => g.IsDeleted == false);

            if (!cityQuery.Any())
            {
                throw new ApplicationException("城市不存在或已被删除");
            }
            var query = _workshopRepository.GetAll().Where(d => d.IsDeleted == false).Where(w => w.Factory.City.CityName == CityName)
                        .Include(w => w.Factory)
                        .Include(w => w.Factory.City);
            var total  = query.Count();
            var result = query.ToList();

            return(new PagedResultDto <WorkshopDto>(total, ObjectMapper.Map <List <WorkshopDto> >(result)));
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <WorkshopShortViewModel> > GetAll()
        {
            using (var scope = _dbContextScope.CreateReadOnly())
            {
                var workshopsData = await _workshopRepo.GetAll();

                return(Mapper.Map <IEnumerable <WorkshopShortViewModel> >(workshopsData));
            }
        }
Ejemplo n.º 4
0
        public PagedResultDto <GatewayDto> GetByWorkshop(string WorkshopName)
        {
            var workQuery = _workshopRepository.GetAll().Where(w => w.WorkshopName == WorkshopName).Where(g => g.IsDeleted == false);

            if (!workQuery.Any())
            {
                throw new ApplicationException("workshop不存在或已被删除");
            }
            var query = _gatewayRepository.GetAll().Where(d => d.IsDeleted == false).Where(g => g.Workshop.WorkshopName == WorkshopName)
                        .Include(g => g.Workshop)
                        .Include(g => g.Workshop.Factory)
                        .Include(g => g.Workshop.Factory.City)
                        .Include(g => g.GatewayType);
            var total  = query.Count();
            var result = query.ToList();

            return(new PagedResultDto <GatewayDto>(total, ObjectMapper.Map <List <GatewayDto> >(result)));
        }
Ejemplo n.º 5
0
 public IQueryable <Workshop> GetAll()
 {
     return(_workshopRepositories.GetAll());
 }