Example #1
0
        public GetListDataResult <Member_Coupon_Account> GetMemberCouponList(GetListDataArgs args)
        {
            GetListDataResult <Member_Coupon_Account> result = new GetListDataResult <Member_Coupon_Account>();

            using (Entities db = new Entities())
            {
                IQueryable <Member_Coupon_Account> queryable = db.Member_Coupon_Account
                                                               .Include(t => t.Coupon_Info)
                                                               .Include(t => t.Member)
                                                               .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("IsUse") == false)
                {
                    int isUse = args.Parameters.GetIntValue("IsUse");
                    queryable = queryable.Where(t => t.is_use == isUse);
                }

                if (args.Parameters.IsNullOrEmpty("member_id") == false)
                {
                    int member_id = args.Parameters.GetIntValue("member_id");
                    queryable = queryable.Where(t => t.member_id == member_id);
                }
                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy).Include(t => t.Coupon_Info)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #2
0
        public GetListDataResult <Point_Exchange> GetPointExchangeList(GetListDataArgs args)
        {
            GetListDataResult <Point_Exchange> result = new GetListDataResult <Point_Exchange>();

            using (Entities db = new Entities())
            {
                IQueryable <Point_Exchange> queryable = db.Point_Exchange
                                                        .Include(c => c.Member)
                                                        .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("member_id") == false)
                {
                    int memberId = args.Parameters.GetIntValue("member_id");
                    queryable = queryable.Where(c => c.member_id == memberId);
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #3
0
        //会用到两个API
        public ActionResult QueryList()
        {
            AppGetProductInfoListArgs args = RequestArgs <AppGetProductInfoListArgs>();

            args.status  = 1;
            args.OrderBy = "create_date_time ASC";

            GetListDataArgs contractArgs = TransferAppGetListJsonArgsToGetListArgs.ToGetListDataArgs(args);

            contractArgs.Parameters.Add("stock", true); //只查有库存的

            GetListDataResult <Product_Info> productList = _productManager.GetProductList(contractArgs);

            AppGetListDataResult <ProductInfoAppDto> result = new AppGetListDataResult <ProductInfoAppDto>();

            result.pageNo      = productList.PagingInfo.CurrentPage;
            result.pageCount   = productList.PagingInfo.PageSize;
            result.totalPage   = productList.PagingInfo.TotalPage;
            result.totalRecord = productList.PagingInfo.TotalCount;

            result.objectList = Mapper.Map <List <Product_Info>, List <ProductInfoAppDto> >(productList.Data);

            TranscationAppNeedProductInfo(result, args);

            return(DataResult(result));
        }
Example #4
0
        //获取我的优惠券
        public ActionResult queryPage()
        {
            AppGetMemberCouponAccountListArgs args = RequestArgs <AppGetMemberCouponAccountListArgs>();

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

            args.MemberId = this.UserContext.Member.id;
            args.IsUse    = 0;
            args.OrderBy  = "create_time DESC";
            if (args.OrderByType == 1)
            {
                args.OrderBy = "create_time ASC";
            }
            GetListDataArgs contractArgs = TransferAppGetListJsonArgsToGetListArgs.ToGetListDataArgs(args);

            //查询符合条件的优惠券集合
            GetListDataResult <Member_Coupon_Account> memberCouponList = _couponManager.GetMemberCouponList(contractArgs);

            AppGetListDataResult <MemberCouponAccountAppDto> result = new AppGetListDataResult <MemberCouponAccountAppDto>();

            result.pageNo      = memberCouponList.PagingInfo.CurrentPage;
            result.pageCount   = memberCouponList.PagingInfo.PageSize;
            result.totalPage   = memberCouponList.PagingInfo.TotalPage;
            result.totalRecord = memberCouponList.PagingInfo.TotalCount;
            result.objectList  = Mapper.Map <List <Member_Coupon_Account>, List <MemberCouponAccountAppDto> >(memberCouponList.Data);

            return(DataResult(result));
        }
Example #5
0
        // GET: AppApi/Order
        public ActionResult QueryPage()
        {
            AppGetProductOrderMasterListArgs args = RequestArgs <AppGetProductOrderMasterListArgs>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }
            args.OrderBy    = "order_date_time DESC";
            args.PersonIdNo = UserContext.UserId;

            GetListDataArgs contractArgs = TransferAppGetListJsonArgsToGetListArgs.ToGetListDataArgs(args);

            GetListDataResult <Product_Order_Master> productList = _orderManager.GetOrderList(contractArgs);

            AppGetListDataResult <ProductOrderMasterAppDto> result = new AppGetListDataResult <ProductOrderMasterAppDto>();

            result.pageNo      = productList.PagingInfo.CurrentPage;
            result.pageCount   = productList.PagingInfo.PageSize;
            result.totalPage   = productList.PagingInfo.TotalPage;
            result.totalRecord = productList.PagingInfo.TotalCount;

            result.objectList = Mapper.Map <List <Product_Order_Master>, List <ProductOrderMasterAppDto> >(productList.Data);

            return(DataResult(result));
        }
Example #6
0
        // GET: AppApi/MicroClassGroup
        public ActionResult QueryMicroGroup()
        {
            AppGetMicroClassGroupListArgs args = RequestArgs <AppGetMicroClassGroupListArgs>();

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

            if (string.IsNullOrEmpty(args.OrderBy))
            {
                args.OrderBy = "Create_Time DESC";
            }
            GetListDataArgs contractArgs = TransferAppGetListJsonArgsToGetListArgs.ToGetListDataArgs(args);

            GetListDataResult <Micro_Class_Group> microClassGroupList = _microClassManager.GetMicroClassGroupList(contractArgs);


            AppGetListDataResult <MicroClassGroupAppDto> result = new AppGetListDataResult <MicroClassGroupAppDto>();

            result.pageNo      = microClassGroupList.PagingInfo.CurrentPage;
            result.pageCount   = microClassGroupList.PagingInfo.PageSize;
            result.totalPage   = microClassGroupList.PagingInfo.TotalPage;
            result.totalRecord = microClassGroupList.PagingInfo.TotalCount;

            result.objectList = Mapper.Map <List <Micro_Class_Group>, List <MicroClassGroupAppDto> >(microClassGroupList.Data);

            return(DataResult(result));
        }
Example #7
0
        public GetListDataResult <Micro_Class_Group> GetMicroClassGroupList(GetListDataArgs args)
        {
            GetListDataResult <Micro_Class_Group> result = new GetListDataResult <Micro_Class_Group>();

            using (Entities db = new Entities())
            {
                IQueryable <Micro_Class_Group> queryable = db.Micro_Class_Group
                                                           .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("Name") == false)
                {
                    string name = args.Parameters.GetValue <string>("Name");
                    queryable = queryable.Where(c => c.name.Contains(name));
                }
                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #8
0
        public GetListDataResult <Coupon_Info> GetCouponList(GetListDataArgs args)
        {
            GetListDataResult <Coupon_Info> result = new GetListDataResult <Coupon_Info>();

            using (Entities db = new Entities())
            {
                IQueryable <Coupon_Info> queryable = db.Coupon_Info.Where(c => c.is_lose_valid == 0)
                                                     .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("Keyword") == false)
                {
                    string keyword = args.Parameters.GetValue <string>("Keyword");
                    queryable = queryable.Where(c => c.name.Contains(keyword));
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #9
0
        public GetListDataResult <Micro_Class_Info> GetMicroClassInfoList(GetListDataArgs args)
        {
            GetListDataResult <Micro_Class_Info> result = new GetListDataResult <Micro_Class_Info>();

            using (Entities db = new Entities())
            {
                IQueryable <Micro_Class_Info> queryable = db.Micro_Class_Info
                                                          .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("TopicInfoTitle") == false)
                {
                    string topicInfoTitle = args.Parameters.GetValue("TopicInfoTitle");
                    queryable = queryable.Where(c => c.topic_info_title.Contains(topicInfoTitle));
                }
                if (args.Parameters.IsNullOrEmpty("GroupId") == false)
                {
                    int groupId = args.Parameters.GetIntValue("GroupId");
                    if (groupId > 0)
                    {
                        queryable = queryable.Where(c => c.group_id == groupId);
                    }
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy).Include(t => t.Micro_Class_Group)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
        public GetListDataResult <Push_Message> GetPushMessageList(GetListDataArgs args)
        {
            GetListDataResult <Push_Message> result = new GetListDataResult <Push_Message>();

            using (Entities db = new Entities())
            {
                IQueryable <Push_Message> queryable = db.Push_Message
                                                      .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("Keyword") == false)
                {
                    string keyword = args.Parameters.GetValue <string>("Keyword");
                    queryable = queryable.Where(c => c.title.Contains(keyword) || c.description.Contains(keyword));
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
        public GetListDataResult <Product_Anti_Fake> GetProductQRCodeList(GetListDataArgs args)
        {
            GetListDataResult <Product_Anti_Fake> result = new GetListDataResult <Product_Anti_Fake>();

            using (Entities db = new Entities())
            {
                IQueryable <Product_Anti_Fake> queryable = db.Product_Anti_Fake
                                                           .AsNoTracking();


                if (args.Parameters.IsNullOrEmpty("Keyword") == false)
                {
                    string keyword = args.Parameters.GetValue <string>("Keyword");
                    queryable = queryable.Where(c => c.product_name.Contains(keyword) || c.product_code.Contains(keyword));
                }

                if (args.Parameters.IsNullOrEmpty("status") == false)
                {
                    int status = args.Parameters.GetIntValue("status");
                    queryable = queryable.Where(c => c.status == status);
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #12
0
        // GET: AppApi/Rebate
        public ActionResult QueryPoint()
        {
            AppGetOrderRebateListArgs args = RequestArgs <AppGetOrderRebateListArgs>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }
            args.OrderBy      = " rebate_time DESC";
            args.distributeId = this.UserContext.UserId;
            GetListDataArgs contractArgs = TransferAppGetListJsonArgsToGetListArgs.ToGetListDataArgs(args);

            GetListDataResult <Order_Rebate_New> rebateList = _orderManager.GetOrderRebateList(contractArgs);

            AppGetListDataResult <OrderRebateAppDto> result = new AppGetListDataResult <OrderRebateAppDto>();

            result.pageNo      = rebateList.PagingInfo.CurrentPage;
            result.pageCount   = rebateList.PagingInfo.PageSize;
            result.totalPage   = rebateList.PagingInfo.TotalPage;
            result.totalRecord = rebateList.PagingInfo.TotalCount;

            result.objectList = Mapper.Map <List <Order_Rebate_New>, List <OrderRebateAppDto> >(rebateList.Data);

            return(DataResult(result));
        }
Example #13
0
        public GetListDataResult <User> GetUserList(GetListDataArgs args)
        {
            GetListDataResult <User> result = new GetListDataResult <User>();

            using (Entities db = new Entities())
            {
                IQueryable <User> queryable = db.User
                                              .Include(c => c.Role)
                                              .Where(c => c.available == true)
                                              .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("Keyword") == false)
                {
                    string keyword = args.Parameters.GetValue <string>("Keyword");
                    queryable = queryable.Where(c => c.account.Contains(keyword) || c.name.Contains(keyword) || c.cellphone.Contains(keyword));
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #14
0
        // GET: AppApi/ProductInfo
        public ActionResult QueryPage()
        {
            AppGetProductInfoListArgs args = RequestArgs <AppGetProductInfoListArgs>();

            if (args == null)
            {
                return(FailedResult("参数无效。"));
            }
            args.OrderBy = "serial_no ASC";
            if (args.orderByType == 1)
            {
                args.OrderBy = "cost_price ASC";
            }
            if (args.orderByType == 2)
            {
                args.OrderBy = "cost_price DESC";
            }
            if (args.orderByType == 3)
            {
                args.OrderBy = "sales_num ASC";
            }
            if (args.orderByType == 4)
            {
                args.OrderBy = "sales_num DESC";
            }
            if (args.orderByType == 5)
            {
                args.OrderBy = "create_date_time DESC";
            }

            args.status = 1;

            args.memberType = UserContext.Member.type;
            GetListDataArgs contractArgs = TransferAppGetListJsonArgsToGetListArgs.ToGetListDataArgs(args);

            contractArgs.Parameters.Add("stock", true); //只查有库存的

            GetListDataResult <Product_Info> productList = _productManager.GetProductList(contractArgs);

            AppGetListDataResult <ProductInfoAppDto> result = new AppGetListDataResult <ProductInfoAppDto>();

            result.pageNo      = productList.PagingInfo.CurrentPage;
            result.pageCount   = productList.PagingInfo.PageSize;
            result.totalPage   = productList.PagingInfo.TotalPage;
            result.totalRecord = productList.PagingInfo.TotalCount;

            result.objectList = Mapper.Map <List <Product_Info>, List <ProductInfoAppDto> >(productList.Data);
            TranscationAppNeedProductInfo(result, args);
            return(DataResult(result));
        }
Example #15
0
        public GetListDataResult <Product_Order_Master> GetOrderList(GetListDataArgs args)
        {
            GetListDataResult <Product_Order_Master> result = new GetListDataResult <Product_Order_Master>();

            using (Entities db = new Entities())
            {
                IQueryable <Product_Order_Master> queryable = db.Product_Order_Master
                                                              .Include(c => c.Product_Order_Detail)
                                                              .Include(c => c.Product_Order_Detail.Select(t => t.Member_Coupon_Account))
                                                              .Include(c => c.Product_Order_Record)
                                                              .Include(c => c.Member)
                                                              .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("Keyword") == false)
                {
                    string keyword = args.Parameters.GetValue("Keyword");
                    queryable = queryable.Where(c => c.id.Contains(keyword) || c.Member.name.Contains(keyword) || c.Member.phone_num.Contains(keyword) ||
                                                c.consignee.Contains(keyword) || c.consignee_address.Contains(keyword) || c.consignee_phone.Contains(keyword));
                }

                if (args.Parameters.IsNullOrEmpty("member_id") == false)
                {
                    int memberId = args.Parameters.GetIntValue("member_id");
                    queryable = queryable.Where(c => c.member_id == memberId);
                }

                if (args.Parameters.IsNullOrEmpty("current_status") == false)
                {
                    int currentStatus = args.Parameters.GetIntValue("current_status");
                    if (currentStatus > 0)
                    {
                        queryable = queryable.Where(c => c.current_status == currentStatus);
                    }
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #16
0
        public ActionResult GetOrderList()
        {
            GetListDataArgs args = RequestArgs <GetListDataArgs>();

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

            GetListDataResult <Product_Order_Master> orderList = _orderManager.GetOrderList(args);

            GetListDataResult <Product_Order_MasterInListDto> result = new GetListDataResult <Product_Order_MasterInListDto>();

            result.PagingInfo = orderList.PagingInfo;
            result.Data       = Mapper.Map <List <Product_Order_Master>, List <Product_Order_MasterInListDto> >(orderList.Data);

            return(DataResult(result));
        }
Example #17
0
        public ActionResult GetPointExchangeList()
        {
            GetListDataArgs args = RequestArgs <GetListDataArgs>();

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

            GetListDataResult <Point_Exchange> memberList = _pointManager.GetPointExchangeList(args);

            GetListDataResult <Point_ExchangeDto> result = new GetListDataResult <Point_ExchangeDto>();

            result.PagingInfo = memberList.PagingInfo;
            result.Data       = Mapper.Map <List <Point_Exchange>, List <Point_ExchangeDto> >(memberList.Data);

            return(DataResult(result));
        }
Example #18
0
        public ActionResult GetCouponList()
        {
            GetListDataArgs args = RequestArgs <GetListDataArgs>();

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

            GetListDataResult <Coupon_Info> couponList = _couponManager.GetCouponList(args);

            GetListDataResult <Coupon_InfoDto> result = new GetListDataResult <Coupon_InfoDto>();

            result.PagingInfo = couponList.PagingInfo;
            result.Data       = Mapper.Map <List <Coupon_Info>, List <Coupon_InfoDto> >(couponList.Data);

            return(DataResult(result));
        }
Example #19
0
        public ActionResult GetMicroClassGroupList()
        {
            GetListDataArgs args = RequestArgs <GetListDataArgs>();

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

            GetListDataResult <Micro_Class_Group> microClassGroupList = _microClassManager.GetMicroClassGroupList(args);

            GetListDataResult <Micro_Class_GroupDto> result = new GetListDataResult <Micro_Class_GroupDto>();

            result.PagingInfo = microClassGroupList.PagingInfo;
            result.Data       = Mapper.Map <List <Micro_Class_Group>, List <Micro_Class_GroupDto> >(microClassGroupList.Data);

            return(DataResult(result));
        }
Example #20
0
        public ActionResult GetRoleList()
        {
            GetListDataArgs args = RequestArgs <GetListDataArgs>();

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

            GetListDataResult <Role> roleList = _roleManager.GetRoleList(args);

            GetListDataResult <RoleInListDto> result = new GetListDataResult <RoleInListDto>();

            result.PagingInfo = roleList.PagingInfo;
            result.Data       = Mapper.Map <List <Role>, List <Model.Dto.RoleInListDto> >(roleList.Data);

            return(DataResult(result));
        }
Example #21
0
        public ActionResult GetUserList()
        {
            GetListDataArgs args = RequestArgs <GetListDataArgs>();

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

            GetListDataResult <User> userList = _userManager.GetUserList(args);

            GetListDataResult <UserDto> result = new GetListDataResult <UserDto>();

            result.PagingInfo = userList.PagingInfo;
            result.Data       = Mapper.Map <List <UserDto> >(userList.Data);

            return(DataResult(result));
        }
        public ActionResult GetPushMessageList()
        {
            GetListDataArgs args = RequestArgs <GetListDataArgs>();

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

            GetListDataResult <Push_Message> pushMessageList = _pushMessageManager.GetPushMessageList(args);

            GetListDataResult <Push_MessageInListDto> result = new GetListDataResult <Push_MessageInListDto>();

            result.PagingInfo = pushMessageList.PagingInfo;
            result.Data       = Mapper.Map <List <Push_Message>, List <Push_MessageInListDto> >(pushMessageList.Data);

            return(DataResult(result));
        }
Example #23
0
        public ActionResult GetProductQRCodeList()
        {
            GetListDataArgs args = RequestArgs <GetListDataArgs>();

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

            GetListDataResult <Product_Anti_Fake> productList = _productQRCodeManager.GetProductQRCodeList(args);

            GetListDataResult <Product_Anti_FakeDto> result = new GetListDataResult <Product_Anti_FakeDto>();

            result.PagingInfo = productList.PagingInfo;
            result.Data       = Mapper.Map <List <Product_Anti_Fake>, List <Product_Anti_FakeDto> >(productList.Data);

            return(DataResult(result));
        }
Example #24
0
        public GetListDataResult <Product_Attribute> GetProductAttributeList(GetListDataArgs args)
        {
            GetListDataResult <Product_Attribute> result = new GetListDataResult <Product_Attribute>();

            using (Entities db = new Entities())
            {
                IQueryable <Product_Attribute> queryable = db.Product_Attribute
                                                           //.Include(c => c.Superior_Agent)
                                                           .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("Keyword") == false)
                {
                    string keyword = args.Parameters.GetValue("Keyword");
                    queryable = queryable.Where(c => c.attribute_name.Contains(keyword));
                }

                if (args.Parameters.IsNullOrEmpty("category_id") == false)
                {
                    int categoryId = args.Parameters.GetIntValue("category_id");
                    queryable = queryable.Where(c => c.category_id == categoryId);
                }
                if (args.Parameters.IsNullOrEmpty("ParentId") == false)
                {
                    int parentId = args.Parameters.GetIntValue("ParentId");
                    queryable = queryable.Where(c => c.parent_id == parentId);
                }
                else
                {
                    queryable = queryable.Where(c => c.parent_id.HasValue == false);
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #25
0
        public GetListDataResult <Order_Rebate_New> GetOrderRebateList(GetListDataArgs args)
        {
            GetListDataResult <Order_Rebate_New> result = new GetListDataResult <Order_Rebate_New>();

            using (Entities db = new Entities())
            {
                IQueryable <Order_Rebate_New> queryable = db.Order_Rebate_New
                                                          .Include(e => e.Giver)
                                                          .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("reciver_id") == false)
                {
                    int reciverId = args.Parameters.GetIntValue("reciver_id");
                    queryable = queryable.Where(c => c.reciver_id == reciverId);
                }

                if (args.Parameters.IsNullOrEmpty("status") == false)
                {
                    int status = args.Parameters.GetIntValue("status");
                    queryable = queryable.Where(c => c.status == status);
                }

                if (args.Parameters.IsNullOrEmpty("rebate_type") == false)
                {
                    int rebateType = args.Parameters.GetIntValue("rebate_type");

                    if (rebateType > 0)
                    {
                        queryable = queryable.Where(c => c.rebate_type == rebateType);
                    }
                }
                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #26
0
        public GetListDataResult <User> GetRoleUserList(GetListDataArgs args)
        {
            GetListDataResult <User> result = new GetListDataResult <User>();

            using (Entities db = new Entities())
            {
                int  roleId = args.Parameters.GetIntValue("roleId");
                Role role   = db.Role.FirstOrDefault(r => r.id == roleId);

                IQueryable <User> userQueryable = db.Entry(role).Collection(r => r.User).Query();

                result.PagingInfo = args.PagingInfo;
                int totalCount = userQueryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = userQueryable.Include(u => u.Role).AsNoTracking().OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }
Example #27
0
        public GetListDataResult <Product_Info> GetProductList(GetListDataArgs args)
        {
            GetListDataResult <Product_Info> result = new GetListDataResult <Product_Info>();

            using (Entities db = new Entities())
            {
                IQueryable <Product_Info> queryable = db.Product_Info
                                                      .Include(c => c.Product_Category)
                                                      .Include(c => c.Product_Attribute)
                                                      .AsNoTracking();

                if (args.Parameters.IsNullOrEmpty("status") == false)
                {
                    int status = args.Parameters.GetIntValue("status");
                    queryable = queryable.Where(c => c.status == status);
                }

                if (args.Parameters.IsNullOrEmpty("stock") == false)
                {
                    bool stock = args.Parameters.GetBoolValue("stock");
                    if (stock)
                    {
                        queryable = queryable.Where(c => c.stock > 0);
                    }
                }

                if (args.Parameters.IsNullOrEmpty("Keyword") == false)
                {
                    string keyword = args.Parameters.GetValue <string>("Keyword");
                    queryable = queryable.Where(c => c.product_name.Contains(keyword) || c.product_code.Contains(keyword));
                }

                if (args.Parameters.IsNullOrEmpty("categoryId") == false)
                {
                    int categoryId = args.Parameters.GetIntValue("categoryId");
                    if (categoryId > 0)
                    {
                        queryable = queryable.Where(c => c.Product_Category.Any(ct => ct.id == categoryId));
                    }
                }
                if (args.Parameters.IsNullOrEmpty("groupId") == false)
                {
                    int groupId = args.Parameters.GetIntValue("groupId");
                    if (groupId > 0)
                    {
                        queryable = queryable.Where(c => c.Product_Group.Any(g => g.id == groupId));
                    }
                }
                if (args.Parameters.IsNullOrEmpty("attributeIdList") == false)
                {
                    int[] attributeIds = args.Parameters.GetValue <int[]>("attributeIdList");
                    queryable = queryable.Where(c => c.Product_Attribute.Any(g => attributeIds.Any(a => a == g.id)));
                }
                if (args.Parameters.IsNullOrEmpty("memberType") == false)
                {
                    int     memberType = args.Parameters.GetIntValue("memberType");
                    decimal priceFrom  = args.Parameters.GetValue <decimal>("priceFrom");
                    decimal priceTo    = args.Parameters.GetValue <decimal>("priceTo");
                    if (priceFrom > 0 || priceTo > 0)
                    {
                        //略显诡异的写法
                        if (memberType == 1)
                        {
                            queryable = queryable.Where(c => c.first_distribution_price >= priceFrom && c.first_distribution_price <= priceTo);
                        }
                        if (memberType == 2)
                        {
                            queryable = queryable.Where(c => c.second_distribution_price >= priceFrom && c.second_distribution_price <= priceTo);
                        }
                        if (memberType == 3)
                        {
                            queryable = queryable.Where(c => c.member_price >= priceFrom && c.member_price <= priceTo);
                        }
                    }
                }

                result.PagingInfo = args.PagingInfo;
                int totalCount = queryable.Count();
                result.PagingInfo.UpdateTotalCount(totalCount);

                result.Data = queryable.OrderBy(args.OrderBy)
                              .Skip((result.PagingInfo.CurrentPage - 1) * result.PagingInfo.PageSize)
                              .Take(result.PagingInfo.PageSize).ToList();
            }

            return(result);
        }