Пример #1
0
        public void Update(Tag tag)
        {
            Tag entity = context.Tags.FirstOrDefault(w => w.Id == tag.Id);

            if (entity != null)
            {
                context.Entry(entity).CurrentValues.SetValues(tag);
                context.SaveChanges();
            }
            else
            {
                // ToDo: Throw exception
            }
        }
Пример #2
0
        public void Create()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                TagRepository target = new TagRepository(new EFContext());

                Tag model = new Tag()
                {
                    Name = "PopTag"
                };

                target.Create(model);

                Tag addedTag = target.GetAll().FirstOrDefault(w => w.Name == "PopTag");

                addedTag.Name.Should().Be("PopTag");
            }
        }
Пример #3
0
 public void Create(Tag tag)
 {
     context.Tags.Add(tag);
     context.SaveChanges();
 }
Пример #4
0
 public void Update(Tag tag)
 {
     repository.Update(tag);
 }
Пример #5
0
 public void Create(Tag tag)
 {
     repository.Create(tag);
 }