Exemplo n.º 1
0
        // Changes the ID of the tag with ID tagPrimeIdFrom to tagPrimeIdFrom.
        // (It actually does this by creating copies and deleting the old ones).
        // The previously existing tag with tagPrimeIdTo will be deleted.
        // If the from and to are the same, that tag is just deleted.
        public static void SwitchTagId(
            this PersonDataContext dataContext,
            int tagPrimeIdFrom,
            int tagPrimeIdTo)
        {
            // Make a copy of the tag with ID tagPrimeIdFrom but with
            // ID tagPrimeIdTo.
            var tagToCopy = dataContext.GetTagPrime(tagPrimeIdFrom);
            var copyOfTag = new TagPrime();

            copyOfTag.Tag  = tagToCopy.Tag;
            copyOfTag.Type = tagToCopy.Type;
            copyOfTag.AllowNonAdminsToAdd = tagToCopy.AllowNonAdminsToAdd;
            copyOfTag.PrimeId             = tagPrimeIdTo;

            var tagToDelete = dataContext.GetTagPrime(tagPrimeIdTo);

            dataContext.TagPrimes.DeleteOnSubmit(tagToDelete);
            dataContext.TagPrimes.DeleteOnSubmit(tagToCopy);
            dataContext.SubmitChanges();

            if (tagPrimeIdFrom == tagPrimeIdTo)
            {
                return;
            }
            dataContext.TagPrimes.InsertOnSubmit(copyOfTag);
            dataContext.SubmitChanges();
        }
Exemplo n.º 2
0
        public static void makeTagToRemoveUnsearchable(
            this PersonDataContext dataContext,
            int tagToRemoveId)
        {
            var tagToRemove       = dataContext.GetTagPrime(tagToRemoveId);
            var copyOfTagToRemove = new TagPrime();

            copyOfTagToRemove.PrimeId = tagToRemove.PrimeId;
            copyOfTagToRemove.Tag     = TagToPrimeDictionary.INVALID_TAG_NAME;

            dataContext.TagPrimes.DeleteOnSubmit(tagToRemove);
            dataContext.SubmitChanges();
            dataContext.TagPrimes.InsertOnSubmit(copyOfTagToRemove);
            dataContext.SubmitChanges();
        }