public void DeleteAuction(Auction auction) { DealDoubleContext context = new DealDoubleContext(); context.Entry(auction).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); }
public void DeleteCategory(Category category) { DealDoubleContext context = new DealDoubleContext(); context.Entry(category).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); }
public void DeleteAuction(Auction auctionModel) { var context = new DealDoubleContext(); context.Entry(auctionModel).State = EntityState.Deleted; context.SaveChanges(); }
//update existing category public void UpdateCategory(Category category) { var context = new DealDoubleContext(); context.Entry(category).State = EntityState.Modified; context.SaveChanges(); }
//delete a comment by entityId, and recordId public bool DeleteEntityComment(int entityId, int recordId) { var context = new DealDoubleContext(); var auctionComment = context.Comments.Where(c => c.EntityId == entityId && c.RecordId == recordId).First(); context.Entry(auctionComment).State = EntityState.Deleted; return(context.SaveChanges() > 0); }
public void UpdateAuction(Auction auction) { DealDoubleContext context = new DealDoubleContext(); var exitingAuction = context.Auctions.Find(auction.ID); context.AuctionPictures.RemoveRange(exitingAuction.AuctionPictures); context.Entry(exitingAuction).CurrentValues.SetValues(auction); context.AuctionPictures.AddRange(auction.AuctionPictures); context.SaveChanges(); }
//delete comments by entityId, and recordId public void DeleteEntityComments(int entityId, int recordId) { var context = new DealDoubleContext(); var auctionComments = context.Comments.Where(c => c.EntityId == entityId && c.RecordId == recordId); foreach (var auctionComment in auctionComments) { context.Entry(auctionComment).State = EntityState.Deleted; } context.SaveChanges(); }
public void UpdateAuction(Auction auction) { DealDoubleContext context = new DealDoubleContext(); var existingAuction = context.Auctions.Find(auction.ID); //first Take Auction from DB. context.AuctionPictures.RemoveRange(existingAuction.AuctionPictures); //second Remove all AuctionPictures table 1 to * relational data of The auction. context.Entry(existingAuction).CurrentValues.SetValues(auction); //Set new data on first selected auction data. context.AuctionPictures.AddRange(auction.AuctionPictures); //Add all new 1 to * relational data of upadted Auction on AuctionPictures table. //context.Entry(auction).State=System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public void UpdateAuction(Auction auction) { var context = new DealDoubleContext(); var existingAuction = context.Auctions.Where(a => a.Id == auction.Id).Include(a => a.AuctionPictures).First(); context.AuctionPictures.RemoveRange(existingAuction.AuctionPictures); //delete existing pics context.Entry(existingAuction).CurrentValues.SetValues(auction); //update all old values to newest except : navigation objects like pics context.AuctionPictures.AddRange(auction.AuctionPictures); //add new pics context.SaveChanges(); }
public async Task UpdateAsync(T entity) { Context.Entry(entity).State = EntityState.Modified; await SaveAsync(); }