public static Car ConstructCar(Db.Car dbCar) { return(new Common.Car { Guid = dbCar.Guid, Color = dbCar.Color, Model = dbCar.Model, Mileage = dbCar.Mileage.Value, Photo = dbCar.Photo, Price = dbCar.Price.Value, Status = (CarStatus)dbCar.Status, YearProduction = dbCar.YearProduction.Value, City = dbCar.City, Mark = dbCar.Mark, Type = dbCar.Type }); }
public static void AddCar(Car car) { using (var context = new Db.OpenRentEntities()) { var dbCar = new Db.Car { Guid = car.Guid, City = car.City, Color = car.Color, Mark = car.Mark, Mileage = car.Mileage, Model = car.Model, Photo = car.Photo, Price = car.Price, Status = (int)CarStatus.Free, Type = car.Type, YearProduction = car.YearProduction }; context.Car.Add(dbCar); context.SaveChanges(); } }