public VehicleHistoryItem GetById(int id) { Mapper.CreateMap <Vehicle_History, VehicleHistoryItem>(); Vehicle_History objVhtbl = DbContext.Vehicle_History.SingleOrDefault(m => m.ID == id); VehicleHistoryItem objVHItem = Mapper.Map <VehicleHistoryItem>(objVhtbl); return(objVHItem); }
public int Update(VehicleHistoryItem model) { Mapper.CreateMap <VehicleHistoryItem, Vehicle_History>(); Vehicle_History objVH = DbContext.Vehicle_History.SingleOrDefault(m => m.ID == model.ID); objVH = Mapper.Map(model, objVH); return(DbContext.SaveChanges()); }
public int Insert(VehicleHistoryItem model) { try { Mapper.CreateMap <VehicleHistoryItem, Vehicle_History>(); Vehicle_History objVehicle = Mapper.Map <Vehicle_History>(model); DbContext.Vehicle_History.Add(objVehicle); return(DbContext.SaveChanges()); } catch (Exception ex) { throw; } }