public List <RefundReportDTO> GetListRefundByBusinessDay(List <string> lstStoreIds, List <string> lstReceiptId) { var result = new List <RefundReportDTO>(); using (var cxt = new NuWebContext()) { var query = (from r in cxt.R_Refund join rd in cxt.R_RefundDetail on r.Id equals rd.RefundId where lstReceiptId.Contains(r.OrderId) && lstStoreIds.Contains(r.StoreId) select new { r, rd }); if (query != null && query.Any()) { var lstHeader = query.Select(ss => ss.r).Distinct().ToList(); var lstRefundDetail = query.Select(ss => new RefundDetailReportDTO() { RefundId = ss.rd.RefundId, ItemId = ss.rd.ItemId, ItemType = ss.rd.ItemType, ItemName = ss.rd.ItemName, PriceValue = ss.rd.PriceValue, Qty = ss.rd.Qty, ServiceCharged = ss.rd.ServiceCharged, Tax = ss.rd.Tax, PromotionAmount = ss.rd.PromotionAmount, DiscountAmount = ss.rd.DiscountAmount }).ToList(); RefundReportDTO refund = null; foreach (var item in lstHeader) { refund = new RefundReportDTO(); refund.Id = item.Id; refund.BusinessDayId = item.BusinessDayId; refund.CreatedDate = item.CreatedDate; refund.CreatedUser = item.CreatedUser; refund.Description = item.Description; refund.StoreId = item.StoreId; refund.TotalRefund = item.TotalRefund; refund.Promotion = item.Promotion; refund.ServiceCharged = item.ServiceCharged; refund.Tax = item.Tax; refund.Discount = item.Discount; refund.OrderId = item.OrderId; refund.ReceiptDate = item.ReceiptDate; refund.ListDetails = lstRefundDetail.Where(ww => ww.RefundId == refund.Id).ToList(); result.Add(refund); } } } return(result); }
public List <RefundReportDTO> GetListRefund(List <string> lstStoreIds, DateTime dFrom, DateTime dTo, int mode) { var result = new List <RefundReportDTO>(); //get business day var lstBusinessDays = _baseFactory.GetBusinessDays(dFrom, dTo, lstStoreIds, mode); if (lstBusinessDays != null && lstBusinessDays.Any()) { var dMin = lstBusinessDays.Min(ss => ss.DateFrom); var dMax = lstBusinessDays.Max(ss => ss.DateTo); using (var cxt = new NuWebContext()) { var query = (from r in cxt.R_Refund join rd in cxt.R_RefundDetail on r.Id equals rd.RefundId where r.CreatedDate >= dMin && r.CreatedDate <= dMax && lstStoreIds.Contains(r.StoreId) select new { r, rd }); if (query != null && query.Any()) { var lstHeader = query.Select(ss => ss.r).Distinct().ToList(); var lstRefundDetail = query.Select(ss => new RefundDetailReportDTO() { RefundId = ss.rd.RefundId, ItemId = ss.rd.ItemId, ItemType = ss.rd.ItemType, ItemName = ss.rd.ItemName, PriceValue = ss.rd.PriceValue, Qty = ss.rd.Qty, ServiceCharged = ss.rd.ServiceCharged, Tax = ss.rd.Tax, PromotionAmount = ss.rd.PromotionAmount, DiscountAmount = ss.rd.DiscountAmount }).ToList(); RefundReportDTO refund = null; foreach (var item in lstHeader) { refund = new RefundReportDTO(); refund.Id = item.Id; refund.BusinessDayId = item.BusinessDayId; refund.CreatedDate = item.CreatedDate; refund.CreatedUser = item.CreatedUser; refund.Description = item.Description; refund.StoreId = item.StoreId; refund.TotalRefund = item.TotalRefund; refund.Promotion = item.Promotion; refund.ServiceCharged = item.ServiceCharged; refund.Tax = item.Tax; refund.Discount = item.Discount; refund.OrderId = item.OrderId; refund.ReceiptDate = item.ReceiptDate; refund.ListDetails = lstRefundDetail.Where(ww => ww.RefundId == refund.Id).ToList(); result.Add(refund); } } } } return(result); }