示例#1
0
 public override async Task <List <Defect> > AllAsync()
 {
     return(await RepositoryDbSet
            .Include(d => d.Description).ThenInclude(t => t.Translations)
            .Include(a => a.Shop).ThenInclude(aa => aa.ShopName).ThenInclude(t => t.Translations)
            .Include(a => a.Shop).ThenInclude(aa => aa.ShopAddress).ThenInclude(t => t.Translations)
            .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact).ThenInclude(t => t.Translations)
            .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact2).ThenInclude(t => t.Translations)
            .Include(a => a.ProductsWithDefect).ThenInclude(aa => aa.Product).ThenInclude(aaa => aaa.ProductName).ThenInclude(t => t.Translations)
            .Select(e => DefectMapper.MapFromDomain(e)).ToListAsync());
 }
示例#2
0
        public async Task <ActionResult <PublicApi.v1.DTO.Defect> > GetDefect(int id)
        {
            var defect = await _bll.Defects.FindProductsWithDefectByShopAsync(id, User.GetShopId());

            if (defect == null)
            {
                return(NotFound());
            }

            return(DefectMapper.MapFromBLL(defect));
        }
示例#3
0
        public async Task <IActionResult> PutDefect(int id, PublicApi.v1.DTO.Defect defect)
        {
            if (!ModelState.IsValid || id != defect.Id || defect.ShopId != User.GetShopId())
            {
                return(BadRequest());
            }

            _bll.Defects.Update(DefectMapper.MapFromExternal(defect));
            await _bll.SaveChangesAsync();

            return(NoContent());
        }
示例#4
0
        public override async Task <Defect> FindAsync(params object[] id)
        {
            var defect = await RepositoryDbSet.FindAsync(id);

            return(DefectMapper.MapFromDomain(await RepositoryDbSet
                                              .Include(d => d.Description).ThenInclude(t => t.Translations)
                                              .Include(a => a.Shop).ThenInclude(aa => aa.ShopName).ThenInclude(t => t.Translations)
                                              .Include(a => a.Shop).ThenInclude(aa => aa.ShopAddress).ThenInclude(t => t.Translations)
                                              .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact).ThenInclude(t => t.Translations)
                                              .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact2).ThenInclude(t => t.Translations)
                                              .Include(a => a.ProductsWithDefect).ThenInclude(aa => aa.Product).ThenInclude(aaa => aaa.ProductName).ThenInclude(t => t.Translations)
                                              .Where(a => a.Id == defect.Id)
                                              .FirstOrDefaultAsync()));
        }
示例#5
0
        public async Task <List <Defect> > AllAsyncByShop(int?shopId, string order, string searchFor, int?pageIndex, int?pageSize)
        {
            var query = RepositoryDbSet
                        .Include(d => d.Description).ThenInclude(t => t.Translations)
                        .Include(a => a.Shop).ThenInclude(aa => aa.ShopName).ThenInclude(t => t.Translations)
                        .Include(a => a.Shop).ThenInclude(aa => aa.ShopAddress).ThenInclude(t => t.Translations)
                        .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact).ThenInclude(t => t.Translations)
                        .Include(a => a.Shop).ThenInclude(aa => aa.ShopContact2).ThenInclude(t => t.Translations)
                        .Include(a => a.ProductsWithDefect).ThenInclude(aa => aa.Product).ThenInclude(aaa => aaa.ProductName)
                        .ThenInclude(t => t.Translations)
                        .Where(s => s.ShopId == shopId).AsQueryable();

            query = Search(query, searchFor);
            query = Order(query, order);
            if (pageIndex != null && pageSize != null)
            {
                query = query.Skip((pageIndex.Value - 1) * pageSize.Value).Take(pageSize.Value);
            }
            var temp = await query.ToListAsync();

            var res = temp.Select(e => DefectMapper.MapFromDomain(e)).ToList();

            return(res);
        }
示例#6
0
 public async Task <DefectWithProductCount> FindProductsWithDefectByShopAsync(int id, int?shopId)
 {
     return(DefectMapper.MapFromDAL(await Uow.Defects.FindProductsWithDefectByShopAsync(id, shopId)));
 }
示例#7
0
 public async Task <List <DefectWithProductCount> > GetAllWithProductsWithDefectByShopAsync(int?shopId, string search, int?pageIndex, int?pageSize)
 {
     return((await Uow.Defects.GetAllWithProductsWithDefectByShopAsync(shopId, search, pageIndex, pageSize)).Select(e => DefectMapper.MapFromDAL(e)).ToList());
 }
示例#8
0
 public override async Task <Defect> FindAsync(params object[] id)
 {
     return(DefectMapper.MapFromDAL(await Uow.Defects.FindAsync(id)));
 }
示例#9
0
 public override async Task <List <Defect> > AllAsync()
 {
     return((await Uow.Defects.AllAsync()).Select(e => DefectMapper.MapFromDAL(e)).ToList());
 }
示例#10
0
 public async Task <List <Defect> > AllAsync(string order, string searchFor, int?pageIndex, int?pageSize)
 {
     return((await Uow.Defects.AllAsync(order, searchFor, pageIndex, pageSize)).Select(e => DefectMapper.MapFromDAL(e)).ToList());
 }
示例#11
0
        public async Task <ActionResult <IEnumerable <PublicApi.v1.DTO.Defect> > > GetDefects(string search, int?pageIndex, int?pageSize)
        {
            if ((pageIndex != null && pageIndex < 1) || (pageSize != null && pageSize < 1))
            {
                return(BadRequest());
            }
            var defect = (await _bll.Defects.GetAllWithProductsWithDefectByShopAsync(User.GetShopId(), search, pageIndex, pageSize)).Select(e => DefectMapper.MapFromBLL(e)).ToList();

            return(defect);
        }