public int UpdateVipCards(IEnumerable <vipCard> items) { using (IOPContext db = new IOPContext()) { VipCardConverter converter = new VipCardConverter(db); foreach (var item in items) { var model = converter.FromDto(item); db.Entry(model).State = System.Data.Entity.EntityState.Modified; } return(db.SaveChanges()); } }
public int AddVipCards(IEnumerable <vipCard> items) { using (IOPContext db = new IOPContext()) { List <VipCard> list = new List <VipCard>(); VipCardConverter converter = new VipCardConverter(db); foreach (var item in items) { var model = converter.FromDto(item); list.Add(model); } db.VipCards.AddRange(list); return(db.SaveChanges()); } }