コード例 #1
0
        public bool CreateOrUpdate(ITPurchaseViewModel viewModel, WFInstanceViewModel wFInstanceView, Guid userId, string userName)
        {
            if (viewModel.Id == new Guid())
            {
                viewModel = mapper.Map(exampleContext.ITPurchase.Add(mapper.Map <ITPurchase>(viewModel)).Entity, viewModel);
            }
            else
            {
                viewModel = mapper.Map(exampleContext.ITPurchase.Update(mapper.Map <ITPurchase>(viewModel)).Entity, viewModel);
            }

            if (viewModel.AssetItem != null)
            {
                for (int i = 0; i < viewModel.AssetItem.Count; i++)
                {
                    viewModel.AssetItem[i].BillId = viewModel.Id;
                    if (viewModel.AssetItem[i].Id == new Guid())
                    {
                        viewModel.AssetItem[i] = mapper.Map(exampleContext.AssetPuchase.Add(mapper.Map <AssetPuchase>(viewModel.AssetItem[i])).Entity, viewModel.AssetItem[i]);
                    }
                    else
                    {
                        viewModel.AssetItem[i] = mapper.Map(exampleContext.AssetPuchase.Update(mapper.Map <AssetPuchase>(viewModel.AssetItem[i])).Entity, viewModel.AssetItem[i]);
                    }
                }
            }
            exampleContext.SaveChanges();
            wFContext.SaveChanges();

            wFInstanceView.Desc  = $"{viewModel.ApplicantName}发起采购申请,总金额{viewModel.EstimatedAmount}";
            wFInstanceView.BId   = viewModel.Id;
            wFInstanceView.BType = typeof(ITPurchase).Name;

            var wf = iWFInstanceServer.CreateWFInstance(wFInstanceView, userId, userName);

            if (wf == null)
            {
                //没有创建成功
                return(false);
            }

            return(true);
        }
コード例 #2
0
 public WFInstanceViewModel CreateWFInstance([FromBody] WFInstanceViewModel viewModel, Guid userId, String userName)
 {
     //解析token,获取用户id,用户名称
     return(iWFInstanceServer.CreateWFInstance(viewModel, userId, userName));
 }