Ejemplo n.º 1
0
 public override async Task <List <Shipper> > AllAsync()
 {
     return(await RepositoryDbSet
            .Include(a => a.ShipperName).ThenInclude(t => t.Translations)
            .Include(a => a.ShipperAddress).ThenInclude(t => t.Translations)
            .Include(a => a.PhoneNumber).ThenInclude(t => t.Translations)
            .Select(e => ShipperMapper.MapFromDomain(e)).ToListAsync());
 }
Ejemplo n.º 2
0
        public override async Task <Shipper> FindAsync(params object[] id)
        {
            var shipper = await RepositoryDbSet.FindAsync(id);

            return(ShipperMapper.MapFromDomain(await RepositoryDbSet.Where(a => a.Id == shipper.Id)
                                               .Include(a => a.ShipperName).ThenInclude(t => t.Translations)
                                               .Include(a => a.ShipperAddress).ThenInclude(t => t.Translations)
                                               .Include(a => a.PhoneNumber).ThenInclude(t => t.Translations)
                                               .FirstOrDefaultAsync()));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <PublicApi.v1.DTO.ShipperWithOrderCount> > GetShipper(int id)
        {
            var shipper = await _bll.Shippers.FindByIdAsyncDTO(id);

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

            return(ShipperMapper.MapFromBLL(shipper));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PutShipper(int id, PublicApi.v1.DTO.Shipper shipper)
        {
            if (!ModelState.IsValid || id != shipper.Id)
            {
                return(BadRequest());
            }

            _bll.Shippers.Update(ShipperMapper.MapFromExternal(shipper));
            await _bll.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 5
0
        public async Task <List <Shipper> > AllAsync(string order, string searchFor, int?pageIndex, int?pageSize)
        {
            var query = RepositoryDbSet
                        .Include(a => a.ShipperName).ThenInclude(t => t.Translations)
                        .Include(a => a.ShipperAddress).ThenInclude(t => t.Translations)
                        .Include(a => a.PhoneNumber).ThenInclude(t => t.Translations)
                        .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 => ShipperMapper.MapFromDomain(e)).ToList();

            return(res);
        }
Ejemplo n.º 6
0
 public async Task <List <Shipper> > AllAsync(string order, string searchFor, int?pageIndex, int?pageSize)
 {
     return((await Uow.Shippers.AllAsync(order, searchFor, pageIndex, pageSize)).Select(e => ShipperMapper.MapFromDAL(e)).ToList());
 }
Ejemplo n.º 7
0
 public async Task <ShipperWithOrderCount> FindByIdAsyncDTO(int id)
 {
     return(ShipperMapper.MapFromDAL(await Uow.Shippers.FindByIdAsyncDTO(id)));
 }
Ejemplo n.º 8
0
        /*public async Task<IEnumerable<ShipperDTO>> GetAllWithOrdersCountByShopAsync(int? shopId)
         * {
         *  return await UOW.Shippers.GetAllWithOrdersCountByShopAsync(shopId);
         * }
         *
         * public async Task<ShipperDTO> FindByIdAsyncDTO(int id)
         * {
         *  return await UOW.Shippers.FindByIdAsyncDTO(id);
         * }*/

        public async Task <List <ShipperWithOrderCount> > GetAllWithOrdersCountByShopAsync(int?shopId, string search, int?pageIndex, int?pageSize)
        {
            return((await Uow.Shippers.GetAllWithOrdersCountByShopAsync(shopId, search, pageIndex, pageSize))
                   .Select(e => ShipperMapper.MapFromDAL(e)).ToList());
        }
Ejemplo n.º 9
0
        public async Task <ActionResult <IEnumerable <PublicApi.v1.DTO.ShipperWithOrderCount> > > GetShippers(string search, int?pageIndex, int?pageSize)
        {
            if ((pageIndex != null && pageIndex < 1) || (pageSize != null && pageSize < 1))
            {
                return(BadRequest());
            }
            var shipper = (await _bll.Shippers.GetAllWithOrdersCountByShopAsync(User.GetShopId(), search, pageIndex, pageSize)).Select(e => ShipperMapper.MapFromBLL(e)).ToList();

            return(shipper);
        }