public override void Add(Core.Model.RepairCard item) { if (item == null) return; if (Guid.Equals(item.Id, Guid.Empty)) { item.Id = Guid.NewGuid(); } if (Guid.Equals(item.Car.Id, Guid.Empty)) { item.Car.Id = Guid.NewGuid(); } item.FinishedDate = new DateTime(1800, 1, 1); item.Car.ProductionYear = new DateTime(1800, 1, 1); using (var dbContext = new CarServiceEntities()) { var entity = MappingManager.Instance.Map<Core.Model.RepairCard, RepairCard>(item); dbContext.RepairCards.Add(entity); dbContext.SaveChanges(); } }
public override void Delete(Guid id) { using (var dbContext = new CarServiceEntities()) { var mechanic = dbContext.Mechanics.FirstOrDefault(m => m.Id == id); dbContext.Mechanics.Remove(mechanic); dbContext.SaveChanges(); } }
public override void AddCar(Core.Model.Car item) { using (var dbContext = new CarServiceEntities()) { var entity = MappingManager.Instance.Map<Core.Model.Car, Car>(item); dbContext.Cars.Add(entity); 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(); } }
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 UpdateCar(Core.Model.Car item) { using (var dbContext = new CarServiceEntities()) { var entity = MappingManager.Instance.Map<Core.Model.Car, Car>(item); var entry = dbContext.Entry<Car>(entity); entry.State = System.Data.EntityState.Modified; dbContext.SaveChanges(); } }