public IAcousticGuitar CreateAcousticGuitar(string make, string model, decimal price, string color,
                                                    string bodyWood, string fingerboardWood, bool caseIncluded, StringMaterial stringMaterial)
        {
            var acousticGuitar = new AcousticGuitar(make, model, price, color, bodyWood, fingerboardWood, caseIncluded, stringMaterial);

            return(acousticGuitar);
        }
        public async Task <IActionResult> Edit(AcousticGuitar item)
        {
            if (ModelState.IsValid)
            {
                await _acousticGuitarRepo.UpdateAsync(item);

                return(RedirectToAction("Index", "Home"));
            }
            return(View(item));
        }
Пример #3
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AcousticGuitar = await _context.AcousticGuitar.FirstOrDefaultAsync(m => m.Id == id);

            if (AcousticGuitar == null)
            {
                return(NotFound());
            }
            return(Page());
        }
    static void Main()
    {
        Guitar obj = new Guitar();

        obj.GuitarInfo();

        ElectricGuitar obj1 = new ElectricGuitar();

        obj1.ElectricGuitarInfo();

        AcousticGuitar obj2 = new AcousticGuitar();

        obj2.AcousticGuitarInfo();

        Console.ReadLine();
    }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AcousticGuitar = await _context.AcousticGuitar.FindAsync(id);

            if (AcousticGuitar != null)
            {
                _context.AcousticGuitar.Remove(AcousticGuitar);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
 public async Task UpdateAsync(AcousticGuitar item)
 {
     _context.AcousticGuitars.Update(item);
     await _context.SaveChangesAsync();
 }
Пример #7
0
        public static void Initialize(InstrumentWebAapplicationContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.AcousticGuitar.Any())
            {
                return;   // DB has been seeded
            }

            var acousticGuitars = new AcousticGuitar[]
            {
                new AcousticGuitar {
                    CapoPosition = 0, NumberOfFrets = 20, InTuneLevel = 10, NumberOfStrings = 6, Name = "AcousticGuitar1", Price = 500
                },
                new AcousticGuitar {
                    CapoPosition = 2, NumberOfFrets = 21, InTuneLevel = 7, NumberOfStrings = 6, Name = "AcousticGuitar2", Price = 200
                },
                new AcousticGuitar {
                    CapoPosition = 0, NumberOfFrets = 19, InTuneLevel = 5, NumberOfStrings = 6, Name = "AcousticGuitar3", Price = 350
                },
            };

            context.AcousticGuitar.AddRange(acousticGuitars);
            context.SaveChanges();

            var acousticPianos = new AcousticPiano[]
            {
                new AcousticPiano {
                    HasPedal = true, NumberOfKeys = 88, InTuneLevel = 10, Name = "AcousticPiano1", Price = 2500
                },
                new AcousticPiano {
                    HasPedal = false, NumberOfKeys = 76, InTuneLevel = 4, Name = "AcousticPiano2", Price = 750
                },
                new AcousticPiano {
                    HasPedal = true, NumberOfKeys = 88, InTuneLevel = 9, Name = "AcousticPiano3", Price = 800
                },
            };

            context.AcousticPiano.AddRange(acousticPianos);
            context.SaveChanges();

            var digitalPianos = new DigitalPiano[]
            {
                new DigitalPiano {
                    HasPedal = false, NumberOfKeys = 88, VolumeSetting = 10, Name = "DigitalPiano1", Price = 1000
                },
                new DigitalPiano {
                    HasPedal = true, NumberOfKeys = 76, VolumeSetting = 6, Name = "DigitalPiano2", Price = 1300
                },
                new DigitalPiano {
                    HasPedal = false, NumberOfKeys = 76, VolumeSetting = 9, Name = "DigitalPiano3", Price = 650
                },
            };

            context.DigitalPiano.AddRange(digitalPianos);
            context.SaveChanges();

            var electricGuitars = new ElectricGuitar[]
            {
                new ElectricGuitar {
                    InTuneLevel = 10, NumberOfStrings = 6, NumberOfFrets = 22, VolumeSetting = 10, Name = "ElectricGuitar1", Price = 1250
                },
                new ElectricGuitar {
                    InTuneLevel = 6, NumberOfStrings = 6, NumberOfFrets = 22, VolumeSetting = 8, Name = "ElectricGuitar2", Price = 750
                },
                new ElectricGuitar {
                    InTuneLevel = 7, NumberOfStrings = 12, NumberOfFrets = 22, VolumeSetting = 10, Name = "ElectricGuitar3", Price = 4800
                },
            };

            context.ElectricGuitar.AddRange(electricGuitars);
            context.SaveChanges();
        }