Exemple #1
0
 public async Task <MethodReturnResult> AddAsync(BaseAttributeValue obj)
 {
     return(await Task.Run <MethodReturnResult>(() =>
     {
         return base.Channel.Add(obj);
     }));
 }
        public async Task <ActionResult> Save()
        {
            MethodReturnResult rst = new MethodReturnResult();

            int    itemNo       = Convert.ToInt32(Request["ItemNo"]);
            string categoryName = Request["CategoryName"];
            IList <BaseAttributeValue> lstVal = new List <BaseAttributeValue>();

            using (BaseAttributeServiceClient client = new BaseAttributeServiceClient())
            {
                MethodReturnResult <IList <BaseAttribute> > result = await Task.Run <MethodReturnResult <IList <BaseAttribute> > >(() =>
                {
                    string where     = string.Format("Key.CategoryName='{0}'", categoryName);
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "Key.CategoryName,Order",
                        Where    = where
                    };
                    return(client.Get(ref cfg));
                });


                if (result.Code == 0)
                {
                    foreach (BaseAttribute attr in result.Data)
                    {
                        string attrValue = Request[attr.Key.AttributeName] ?? string.Empty;

                        BaseAttributeValue val = new BaseAttributeValue()
                        {
                            Key = new BaseAttributeValueKey()
                            {
                                CategoryName  = attr.Key.CategoryName,
                                AttributeName = attr.Key.AttributeName,
                                ItemOrder     = itemNo
                            },
                            Value    = attrValue.Split(',')[0],
                            Editor   = User.Identity.Name,
                            EditTime = DateTime.Now
                        };
                        lstVal.Add(val);
                    }
                }
            }

            using (BaseAttributeValueServiceClient client = new BaseAttributeValueServiceClient())
            {
                rst = await client.AddAsync(lstVal);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(StringResource.BaseAttributeValue_Save_Success);
                }
            }
            return(Json(rst));
        }
Exemple #3
0
        /// <summary>
        /// 修改基础属性。
        /// </summary>
        /// <param name="obj">基础属性数据。</param>
        /// <returns><see cref="MethodReturnResult" />.</returns>
        public MethodReturnResult Modify(BaseAttributeValue obj)
        {
            MethodReturnResult result = new MethodReturnResult();

            if (!this.BaseAttributeValueDataEngine.IsExists(obj.Key))
            {
                result.Code    = 1002;
                result.Message = String.Format(StringResource.BaseAttributeValueService_IsNotExists, obj.Key);
                return(result);
            }
            try
            {
                this.BaseAttributeValueDataEngine.Modify(obj);
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = String.Format(StringResource.BaseAttributeValueService_OtherError, ex.Message);
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// 添加基础属性。
        /// </summary>
        /// <param name="obj">基础属性数据。</param>
        /// <returns><see cref="MethodReturnResult" />.</returns>
        public MethodReturnResult Add(BaseAttributeValue obj)
        {
            MethodReturnResult result = new MethodReturnResult();

            if (this.BaseAttributeValueDataEngine.IsExists(obj.Key))
            {
                result.Code    = 1001;
                result.Message = String.Format(StringResource.BaseAttributeValueService_IsExists, obj.Key);
                return(result);
            }
            try
            {
                this.BaseAttributeValueDataEngine.Insert(obj);
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = String.Format(StringResource.BaseAttributeValueService_OtherError, ex.Message);
                result.Detail  = ex.ToString();
            }
            return(result);
        }
Exemple #5
0
 /// <summary>
 /// 添加基础数据值。
 /// </summary>
 /// <param name="obj">基础数据值数据。</param>
 /// <returns><see cref="MethodReturnResult" />.</returns>
 public MethodReturnResult Add(BaseAttributeValue obj)
 {
     return(base.Channel.Add(obj));
 }
Exemple #6
0
 /// <summary>
 /// 修改基础数据值。
 /// </summary>
 /// <param name="obj">基础数据值数据。</param>
 /// <returns><see cref="MethodReturnResult" />.</returns>
 public MethodReturnResult Modify(BaseAttributeValue obj)
 {
     return(base.Channel.Modify(obj));
 }