public ActionResult ListMyInvestment(GridCommand command) { var gridModel = new GridModel <MyInvestmentPlan>(); var customerplan = _workContext.CurrentCustomer.CustomerPlan.Where(x => x.IsActive == true).ToList(); gridModel.Data = customerplan.Select(x => { var myInvestment = new MyInvestmentPlan(); myInvestment.PlanName = _planService.GetPlanById(x.PlanId).Name; myInvestment.PurchaseDate = x.PurchaseDate; myInvestment.ROIPaid = x.ROIPaid; myInvestment.RepurchaseWallet = x.RepurchaseWallet; myInvestment.ROIToPay = x.ROIToPay; myInvestment.ROIPending = (x.ROIToPay - x.ROIPaid); myInvestment.ROIPaidString = x.ROIPaid.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.ROIToPayString = x.ROIToPay.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.ROIPendingString = myInvestment.ROIPending.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.RepurchaseWalletString = myInvestment.RepurchaseWallet.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.TotalFundingString = x.AmountInvested.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.IsActive = x.IsActive; myInvestment.Status = (x.IsActive) ? ((x.IsExpired == false) ? "Active" : "Expired") : "InActive"; myInvestment.ExpireDate = x.ExpiredDate; return(myInvestment); }); gridModel.Total = customerplan.Count; return(new JsonResult { Data = gridModel }); }
public ActionResult MyShare() { MyInvestmentPlan model = new MyInvestmentPlan(); var customerplans = _workContext.CurrentCustomer.CustomerPlan.Where(x => x.IsActive == true).ToList(); model.MyTotalInvestment = customerplans.Select(x => x.AmountInvested).Sum(); model.MyTotalROIPaid = customerplans.Select(x => x.ROIPaid).Sum(); model.MyTotalROIToPay = customerplans.Select(x => x.ROIToPay).Sum(); model.MyTotalROIPending = model.MyTotalROIToPay - model.MyTotalROIPaid; ViewBag.CurrencyCode = _workContext.WorkingCurrency.CurrencyCode; return(View(model)); }
public HttpResponseMessage MyShare(int CustomerId) { string message = ""; try { var customerguid = Request.Headers.GetValues("CustomerGUID").FirstOrDefault(); if (customerguid != null) { var cust = _customerService.GetCustomerByGuid(Guid.Parse(customerguid)); if (CustomerId != cust.Id) { return(Request.CreateResponse(HttpStatusCode.Unauthorized, new { code = 0, Message = "something went wrong" })); } } var Customer = _customerService.GetCustomerById(CustomerId); var gridModel = new GridModel <MyInvestmentPlan>(); var customerplan = Customer.CustomerPlan.Where(x => x.IsActive == true).ToList(); gridModel.Data = customerplan.Select(x => { var myInvestment = new MyInvestmentPlan(); myInvestment.ShareId = x.Id; myInvestment.PlanId = x.PlanId; myInvestment.PlanName = _planService.GetPlanById(x.PlanId).Name; myInvestment.PurchaseDate = x.PurchaseDate; myInvestment.ROIPaid = x.ROIPaid; myInvestment.ROIToPay = x.ROIToPay; myInvestment.ROIPending = (x.ROIToPay - x.ROIPaid); myInvestment.ROIPaidString = x.ROIPaid.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.ROIToPayString = x.ROIToPay.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.ROIPendingString = myInvestment.ROIPending.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.TotalFundingString = x.AmountInvested.ToString() + " " + _workContext.WorkingCurrency.CurrencyCode; myInvestment.IsActive = x.IsActive; myInvestment.Status = (x.IsActive) ? ((x.IsExpired == false) ? "Active" : "Expired") : "InActive"; myInvestment.ExpireDate = x.ExpiredDate; return(myInvestment); }); gridModel.Total = customerplan.Count; message = "success"; return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = message, data = gridModel })); } catch (Exception ex) { message = T("Invesment.Deposit.FundingError").Text; } return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = message })); }