public static Car ConvertToDomain(this UpdateCarViewModel updateCarViewModel) { Car car = new Car() { Id = updateCarViewModel.Id , DailyRentalFee = updateCarViewModel.DailyRentalFee , Make = updateCarViewModel.Make , NumberOfDoors = updateCarViewModel.NumberOfDoors }; string[] countries = updateCarViewModel.DelimitedListOfCountries.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); car.CountriesAllowedIn = countries.ToList(); return car; }
private void AttachImageToCar(HttpPostedFileBase file, Car car) { ObjectId imageId = ObjectId.GenerateNewId(); car.ImageId = imageId.ToString(); CarRentalContext.Cars.Save(car); MongoGridFSCreateOptions createOptions = new MongoGridFSCreateOptions() { Id = imageId , ContentType = file.ContentType }; CarRentalContext.CarRentalDatabase.GridFS.Upload(file.InputStream, file.FileName, createOptions); }
private void DeleteCarImage(Car car) { CarRentalContext.CarRentalDatabase.GridFS.DeleteById(car.ImageId); car.ImageId = string.Empty; CarRentalContext.Cars.Save(car); }