Пример #1
0
        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);
        }
Пример #2
0
        public async Task <bool> Create(CarModel car)
        {
            await _context.Cars.AddAsync(car);

            return(await _context.SaveChangesAsync() > 0);
        }