public ListResult <GarmentLetterOfCreditViewModel> Read(int page, int size, string filter, string order, string keyword) { var query = _repository.ReadAll(); List <string> SearchAttributes = new List <string>() { "DocumentCreditNo", "IssuedBank", "ApplicantName", "UomUnit" }; query = QueryHelper <GarmentShippingLetterOfCreditModel> .Search(query, SearchAttributes, keyword); Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter); query = QueryHelper <GarmentShippingLetterOfCreditModel> .Filter(query, FilterDictionary); Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order); query = QueryHelper <GarmentShippingLetterOfCreditModel> .Order(query, OrderDictionary); var data = query .Skip((page - 1) * size) .Take(size) .Select(model => MapToViewModel(model)) .ToList(); return(new ListResult <GarmentLetterOfCreditViewModel>(data, page, size, query.Count())); }
public IQueryable <GarmentLetterOfCreditMonitoringViewModel> GetData(string buyerAgent, string lcNo, DateTime?dateFrom, DateTime?dateTo, int offset) { var queryLC = lcrepository.ReadAll(); var queryInv = invrepository.ReadAll(); var queryPL = plrepository.ReadAll(); if (!string.IsNullOrWhiteSpace(buyerAgent)) { queryLC = queryLC.Where(w => w.ApplicantCode == buyerAgent); } if (!string.IsNullOrWhiteSpace(lcNo)) { queryLC = queryLC.Where(w => w.DocumentCreditNo == lcNo); } DateTime DateFrom = dateFrom == null ? new DateTime(1970, 1, 1) : (DateTime)dateFrom; DateTime DateTo = dateTo == null ? DateTime.Now : (DateTime)dateTo; queryLC = queryLC.Where(w => w.Date.AddHours(offset).Date >= DateFrom.Date && w.Date.AddHours(offset).Date <= DateTo.Date); queryLC = queryLC.OrderBy(w => w.ApplicantCode); var Query = (from a in queryLC join b in queryInv on a.ApplicantId equals b.BuyerAgentId join c in queryPL on b.PackingListId equals c.Id where a.IsDeleted == false && c.IsDeleted == false && c.IsDeleted == false && c.PaymentTerm == "LC" && a.DocumentCreditNo == c.LCNo select new GarmentLetterOfCreditMonitoringViewModel { LCNo = a.DocumentCreditNo, LCDate = a.Date, IssuedBank = a.IssuedBank, ApplicantName = a.ApplicantCode + " - " + a.ApplicantName, InvoiceNo = c.InvoiceNo, TruckingDate = c.TruckingDate, ExpiredDate = a.ExpireDate, ExpiredPlace = a.ExpirePlace, LatestShipment = a.LatestShipment, LCCondition = a.LCCondition, AmountToBePaid = b.AmountToBePaid, Quantity = a.Quantity, UomUnit = a.UomUnit, AmountLC = a.TotalAmount, }); return(Query); }