Exemple #1
0
        public ActionResult ListFundTransactionReport(GridCommand command, TransactionModel model)
        {
            var      gridModel      = new GridModel <AllTransactionModel>();
            DateTime?startDateValue = (model.StartDate == null) ? null : model.StartDate;
            DateTime?endDateValue   = (model.EndDate == null) ? null : model.EndDate;

            int[] StatusIds          = model.StatusIds.ToIntArray();
            int[] TranscationTypeIds = { (int)TransactionType.PoolBonus };
            var   customerid         = _workContext.CurrentCustomer.Id;
            bool  Is_Visible         = false;

            if (_workContext.CurrentCustomer.IsInCustomerRole("Administrators"))
            {
                customerid = 0;
                Is_Visible = true;
            }

            var transcation = _transactionService.GetAllTransactions(model.CustomerId, 1, model.StartDate, model.EndDate, command.Page - 1, command.PageSize);

            var currency = _workContext.WorkingCurrency.CurrencyCode;

            int[] Coin = new int[] { 15, 16, 17 };
            gridModel.Data = transcation.Select(x =>
            {
                var transModel = new AllTransactionModel
                {
                    CustomerId       = x.CustomerId,
                    FinalAmountRaw   = x.Amount + " " + (Coin.Contains(x.TranscationTypeId) == true ? "Coin" : currency),
                    TransactionDate  = x.TransactionDate,
                    CustomerUserName = x.SenderUserName,
                    RefUserName      = x.ReceiverUserName
                };

                transModel.TransactionDateString = transModel.TransactionDate.ToString("g");

                return(transModel);
            });

            gridModel.Total = transcation.TotalCount;

            return(new JsonResult
            {
                Data = gridModel
            });
        }
        public HttpResponseMessage ListTransactionReport(TransactionModel model)
        {
            var customerguid = Request.Headers.GetValues("CustomerGUID").FirstOrDefault();

            if (customerguid != null)
            {
                var cust = _customerService.GetCustomerByGuid(Guid.Parse(customerguid));
                if (model.CustomerId != cust.Id)
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, new { code = 0, Message = "something went wrong" }));
                }
            }
            var gridModel = new GridModel <AllTransactionModel>();

            var transcation = _transactionService.GetAllTransactions(model.CustomerId, model.TranscationTypeId, model.StartDate, model.EndDate);

            var currency = _workContext.WorkingCurrency.CurrencyCode;

            int[] Coin = new int[] { 15, 16, 17 };
            gridModel.Data = transcation.Select(x =>
            {
                var transModel = new AllTransactionModel
                {
                    Id               = x.Id,
                    CustomerId       = x.CustomerId,
                    FinalAmountRaw   = x.Amount + " " + (Coin.Contains(x.TranscationTypeId) == true ? "Coin" : currency),
                    TransactionDate  = x.TransactionDate,
                    CustomerUserName = x.SenderUserName,
                    RefUserName      = x.ReceiverUserName,
                    StokistName      = x.StokistName
                };

                transModel.TransactionDateString = transModel.TransactionDate.ToString("g");

                return(transModel);
            }).ToList();

            return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "success", data = gridModel }));
        }