public void RemoveLayout() { try { var options = CreateNewContextOptions(); using (var db = new AuctionContext(options)) { AuctionTestHelper.PopulateDefaultData(db); } using (var db = new AuctionContext(options)) { var repository = new AuctionRepository(db); var item = GenerateModel(); Assert.DoesNotThrow(() => repository.Save(item)); var layout = new AuctionLayout { Title = "title", Description = "description", Layout = GenerateAttachment(), AuctionId = item.Id }; Assert.DoesNotThrow(() => repository.AddLayout(item, layout)); Assert.DoesNotThrow(() => repository.RemoveLayout(item, layout)); } } catch (Exception ex) { LogEventManager.Logger.Error(ex); throw; } }
public void RemoveLayout(Server.Model.Auction.Auction auction, AuctionLayout layout) { try { var auctionLayout = Db.Set <AuctionLayout>().Single(it => it.LayoutId == layout.LayoutId && it.AuctionId == auction.Id); Db.Set <AuctionLayout>().Remove(auctionLayout); Db.SaveChanges(); } catch (Exception ex) { LogEventManager.Logger.Error(ex.Message, ex); throw; } }
public void AddLayout(Server.Model.Auction.Auction auction, AuctionLayout layout) { try { layout.AuctionId = auction.Id; Db.Set <AuctionLayout>().Add(layout); Db.SaveChanges(); } catch (Exception ex) { LogEventManager.Logger.Error(ex.Message, ex); throw; } }