/// <summary> /// Create a new UserMapping object. /// </summary> /// <param name="userID">Initial value of the UserID property.</param> public static UserMapping CreateUserMapping(global::System.String userID) { UserMapping userMapping = new UserMapping(); userMapping.UserID = userID; return(userMapping); }
internal static bool AddUpdate(string userId, string keyId, string vCode, KeyType keyType) { if (string.IsNullOrWhiteSpace(userId)) { throw new ArgumentException("user_id cannot be empty"); } if (string.IsNullOrWhiteSpace(keyId)) { throw new ArgumentException("KeyID cannot be empty"); } if (string.IsNullOrWhiteSpace(vCode)) { throw new ArgumentException("vCode cannot be empty"); } using (SlackEvePingEntities ef = new SlackEvePingEntities()){ UserMapping user = ef.UserMappings.FirstOrDefault(x => x.UserID == userId.Trim()); if (user == null) { user = new UserMapping { UserID = userId.Trim() }; ef.UserMappings.AddObject(user); } user.KeyID = keyId.Trim(); user.vCode = vCode.Trim(); user.KeyType = keyType.ToString(); ef.SaveChanges(); } return(true); }
internal static bool Remove(string userId) { if (string.IsNullOrWhiteSpace(userId)) { throw new ArgumentException("user_id cannot be empty"); } bool success = false; using (SlackEvePingEntities ef = new SlackEvePingEntities()){ UserMapping user = ef.UserMappings.FirstOrDefault(x => x.UserID == userId.Trim()); if (user != null) { ef.UserMappings.DeleteObject(user); ef.SaveChanges(); success = true; } } return(success); }
/// <summary> /// Deprecated Method for adding a new object to the UserMappings EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUserMappings(UserMapping userMapping) { base.AddObject("UserMappings", userMapping); }