コード例 #1
0
        public async Task <IActionResult> PutAutoBrand([FromRoute] int id, [FromBody] AutoBrand autoBrand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != autoBrand.Id)
            {
                return(BadRequest());
            }

            _context.Entry(autoBrand).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AutoBrandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PostAutoBrand([FromBody] AutoBrand autoBrand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.AutoBrands.Add(autoBrand);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAutoBrand", new { id = autoBrand.Id }, autoBrand));
        }
コード例 #3
0
ファイル: VehicleBase.cs プロジェクト: Aliasiuk/Training
        public VehicleBase(Guid id, string stateCarNumber, AutoBrand autoBrand, string name, DateTime produced, double price,
                           int maximumSpeed, FuelType fuelType, double consumption, int mileage)

        {
            Id             = id;
            StateCarNumber = stateCarNumber;
            AutoBrand      = autoBrand;
            Name           = name;
            Produced       = produced;
            Price          = price;
            MaximumSpeed   = maximumSpeed;
            FuelType       = fuelType;
            Сonsumption    = consumption;
            Mileage        = mileage;
        }
コード例 #4
0
        public PassengerVehicle(Guid id, string stateCarNumber, AutoBrand autoBrand, string name, DateTime produced, double price,
                                int maximumSpeed, FuelType fuelType, double consumption, int mileage, int passengerNumber)
            : base(id, stateCarNumber, autoBrand, name, produced, price, maximumSpeed, fuelType, consumption, mileage)

        {
            Id              = id;
            StateCarNumber  = stateCarNumber;
            AutoBrand       = autoBrand;
            Name            = name;
            Produced        = produced;
            Price           = price;
            MaximumSpeed    = maximumSpeed;
            FuelType        = fuelType;
            Сonsumption     = consumption;
            Mileage         = mileage;
            PassengerNumber = passengerNumber;
        }
コード例 #5
0
ファイル: Truck.cs プロジェクト: Aliasiuk/Training
        public Truck(Guid id, string stateCarNumber, AutoBrand autoBrand, string name, DateTime produced, double price,
                     int maximumSpeed, FuelType fuelType, double consumption, int mileage,
                     double cargo, int trunkLenght, int trunkHeight, int trunkWeight)
            : base(id, stateCarNumber, autoBrand, name, produced, price, maximumSpeed, fuelType, consumption, mileage)

        {
            Id             = id;
            StateCarNumber = stateCarNumber;
            AutoBrand      = autoBrand;
            Name           = name;
            Produced       = produced;
            Price          = price;
            MaximumSpeed   = maximumSpeed;
            FuelType       = fuelType;
            Сonsumption    = consumption;
            Mileage        = mileage;
            Cargo          = cargo;
            TrunkLenght    = trunkLenght;
            TrunkHeight    = trunkHeight;
            TrunkWeight    = trunkWeight;
        }
コード例 #6
0
ファイル: MapperExtensions.cs プロジェクト: Zkken/MotorDepot
 public static AutoBrandDto ToDto(this AutoBrand model)
 {
     return(MapperBLL.Map <AutoBrand, AutoBrandDto>(model));
 }