Exemplo n.º 1
0
        public string GetListByOptionType(NameValueCollection rParams, int OptionType)
        {
            OptionsDefinedEntity entity = rParams["form"].DeserializeJSONTo <OptionsDefinedEntity>();

            if (entity == null)
            {
                entity = new OptionsDefinedEntity();
            }
            int pageSize  = rParams["limit"].ToInt();
            int pageIndex = rParams["page"].ToInt();

            IWhereCondition[] pWhereConditions = new IWhereCondition[3];
            if (entity != null)
            {
                if (entity.Title != null && entity.Title != "")
                {
                    LikeCondition like = new LikeCondition();
                    like.FieldName           = "Title";
                    like.HasLeftFuzzMatching = true;
                    like.HasRightFuzzMathing = true;
                    like.Value          = entity.Title;
                    pWhereConditions[0] = like;
                }
            }
            EqualsCondition equalCondition = new EqualsCondition();

            equalCondition.FieldName = "OptionType";
            equalCondition.Value     = OptionType;
            pWhereConditions[1]      = equalCondition;
            EqualsCondition equalCondition2 = new EqualsCondition();

            equalCondition2.FieldName = "ClientID";
            equalCondition2.Value     = CurrentUserInfo.ClientID;
            pWhereConditions[2]       = equalCondition2;
            OrderBy[] pOrderBys = new OrderBy[1];
            OrderBy   order     = new OrderBy();

            order.Direction = OrderByDirections.Asc;
            order.FieldName = "CreateTime";
            pOrderBys[0]    = order;
            PagedQueryResult <OptionsDefinedEntity> entitys = new OptionsDefinedBLL(CurrentUserInfo).PagedQuery(pWhereConditions, pOrderBys, pageSize, pageIndex);

            return(string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                 entitys.Entities.ToJSON(),
                                 entitys.RowCount));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="rParams"></param>
        /// <param name="type">1新增 2修改</param>
        /// <returns></returns>
        private string Edit(NameValueCollection rParams)
        {
            string res = "{success:false,msg:'保存失败'}";
            OptionsDefinedEntity optionsDefinedEntity = new OptionsDefinedEntity();

            if (!string.IsNullOrEmpty(rParams["definedID"]))
            {
                optionsDefinedEntity = new OptionsDefinedBLL(CurrentUserInfo).GetByID(rParams["definedID"].ToString());
            }
            optionsDefinedEntity = DataLoader.LoadFrom <OptionsDefinedEntity>(rParams, optionsDefinedEntity);
            OptionsEntity[] optionEntity = rParams["options"].DeserializeJSONTo <OptionsEntity[]>();
            int             result       = new OptionsBLL(CurrentUserInfo).OptionsDefinedEdit(optionsDefinedEntity, optionEntity);

            if (result == 1)
            {
                res = "{success:true,msg:'保存成功'}";
            }
            else if (result == 2)
            {
                res = "{success:false,msg:'名称已经存在,请换一个名称'}";
            }
            return(res);
        }