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 } }
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"); } }
public void Create(Tag tag) { context.Tags.Add(tag); context.SaveChanges(); }
public void Update(Tag tag) { repository.Update(tag); }
public void Create(Tag tag) { repository.Create(tag); }