public async Task <ActionResult> ProdServerEdit(int id) { var prodDeply = await prodRepo.GetProdServerDeployAsync(id); //甲方公司 var PartyList = new List <SelectListItem>(); var party = await partyRepo.GetPartyListAsync(); var party2 = new SelectList(party, "PartyID", "name"); PartyList.AddRange(party2); ViewBag.PartyList = PartyList; //产品 var ProdList = new List <SelectListItem>(); var prods = await prodRepo.GetListAsync(); var prods2 = new SelectList(prods, "ProID", "NAME"); ProdList.AddRange(prods2); ViewBag.ProdList = ProdList; //通讯协议 var ProtTypeList = new List <SelectListItem>(); var prots = await codeRepo.GetCodesListAsync(ECodesTypeId.ProtType); var prots2 = new SelectList(prots, "Code", "Text"); ProtTypeList.AddRange(prots2); ViewBag.ProtTypeList = ProtTypeList; if (prodDeply == null) { prodDeply = new ProdServerDeploy(); } return(View(prodDeply)); }
public async Task <bool> AddOrUpdateProdServerDeployAsync(ProdServerDeploy pDeployPara) { var isAdd = false; var model = await context.ProdServerDeploys.Where(p => p.id == pDeployPara.id).FirstOrDefaultAsync(); if (model == null) { isAdd = true; model = new ProdServerDeploy(); } model.partyID = pDeployPara.partyID; model.itemid = pDeployPara.itemid; model.prodid = pDeployPara.prodid; model.serverid = pDeployPara.serverid; model.port = pDeployPara.port; model.porttype = pDeployPara.porttype; model.remark = pDeployPara.remark; if (isAdd) { context.ProdServerDeploys.Add(model); } return(await context.SaveChangesAsync() == 1); }
public async Task <JsonResult> SaveProdDeploy(ProdServerDeploy model) { var result = await prodRepo.AddOrUpdateProdServerDeployAsync(model); return(Json(new { isOk = result })); }