Exemple #1
0
        public ListResult <IndexViewModel> Read(int page, int size, string filter, string order, string keyword)
        {
            var query = _repository.ReadAll();

            List <string> SearchAttributes = new List <string>()
            {
                "BuyerAgentCode", "BuyerAgentName"
            };

            query = QueryHelper <GarmentDebiturBalanceModel> .Search(query, SearchAttributes, keyword);

            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter);

            query = QueryHelper <GarmentDebiturBalanceModel> .Filter(query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            query = QueryHelper <GarmentDebiturBalanceModel> .Order(query, OrderDictionary);

            var data = query
                       .Skip((page - 1) * size)
                       .Take(size)
                       .Select(model => new IndexViewModel
            {
                id               = model.Id,
                buyerAgentId     = model.BuyerAgentId,
                buyerAgentCode   = model.BuyerAgentCode,
                buyerAgentName   = model.BuyerAgentName,
                balanceAmount    = model.BalanceAmount,
                balanceAmountIDR = model.BalanceAmountIDR,
                balanceDate      = model.BalanceDate,
            })
                       .ToList();

            return(new ListResult <IndexViewModel>(data, page, size, query.Count()));
        }