Esempio n. 1
0
        public static void SaveTags(Tag tags, int taskId)
        {
            using (var db = new SqlConnection(ConnectionString))
            {
                db.Open();
                var q = @"INSERT INTO [Collect2000].[ERCTasks].[Tags]
                        (tag)
                        VALUES (@TagDescription);SELECT SCOPE_IDENTITY();";
             var tagID=   db.Query<int>(q, new
                {
                    TagDescription = tags.tag

                });
                var q1 = @"INSERT INTO [Collect2000].[ERCTasks].[TaskTags]
                        (TagId,TaskId)
                        VALUES (@TagID,@TaskID);";
                db.Query<int>(q1, new
                {
                    TagID = tagID,
                    TaskID = taskId

                });

            }
        }
Esempio n. 2
0
        public void AddAssertion(string userName, int categoryId, string tagName) 
        {
            Check.Require(!userName.IsNullOrEmpty(), "userName must be provided.");
            Check.Require(categoryId > 0, "categoryId must be greater than 0.");
            Check.Require(!tagName.IsNullOrEmpty(), "tagName must be provided.");

            // TODO: Ideally we want a transaction here as we are potentially doing two updates.
            var profile = this.GetProfileByUserName(userName);

            var tag = this.tagRepository.FindOne(new TagByNameSpecification(tagName));

            if (tag == null)
            {
                tag = new Tag 
                    {
                        Name = tagName
                    };

                this.tagRepository.Save(tag);
            }

            // See if there's already an assertion for this tag/category combination
            var existingAssertion = profile.Assertions.FirstOrDefault(
                a => (a.Tag == tag) && (a.Category.Id == categoryId));

            // If not add it. If there is, do nothing further - there's no point returning an error, since the user has what they wanted
            if (existingAssertion == null)
            {
                var category = this.GetCategory(categoryId);

                var newAssertion = new Assertion
                    {
                        Profile = profile,
                        Category = category,
                        Tag = tag
                    };

                profile.Assertions.Add(newAssertion);

                this.profileRepository.Save(profile);
            }
        }
Esempio n. 3
0
        public void AddAssertion(AddAssertionDetails addAssertionDetails)
        {
            addAssertionDetails.Validate();

            // TODO: Ideally we want a transaction here as we are potentially doing two updates.

            var profile = this.GetProfileByUserName(addAssertionDetails.UserName);

            var tag = this.tagRepository.FindOne(new TagByNameSpecification(addAssertionDetails.TagName));

            if (tag == null)
            {
                tag = new Tag
                    {
                        Name = addAssertionDetails.TagName
                    };

                this.tagRepository.Save(tag);
            }

            // See if there's already an assertion for this tag/category combination
            var existingAssertion = profile.Assertions.FirstOrDefault(
                a => (a.Tag == tag) && (a.Category.Id == addAssertionDetails.CategoryId));

            // If not add it. If there is, do nothing further - there's no point returning an error, since the user has what they wanted
            if (existingAssertion == null)
            {
                var category = this.GetCategory(addAssertionDetails.CategoryId);

                var newAssertion = new Assertion
                    {
                        Profile = profile,
                        Category = category,
                        Tag = tag
                    };

                profile.Assertions.Add(newAssertion);

                this.profileRepository.Save(profile);
            }
        }
Esempio n. 4
0
 public bool SaveTags(Tag _obj, int id)
 {
     try
      {
          TagManager.SaveTags(_obj, id);
          return true;
      }
      catch (Exception ex) { return false; }
 }
 internal void RemoveTag(Tag tag)
 {
     RemoveObject(Relation.VerbType.TaggedAs, tag);
 }
 //        public Organization AuthorOrganization { get { return Author as Organization; } }
 internal void AddTag(Tag tag)
 {
     AddObject(Relation.VerbType.TaggedAs, tag);
 }