Esempio n. 1
0
        public ActionResult GetDistributedCouponList()
        {
            GetDistributedCouponListArgs args = RequestArgs <GetDistributedCouponListArgs>();

            if (args == null)
            {
                return(RespondResult(false, "参数无效。"));
            }

            args.DomainId = UserContext.User.Domain;
            args.AppId    = DomainContext.AppId;

            GetItemListResult result = _couponManager.GetDistributedCouponList(args);

            return(RespondDataResult(result));
        }
        public GetItemListResult GetDistributedCouponList(GetDistributedCouponListArgs args)
        {
            List <CommandParameter> parameterList = new List <CommandParameter>();

            parameterList.Add(new CommandParameter("@domainId", args.DomainId));
            parameterList.Add(new CommandParameter("@appId", args.AppId));
            parameterList.Add(new CommandParameter("@page", args.Page));
            parameterList.Add(new CommandParameter("@pageSize", args.PageSize));
            parameterList.Add(new CommandParameter("@couponId", args.CouponId));
            parameterList.Add(new CommandParameter("@serialNumber", args.SerialNumber));
            parameterList.Add(new CommandParameter("@memberNickName", args.MemberNickName));
            if (args.Status.HasValue)
            {
                parameterList.Add(new CommandParameter("@status", args.Status.Value));
            }
            else
            {
                parameterList.Add(new CommandParameter("@status", DBNull.Value));
            }

            DataSet dsResult =
                _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetDistributedCouponList", parameterList,
                                         new string[] { "result" });

            if (dsResult.Tables[0].Rows.Count == 0 && args.Page > 1)
            {
                args.Page--;
                return(GetDistributedCouponList(args));
            }

            GetItemListResult result = new GetItemListResult();

            result.ItemList = dsResult.Tables[0];

            int totalCount = int.Parse(dsResult.Tables[1].Rows[0][0].ToString());

            result.TotalCount = totalCount;
            result.TotalPage  = totalCount / args.PageSize;
            if (totalCount % args.PageSize > 0)
            {
                result.TotalPage++;
            }
            result.Page = args.Page;

            return(result);
        }