public async Task <CarImageModel> SaveCarImage(ImageUploadResult uploadResult, string fileNameLong, int CarId) { var fileName = Path.GetFileNameWithoutExtension(fileNameLong); var image = new CarImageModel { Id = uploadResult.PublicId, Url = uploadResult.SecureUrl.AbsoluteUri, Name = fileName, Description = fileName, CarId = CarId }; await _context.CarImages.AddAsync(image); await _context.SaveChangesAsync(); return(image); }
public async Task <bool> Create(CarModel car) { await _context.Cars.AddAsync(car); return(await _context.SaveChangesAsync() > 0); }