public JsonResult GetPurchaseDateByLimitOffset(int limit, int offset) { var ldvm = new ListDepreciationViewModel(); var listPurchaseNo = _repDepreciation.ListPurchaseNo(); //ldvm.PurchasedDateString = listPurchaseNo.Skip(0).Take(10); var listDepreciation = new List <ListDepreciationViewModel>(); foreach (var item in listPurchaseNo) { var ldvmObj = new ListDepreciationViewModel(); ldvmObj.AssetPurchaseId = item.AssetPurchaseId; ldvmObj.PurchaseNo = item.PurchaseNo; ldvmObj.AssetName = item.AssetName; ldvmObj.PurchasedPrice = item.PurchasedPrice; ldvmObj.CurrentAssetValue = Decimal.Parse(CurrentItemValue.GetCurrentValue(item.AssetPurchaseId).ToString("#.##")); var purchasedPrice = _repPurchaseAsset.GetAssetPurchaseDetails() .Where(x => x.Id == item.AssetPurchaseId) .SingleOrDefault().PricePerUnit; ldvmObj.DepRateList = _repDepreciation.GetDepreciation() .Where(x => x.AssetPurchaseId == item.AssetPurchaseId) .Select(x => new DepreciationRateViewModel() { AssetPurchaseId = x.AssetPurchaseId, PurchasedDate = x.PurchasedDate, Year = x.Year, Rate = x.Rate, DepreciationType = x.DepreciationType, DepreciationMaturityDate = x.DepreciationMaturityDate, DepreciationEntryDate = x.DepreciationEntryDate, //CurrentAssetValue = Decimal.Parse(CurrentItemValue.GetCurrentValue(x.AssetPurchaseId).ToString("#.##")) //CurrentAssetValue = Decimal.Parse(GetCurrentAssetValue(purchasedPrice, // x.PurchasedDate, // x.Rate, // "fixed").ToString("#.##")) }).OrderByDescending(x => x.Year).ToList(); listDepreciation.Add(ldvmObj); } ldvm.ListDepreciation = listDepreciation.Skip(offset).Take(limit).ToList(); ldvm.TotalDateCount = _repDepreciation.ListPurchaseNo().Count(); var json = JsonConvert.SerializeObject(ldvm); if (ldvm != null) { return(Json(json, JsonRequestBehavior.AllowGet)); } return(Json("[]", JsonRequestBehavior.AllowGet)); }
public ViewResult ListDepreciationValue() { ViewBag.Title = Constant.LIST_DEPRECIATION; var ldvm = new ListDepreciationViewModel(); var listPurchaseNo = _repDepreciation.ListPurchaseNo(); //ldvm.PurchasedDateString = listPurchaseNo.Skip(0).Take(10); var listDepreciation = new List <ListDepreciationViewModel>(); foreach (var item in listPurchaseNo) { var ldvmObj = new ListDepreciationViewModel(); ldvmObj.AssetPurchaseId = item.AssetPurchaseId; ldvmObj.PurchaseNo = item.PurchaseNo; ldvmObj.AssetName = item.AssetName; ldvmObj.PurchasedPrice = item.PurchasedPrice; ldvmObj.CurrentAssetValue = Decimal.Parse(CurrentItemValue.GetCurrentValue(item.AssetPurchaseId).ToString("#.##")); var purchasedPrice = _repPurchaseAsset.GetAssetPurchaseDetails() .Where(x => x.Id == item.AssetPurchaseId) .SingleOrDefault().PricePerUnit; ldvmObj.DepRateList = _repDepreciation.GetDepreciation() .Where(x => x.AssetPurchaseId == item.AssetPurchaseId) .Select(x => new DepreciationRateViewModel() { AssetPurchaseId = x.AssetPurchaseId, PurchasedDate = x.PurchasedDate, Year = x.Year, Rate = x.Rate, DepreciationType = x.DepreciationType, DepreciationMaturityDate = x.DepreciationMaturityDate, DepreciationEntryDate = x.DepreciationEntryDate, //CurrentAssetValue = Decimal.Parse(CurrentItemValue.GetCurrentValue(x.AssetPurchaseId).ToString("#.##")) //CurrentAssetValue = Decimal.Parse(GetCurrentAssetValue(purchasedPrice, // x.PurchasedDate, // x.Rate, // "fixed").ToString("#.##")) }).OrderByDescending(x => x.Year).ToList(); listDepreciation.Add(ldvmObj); } ldvm.ListDepreciation = listDepreciation.Skip(0).Take(10).ToList(); ldvm.TotalDateCount = _repDepreciation.ListPurchaseNo().Count(); ldvm.DateCount = listDepreciation.Skip(0).Take(10).ToList().Count(); return(View(ldvm)); }