Inheritance: BaseUserDepartmentModel
Exemplo n.º 1
0
 public JResult AddUserDepartment(BaseUserDepartmentAddModel model)
 {
     return _baseservice.AddUserDepartment(model);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 保存职员对应部门
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int AddUserDepartment(BaseUserDepartmentAddModel model)
 {
     //删除用户对应数据
     const string sql = @"delete from sys_user_city where userid=@userid;";
     //var ids = model.ids.TrimEnd(',').Split(',');
     string sqlAdd = string.Empty;
     foreach (var cityid in model.ids)
     {
         sqlAdd = sqlAdd + "INSERT INTO `sys_user_city` (`innerid`,`cityid`,`userid`) VALUES (uuid()," + cityid + ",'" + model.userid + "');";
     }
     using (var conn = Helper.GetConnection())
     {
         var tran = conn.BeginTransaction();
         try
         {
             conn.Execute(sql, new { userid = model.userid }, tran);
             conn.Execute(sqlAdd, tran);
             tran.Commit();
             return 1;
         }
         catch (Exception ex)
         {
             tran.Rollback();
             return 0;
         }
     }
 }