Example #1
0
 //[ResponseType(typeof(Models.Return.R_Users.R_GetRechargeApplyList))]
 public Task <IApiResult <R_Users.GetRechargeApplyList_Result> > GetRechargeApplyList([FromUri] P_Users.P_GetRechargeApplyList pars)
 {
     pars.SetHost(Request.RequestUri.Host, Request.RequestUri.Port);
     return(ApiAsync <P_Users.P_GetRechargeApplyList, R_Users.GetRechargeApplyList_Result>(pars, new BLL.UsersManager.Users().GetRechargeApplyList));
 }
Example #2
0
        public Task <IApiResult <R_Users.GetRechargeApplyList_Result> > GetRechargeApplyList(P_Users.P_GetRechargeApplyList arg)
        {
            return(Task.Run(() =>
            {
                IApiResult <R_Users.GetRechargeApplyList_Result> ar = new IApiResult <R_Users.GetRechargeApplyList_Result>();
                try
                {
                    string host = "";
                    var prot = 80;
                    arg.GetHost(out host, out prot);
                    if (prot != 80)
                    {
                        host += ":" + prot + "/";
                    }

                    //select new
                    //{
                    //    r.RID,
                    //    r.IsCheck,
                    //    r.Created,
                    //    r.Bank,
                    //    r.PaymentMethod,
                    //    Rroof = host + r.ProofImg,
                    //    r.TransferTime,
                    //    u.UserName,
                    //    u.UserID
                    //};
                    using (DAL.CarRentEntities db = new DAL.CarRentEntities())
                    {
                        var rr = from r in db.RechargeRecord
                                 join u in db.Users on r.UserID equals u.UserID
                                 where r.Deleted == false
                                 select new Models.Return.R_Users.GetRechargeApplyList_Result.GetRechargeApplyList_PageList
                        {
                            PaymentMethod = r.PaymentMethod,
                            IsCheck = r.IsCheck,
                            TransferMethod = r.TransferMethod,
                            RID = r.RID,
                            Proof = host + r.ProofImg,
                            TransferTime = r.TransferTime,
                            UserID = u.UserID,
                            UserName = u.UserName,
                            Remark = r.Remark,
                            Fee = r.Money,
                            Created = r.Created
                        };
                        if (arg.type != 2)
                        {
                            bool a = arg.type == 1 ? true : false;
                            rr = rr.Where(r => r.IsCheck == a);
                        }
                        if (arg.start_time != null)
                        {
                            rr.Where(r => r.TransferTime >= arg.start_time);
                        }
                        if (arg.end_time != null)
                        {
                            rr.Where(r => r.TransferTime <= arg.end_time);
                        }
                        if (arg.transfer_method != null)
                        {
                            rr.Where(r => r.PaymentMethod == arg.transfer_method);
                        }
                        int count = rr.Count();
                        var index = (arg.p - 1) * arg.pagesize;

                        var list = rr.OrderBy((r) => r.RID).Skip(index).Take(arg.pagesize).ToList();
                        list.ForEach((s) => { s.RowIndex = ++index; });
                        ar.message = $"There are {count} data";
                        //ar.result =  new
                        //{
                        //    total = count,
                        //    pages = Math.Ceiling(count/arg.pagesize+0.0) + 1,
                        //    list = list
                        //};
                        ar.result = new R_Users.GetRechargeApplyList_Result
                        {
                            total = count,
                            list = list,
                            pages = count % arg.pagesize == 0 ? count / arg.pagesize : count / arg.pagesize + 1,
                        };
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(this, ex);
                    ar.code = Interface.StatusCode.error;
                    ar.message = ex.Message;
                }
                return ar;
            }));
        }