public void Insert(TelbookModel model) { using (MySqlConnection conn = new MySqlConnection(_connStr)) { conn.Execute(InsertStr, model); } }
public void Update(string condition, TelbookModel model) { string sql = GetUpdateSql("Name=@Name,Telephone=@Telephone", condition); using (MySqlConnection conn = new MySqlConnection(_connStr)) { conn.Execute(sql, model); } }
public void Insert(TelbookModel model) { var item = _provider.GetItem(" AND Name=@Name", new { Name = model.Name }); if (item != null) { throw new Exception("已存在相同姓名的人员"); } _provider.Insert(model); }
public void Update(TelbookModel model) { string condition = "AND Id = @Id"; var item = _provider.GetItem(condition, new { Id = model.Id }); if (item == null) { throw new Exception("所要修改的信息不存在,请重试"); } //model.Password = item.Password; _provider.Update(condition, model); }
public IActionResult Add(TelbookModel model) { try { _business.Insert(model); return(Json(new JsonResultLogModel { State = true, Message = "用户添加成功!", Log = $" 用户 {SiteUser.Username} 添加人员 {model.Name} 成功 ", LogType = LogType.TelbookManage, Username = SiteUser.Username })); } catch (Exception ex) { return(Json(new { State = false, Message = ex.Message })); } }
//[AuthorizationFilter(Role = UserType.SysAdmin)] public JsonResult Edit(TelbookModel model) { try { //model.Content.Replace("\r\n", ""); _business.Update(model); return(Json(new JsonResultLogModel { State = true, Message = "用户信息修改成功!", Log = $" 用户 {SiteUser.Username} 编辑人员 {model.Name} 成功 ", LogType = LogType.TelbookManage, Username = SiteUser.Username })); } catch (Exception ex) { return(Json(new { State = false, Message = ex.Message })); } }