Exemple #1
0
        public int Create(Tag tagToCreate)
        {
            if (tagToCreate == null)
            {
                throw new Exception("The Tag sent in for creation is null.");
            }

            base.UpdateDateAdded(tagToCreate);
            base.UpdateIsDeletedToFalse(tagToCreate);

            db.Tags.Add(tagToCreate);
            db.SaveChanges();
            int idOfTag = tagToCreate.ID;

            return idOfTag;
        }
Exemple #2
0
 public void Delete(Tag tagToDelete)
 {
     Delete(tagToDelete.ID);
 }
Exemple #3
0
 public Tag Get(Tag tagToGet)
 {
     return Get(tagToGet.Name);
 }
Exemple #4
0
        public int Update(Tag updatedTag)
        {
            Tag tagToUpdate = db.Tags.SingleOrDefault(c => c.ID == updatedTag.ID && c.IsDeleted == false);

            if (tagToUpdate == null)
            {
                throw new Exception("No Tag exists with the id " + updatedTag.ID);
            }

            base.UpdateDateUpdated(updatedTag);

            db.Tags.AddOrUpdate(c => c.ID, updatedTag);
            db.SaveChanges();
            int idOfTag = updatedTag.ID;

            return idOfTag;
        }
Exemple #5
0
 public void Destroy(Tag tagToDestroy)
 {
     Destroy(tagToDestroy.ID);
 }