Пример #1
0
        public async Task <ActionResult> SaveModify(EfficiencyViewModel model)
        {
            using (EfficiencyServiceClient client = new EfficiencyServiceClient())
            {
                EfficiencyKey key = new EfficiencyKey()
                {
                    Code  = model.Code,
                    Group = model.Group
                };
                MethodReturnResult <Efficiency> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    result.Data.Lower       = model.Lower;
                    result.Data.Upper       = model.Upper;
                    result.Data.Name        = model.Name;
                    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.Efficiency_SaveModify_Success
                                                    , model.Code);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Пример #2
0
        //
        // GET: /ZPVM/Efficiency/Modify
        public async Task <ActionResult> Modify(string group, string code)
        {
            EfficiencyViewModel viewModel = new EfficiencyViewModel();

            using (EfficiencyServiceClient client = new EfficiencyServiceClient())
            {
                MethodReturnResult <Efficiency> result = await client.GetAsync(new EfficiencyKey()
                {
                    Code  = code,
                    Group = group
                });

                if (result.Code == 0)
                {
                    viewModel = new EfficiencyViewModel()
                    {
                        Code        = result.Data.Key.Code,
                        Group       = result.Data.Key.Group,
                        Description = result.Data.Description,
                        Name        = result.Data.Name,
                        Lower       = result.Data.Lower,
                        Upper       = result.Data.Upper,
                        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"));
        }