public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] MotorcycleType motorcycleType)
        {
            if (id != motorcycleType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(motorcycleType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MotorcycleTypeExists(motorcycleType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(motorcycleType));
        }
Example #2
0
        public void PrepareMotorcycle(ChassiSize chassiSize, ColorType colorType, MotorcycleType motorcycleType, string name)
        {
            this.Init();

            this.Motorcycle.ChassiSize     = chassiSize;
            this.Motorcycle.MotorcycleType = motorcycleType;
            this.Motorcycle.ColorType      = colorType;
            this.Motorcycle.Name           = name;
        }
Example #3
0
 private void AddMotorcycle(string name, Owner owner, MotorcycleType motorcycleType, string brand)
 {
     _dataContext.Motorcycles.Add(new Motorcycle
     {
         Shop           = DateTime.Now.AddYears(-2),
         Name           = name,
         Owner          = owner,
         MotorcycleType = motorcycleType,
         Brand          = brand
     });
 }
        public async Task <IActionResult> Create([Bind("Id,Name")] MotorcycleType motorcycleType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(motorcycleType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(motorcycleType));
        }
Example #5
0
 public void PrepareMotorcycleHarley(IMotorcycleBuilder motorcycleBuilder, ChassiSize chassiSize, ColorType colorType, MotorcycleType motorcycleType, string name)
 {
     motorcycleBuilder.PrepareMotorcycle(chassiSize, colorType, motorcycleType, name);
     motorcycleBuilder.DefinePrice();
 }