コード例 #1
0
        //
        // GET: /ZPVM/RuleControlObject/Detail
        public async Task <ActionResult> Detail(string code, EnumPVMTestDataType obj, string type)
        {
            using (RuleControlObjectServiceClient client = new RuleControlObjectServiceClient())
            {
                RuleControlObjectKey key = new RuleControlObjectKey()
                {
                    Code   = code,
                    Object = obj,
                    Type   = type
                };
                MethodReturnResult <RuleControlObject> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    RuleControlObjectViewModel viewModel = new RuleControlObjectViewModel()
                    {
                        Code       = result.Data.Key.Code,
                        Value      = result.Data.Value,
                        Type       = result.Data.Key.Type,
                        Object     = result.Data.Key.Object,
                        IsUsed     = result.Data.IsUsed,
                        CreateTime = result.Data.CreateTime,
                        Creator    = result.Data.Creator,
                        Editor     = result.Data.Editor,
                        EditTime   = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
コード例 #2
0
        public async Task <ActionResult> SaveModify(RuleControlObjectViewModel model)
        {
            using (RuleControlObjectServiceClient client = new RuleControlObjectServiceClient())
            {
                RuleControlObjectKey key = new RuleControlObjectKey()
                {
                    Code   = model.Code,
                    Type   = model.Type,
                    Object = model.Object
                };
                MethodReturnResult <RuleControlObject> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    result.Data.Value    = model.Value;
                    result.Data.IsUsed   = model.IsUsed;
                    result.Data.Editor   = User.Identity.Name;
                    result.Data.EditTime = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(ZPVMResources.StringResource.RuleControlObject_SaveModify_Success
                                                    , model.Code);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }