Example #1
0
        public IActionResult AddCar(JsonElement request)
        {
            var price       = request.GetProperty("carPrice").GetInt32();
            var countryId   = request.GetProperty("countryId").GetInt32();
            var country     = _countryRepository.GetCountry(countryId);
            var cityId      = request.GetProperty("cityId").GetInt32();
            var city        = _cityRepository.GetCity(cityId);
            var engine      = request.GetProperty("engine").GetInt32();
            var probeg      = request.GetProperty("probeg").GetString();
            var wheelId     = request.GetProperty("wheelId").GetInt32();
            var wheel       = _wheelRepository.GetWheel(wheelId);
            var color       = request.GetProperty("color").GetString();
            var privodId    = request.GetProperty("privodId").GetInt32();
            var privod      = _privodRepository.GetPrivod(privodId);
            var raztamojen  = request.GetProperty("raztamojen").GetBoolean();
            var categoryId  = request.GetProperty("categoryId").GetInt32();
            var category    = _categoryRepository.GetCategory(categoryId);
            var description = request.GetProperty("description").GetString();
            var year        = request.GetProperty("year").GetInt32();
            var car         = new Car()
            {
                Price       = price,
                CountryId   = countryId,
                Country     = country,
                CityId      = city.Id,
                City        = city,
                Engine      = engine,
                Probeg      = probeg,
                WheelId     = wheelId,
                Wheel       = wheel,
                Color       = color,
                PrivodId    = privodId,
                Privod      = privod,
                Raztamojen  = raztamojen,
                CategoryId  = categoryId,
                Category    = category,
                Description = description,
                Year        = year
            };

            _carRepository.Add(car);
            return(Ok("Created successfully"));
        }
Example #2
0
 public Privod GetPrivod(int privodId)
 {
     return(_privodRepository.GetPrivod(privodId));
 }