public override void Update(Model.Mechanic item) { if (item == null) return; var mapped = MappingManager.Instance.Map<Model.Mechanic, Mechanic>(item); using (var dbContext = new CarServiceEntities()) { var entry = dbContext.Entry(mapped); entry.State = System.Data.EntityState.Modified; dbContext.SaveChanges(); } }
public override void Add(Model.Mechanic item) { if (item == null) return; if (Guid.Equals(item.Id, Guid.Empty)) { item.Id = Guid.NewGuid(); } var mapped = MappingManager.Instance.Map<Model.Mechanic, Mechanic>(item); using (var dbContext = new CarServiceEntities()) { dbContext.Mechanics.Add(mapped); dbContext.SaveChanges(); } }