Example #1
0
 public ActionResult SavePermission(int RoleID, string Action, string MenuIDs)
 {
     IDbConnection db = new OrmliteConnection().openConn();
     try
     {
         if(RoleID == 0 || string.IsNullOrEmpty(Action))
             return Json(new { success = false, message = "Có dữ liệu rỗng" });
         if (string.IsNullOrEmpty(MenuIDs))
         {
             db.UpdateOnly(new Auth_Action() { IsAllowed = false, RowUpdatedAt = DateTime.Now, RowUpdatedBy = currentUser.UserID },
                 onlyFields: p => new { p.IsAllowed, p.RowUpdatedAt, p.RowUpdatedBy },
                 where: p => p.RoleID == RoleID && p.Action == Action);
         }
         else
         {
             db.ExecuteNonQuery("p_Auth_Action_Save_By_RoleID @RoleID, @UserID, @Action, @MenuIDs", new
             {
                 RoleID = RoleID,
                 UserID = currentUser.UserID,
                 Action = Action,
                 MenuIDs = MenuIDs
             });
         }
         return Json(new { success = true });
     }
     catch (Exception e) { return Json(new { success = false, message = e.Message }); }
     finally { db.Close(); }
 }
Example #2
0
 public ActionResult SaveCustomerHirerachy(string CustomerID, string CustomerHirerachyIDs)
 {
     IDbConnection db = new OrmliteConnection().openConn();
     try
     {
         if (string.IsNullOrEmpty(CustomerHirerachyIDs))
         {
             db.UpdateOnly(new CustomerHirerachyDetail() { Status = false, UpdatedAt = DateTime.Now, UpdatedBy = currentUser.UserID },
                 onlyFields: p => new { p.Status, p.UpdatedAt, p.UpdatedBy },
                 where: p => p.CustomerID == CustomerID);
         }
         else
         {
             db.ExecuteNonQuery("p_CustomerHirerachyDetail_Save_By_CustomerID @CustomerID, @UserID, @CustomerHirerachyIDs", new
             {
                 CustomerID = CustomerID,
                 UserID = currentUser.UserID,
                 CustomerHirerachyIDs = CustomerHirerachyIDs
             });
         }
         return Json(new { success = true });
     }
     catch (Exception e) { return Json(new { success = false, message = e.Message }); }
     finally { db.Close(); }
 }