Esempio n. 1
0
        public async Task <ActionResult> SaveModify(DecayViewModel model)
        {
            using (DecayServiceClient client = new DecayServiceClient())
            {
                DecayKey key = new DecayKey()
                {
                    Code   = model.Code,
                    Object = model.Object
                };
                MethodReturnResult <Decay> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    result.Data.Value       = model.Value ?? 0;
                    result.Data.Type        = model.Type;
                    result.Data.Description = model.Description;
                    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.Decay_SaveModify_Success
                                                    , model.Code);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Esempio n. 2
0
        //
        // GET: /ZPVM/Decay/Modify
        public async Task <ActionResult> Modify(string code, EnumPVMTestDataType obj)
        {
            DecayViewModel viewModel = new DecayViewModel();

            using (DecayServiceClient client = new DecayServiceClient())
            {
                MethodReturnResult <Decay> result = await client.GetAsync(new DecayKey()
                {
                    Code   = code,
                    Object = obj
                });

                if (result.Code == 0)
                {
                    viewModel = new DecayViewModel()
                    {
                        Code        = result.Data.Key.Code,
                        Object      = result.Data.Key.Object,
                        Description = result.Data.Description,
                        Value       = result.Data.Value,
                        Type        = result.Data.Type,
                        IsUsed      = result.Data.IsUsed,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    return(PartialView("_ModifyPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_ModifyPartial"));
        }