Ejemplo n.º 1
0
        public JsonResult UserPackagePendingList(int offset, int limit, string sort, string order, int?userId, string requestDate)
        {
            var tz            = User.Identity.GetUserTimeZone();
            var queryableList = _investmentService.GetAllPendingUserPackage(userId);

            if (!requestDate.IsNullOrEmpty())
            {
                DateTime _date;
                DateTime.TryParseExact(requestDate, DBCDateFormat.ddMMMyyyy, CultureInfo.CurrentCulture, DateTimeStyles.None, out _date);
                if (_date != null)
                {
                    DateTime _endDate = _date.AddDays(1);
                    //get return date within its month
                    queryableList = queryableList.Where(x => x.CreatedTimestamp >= _date && x.CreatedTimestamp < _endDate);
                }
            }

            var allRowCount         = queryableList.Count();
            var sortedQueryableList = queryableList.PaginateList(sort, order, offset, limit, x => x.CreatedTimestamp);

            var rowsResult = sortedQueryableList.ToList().Select(x => new UserPackagePendingListViewModel
            {
                UserPackageId  = x.UserPackageId,
                Package        = x.Package.Description,
                RequestDate    = x.CreatedTimestamp.ToUserLocalDate(tz),
                Username       = x.User.Username,
                IsNewUser      = (x.User.StatusId == (int)EStatus.Pending) ? "Yes" : "No",
                InvestedAmount = x.TotalAmount,
                ReturnRate     = x.InterestRate,
                Status         = x.Status.Description,
                ImageLink      = new List <ActionLink>
                {
                    new ActionLink()
                    {
                        Name = "Image",
                        Url  = Url.Action("GetUploadReceipt", "Image", new {
                            relativePath = ConfigurationManager.AppSettings[""],
                            imageName    = x.ReceiptImagePath
                        }),
                        ClassName = "image-previewable"
                    },
                },
                ActionTags = new Func <List <ActionTag> >(() =>
                {
                    List <ActionTag> links = new List <ActionTag>();

                    links.Add(new ActionTag()
                    {
                        Name   = "Void",
                        Action = "void",
                    });

                    links.Add(new ActionTag()
                    {
                        Name   = "Approve",
                        Action = "approve",
                    });

                    return(links);
                })()
            });

            var model = new
            {
                total = allRowCount,
                rows  = rowsResult
            };

            return(Json(model, JsonRequestBehavior.AllowGet));
        }