public List <ColorViewModel> GetAll()
        {
            var colors   = _colorRepository.FindAll();
            var colorVms = colors.ProjectTo <ColorViewModel>(colors).ToList();

            return(colorVms);
        }
        // GET: ColorController
        public async Task <ActionResult> Index()
        {
            var colors = await _repo.FindAll();

            var model = _mapper.Map <List <Color>, List <ColorVM> >(colors);

            return(View(model));
        }
Exemple #3
0
        public List <ColorViewModel> GetColorByProduct(int productId)
        {
            var query = (from t in _productQuantityRepository.FindAll()
                         join pt in _colorRepository.FindAll()
                         on t.ColorId equals pt.Id
                         where t.ProductId == productId
                         select pt).Distinct();

            return(query.ProjectTo <ColorViewModel>().ToList());
        }
Exemple #4
0
        public PageResult <ColorModel> GetSearchPaging(RoleSearch search)
        {
            var query = _colorRepository.FindAll();

            if (search.Id > 0)
            {
                query = query.Where(r => r.Id == search.Id);
            }

            if (!string.IsNullOrEmpty(search.Name))
            {
                query = query.Where(r => r.Name.Contains(search.Name));
            }
            //if (!string.IsNullOrEmpty(search.Description))
            //{
            //    query = query.Where(r => r.Description.Contains(search.Description));
            //}
            var Total = query.Count();

            var data = query
                       .OrderByDescending(U => U.CreatedDate)
                       .Skip((search.PageIndex - 1) * search.PageSize)
                       .Take(search.PageSize)
                       .Select(u => u.ToModel())
                       .ToList();

            var result = new PageResult <ColorModel>()
            {
                Results   = data,
                PageIndex = search.PageIndex,
                PageSize  = search.PageSize,
                Total     = Total,
            };

            return(result);
        }
Exemple #5
0
 public List <ColorViewModel> GetColors()
 {
     return(_colorRepository.FindAll().ProjectTo <ColorViewModel>().ToList());
 }
Exemple #6
0
        public List <ColorViewModel> GetAllColor()
        {
            var colors = _colorRepository.FindAll().ToList();

            return(Mapper.Map <List <Color>, List <ColorViewModel> >(colors));
        }
Exemple #7
0
 public async Task <List <ColorViewModel> > GetColors()
 {
     return(new ColorViewModel().Map((await _colorRepository.FindAll()).AsNoTracking()).ToList());
 }
Exemple #8
0
 public List <ColorViewModel> GetColors()
 {
     return(_colorRepository.FindAll().ProjectTo <ColorViewModel>(_mapper.ConfigurationProvider).ToList());
 }
Exemple #9
0
 public async Task <List <ColorViewModel> > GetAll()
 {
     return(new ColorViewModel().Map(await _colorRepository.FindAll()).ToList());
 }