SHARE
TWEET

Untitled

a guest Mar 26th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public static bool deleteSharedFieldsOfFarm(int farmId)
  2.         {
  3.             try
  4.             {
  5.  
  6.                 using (PDContext db2 = new PDContext())
  7.                 {
  8.                     var fieldIds = db2.fields.Where(x => x.farm_id == farmId).Select(x => x.id).ToList();
  9.  
  10.                     foreach (var fieldId in fieldIds)
  11.                     {
  12.                         db2.share_permissions
  13.                           .Where(x => x.shared_object_type_id == 3 && x.shared_object_id == fieldId)
  14.                           .ToList().ForEach(f => f.deleted = true);
  15.                     }
  16.                        
  17.                     db2.share_permissions
  18.                           .Where(x => x.shared_object_type_id == 2 && x.shared_object_id == farmId)
  19.                           .ToList().ForEach(f => f.deleted = true);
  20.  
  21.                     db2.SaveChanges();
  22.                 }
  23.  
  24.                 return true;
  25.             }
  26.             catch (Exception ex)
  27.             {
  28.                 EmailHelper.SendErrorMail(ex);
  29.                 return false;
  30.             }
  31.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top