public ActionResult Edit_BaseInfo() { if (Session["CurrentAccountID"] == null) { return(RedirectToAction("Select", "OfficialAccount", new { Area = "Admin" })); } Guid id = Guid.Parse(Session["CurrentAccountID"].ToString()); OfficialAccount off = new OfficialAccount_BLL().Get(a => a.AccountID == id); AutoMapper.Mapper.CreateMap <OfficialAccount, OfficialAccount_BaseInfo_ViewModel>(); OfficialAccount_BaseInfo_ViewModel model = AutoMapper.Mapper.Map <OfficialAccount_BaseInfo_ViewModel>(off); return(View(model)); }
public ActionResult Edit_BaseInfo(OfficialAccount_BaseInfo_ViewModel model) { OfficialAccount_BLL bll = new OfficialAccount_BLL(); OfficialAccount newmodel = bll.Get(a => a.AccountID == model.AccountID); newmodel.WeiXinName = model.WeiXinName; newmodel.OriginalID = model.OriginalID; newmodel.WeiXinNumber = model.WeiXinNumber; newmodel.WeiXinName = model.AppID; newmodel.WeiXinName = model.AppSecret; if (bll.Update(newmodel) > 0) { return(RedirectToAction("Edit_BaseInfo")); } else { ModelState.AddModelError("", "修改失败,请稍后再试!"); return(View(model)); } }
public ActionResult Add(OfficialAccount_BaseInfo_ViewModel model) { AutoMapper.Mapper.CreateMap <OfficialAccount_BaseInfo_ViewModel, OfficialAccount>(); OfficialAccount newmodel = AutoMapper.Mapper.Map <OfficialAccount>(model); newmodel.AccountID = Guid.NewGuid(); newmodel.CreateTime = DateTime.Now; Users user = new Users_BLL().GetCurrentUser(); newmodel.UserID = user.UserID; newmodel.IsConfigure = false; OfficialAccount_BLL bll = new OfficialAccount_BLL(); if (bll.Add(newmodel) > 0) { return(RedirectToAction("Select")); } else { ModelState.AddModelError("", "添加失败,请稍后再试!"); return(View(model)); } }