//public ActionResult SaveEditDbTag(DbTagInput tag) //{ // try // { // _dbTagAppService.InsertOrUpdateDbTag(tag); // return Json("保存成功"); // } // catch (Exception e) // { // throw new Exception(e.Message); // } //} #endregion #region 数据库管理 public ActionResult InserDbServer() { var model = new DbServerInput(); ViewBag.DbType = _dbTypeAppService.GetDropDownList(); return(View("Easyman.FwWeb.Views.DbServer.EditDbServer", model)); }
/// <summary> /// 更新和新增数据库 /// </summary> /// <param name="input"></param> /// <returns></returns> public void InsertOrUpdateDbServer(DbServerInput input) { if (_dbServerRepository.GetAll().Any(p => p.Id != input.Id && p.ByName == input.ByName)) { throw new System.Exception("数据库别名重复"); } //var dbServer = AutoMapper.Mapper.Map<DbServerInput, DbServer>(input); var dbServer = _dbServerRepository.GetAll().FirstOrDefault(x => x.Id == input.Id) ?? new DbServer(); dbServer = Fun.ClassToCopy(input, dbServer, (new string[] { "Id" }).ToList()); var server = _dbServerRepository.InsertOrUpdate(dbServer); if (server == null) { throw new UserFriendlyException("新增或者更新失败!"); } }