public MessershmittWarplaneBuilder() { _warplane = new Warplane() { Name = "Messerschmitt Bf 109" }; }
public SpitfireWarplaneBuilder() { _warplane = new Warplane() { Name = "Supermarine Spitfire" }; }
public void AddPlane(Warplane plane) { if (!PlaneCollection.Contains(plane)) { PlaneCollection.Add(plane); } }
public void Init() { p1 = new Warplane { WarplaneID = 1, Name = "P1" }; p2 = new Warplane { WarplaneID = 2, Name = "P2" }; sut = new Comparison(); }
public ActionResult Delete(int id, Warplane plane) { try { // TODO: Add delete logic here repo.RemovePlane(id); return(RedirectToAction("Index")); } catch (Exception e) { return(View("Error")); } }
public ActionResult Edit(int id, Warplane plane) { try { // TODO: Add update logic here repo.SavePlane(plane); return(RedirectToAction("Index")); } catch (Exception e) { return(View("Error")); } }
public ActionResult Create(Warplane plane) { try { // TODO: Add insert logic here repo.SavePlane(plane); return(RedirectToAction("Index")); } catch (Exception e) { return(View("Error")); } }
public Warplane BuildWarplane(string name) { Warplane warplane = _factory.CreateWarplane(name); if (warplane == null) { return(null); } warplane.Fly(); warplane.Shoot(); warplane.Reload(); warplane.Repair(); return(warplane); }
public void Cant_Delete_unexisted_plane() { sut.AddPlane(p1); sut.AddPlane(p2); var p3 = new Warplane() { WarplaneID = 3, Name = "P3" }; var results = sut.Planes.OrderBy(x => x.Name).ToArray(); sut.RemovePlane(p3); Assert.AreEqual(results.Length, 2); Assert.AreEqual(results[0], p1); Assert.AreEqual(results[1], p2); }
public void SavePlane(Warplane plane) { if (plane.WarplaneID == 0) { context.Warplanes.Add(plane); } else { Warplane dbEntry = context.Warplanes.Find(plane.WarplaneID); if (dbEntry != null) { dbEntry.Name = plane.Name; dbEntry.Description = plane.Description; dbEntry.Country = plane.Country; dbEntry.Category = plane.Category; dbEntry.Description = plane.Description; dbEntry.PlaneImageUrl = plane.PlaneImageUrl; dbEntry.Generation = plane.Generation; dbEntry.Crew = plane.Crew; dbEntry.Length = plane.Length; dbEntry.Wingspan = plane.Wingspan; dbEntry.Height = plane.Height; dbEntry.WingArea = plane.WingArea; dbEntry.EmptyWeight = plane.EmptyWeight; dbEntry.MaximumWeight = plane.MaximumWeight; dbEntry.FuelWeight = plane.FuelWeight; dbEntry.EngineName = plane.EngineName; dbEntry.EngineDescription = plane.EngineDescription; dbEntry.EngineWeight = plane.EngineWeight; dbEntry.MaximumSpeed = plane.MaximumSpeed; dbEntry.MaxRange = plane.MaxRange; dbEntry.FlightDuration = plane.FlightDuration; dbEntry.Ceiling = plane.Ceiling; } } context.SaveChanges(); }
public void RemovePlane(Warplane plane) => PlaneCollection.Remove(plane);