コード例 #1
0
        public ActionResult AddUserToGroup(string id, string data)
        {
            IDbConnection db = new OrmliteConnection().openConn();

            try
            {
                // Delete All Group of User
                if (string.IsNullOrEmpty(id))
                {
                    return(Json(new { success = false, message = "Chọn người dùng trước khi thêm nhóm." }));
                }
                db.DeleteById <Auth_UserInRole>(id);

                // Add User Group
                if (!string.IsNullOrEmpty(data))
                {
                    string[] arr = data.Split(',');
                    foreach (string item in arr)
                    {
                        var detail = new Auth_UserInRole();
                        detail.UserID       = id;
                        detail.RoleID       = int.Parse(item);
                        detail.RowCreatedAt = DateTime.Now;
                        detail.RowCreatedBy = currentUser.UserID;
                        db.Insert <Auth_UserInRole>(detail);
                    }
                }
                return(Json(new { success = true }));
            }
            catch (Exception e) { return(Json(new { success = false, message = e.Message })); }
            finally { db.Close(); }
        }
コード例 #2
0
ファイル: Property_DAO.cs プロジェクト: war-man/BIBIAM
 public string Delete(string[] ids, string connectionString)
 {
     using (var db = new OrmliteConnection().openConn(connectionString))
     {
         using (var dbTrans = db.OpenTransaction(IsolationLevel.ReadCommitted))
         {
             try
             {
                 foreach (var id in ids)
                 {
                     db.DeleteById <Property>(id);
                 }
                 dbTrans.Commit();
                 return("true");
             }
             catch
             {
                 dbTrans.Rollback();
                 return("false");
             }
         }
     }
 }