/// <summary> /// Update Constructor. Call if you want to load an automobile for updates. /// </summary> /// <param name="miscController">Controller for small operations - side table controller</param> /// <param name="automobileController">Controller for the automobile table.</param> /// <param name="Model">The AutomobileDataModel you are going to update.</param> public AutomobileDataInput(MiscController miscController, AutomobileController automobileController, AutomobileDataModel Model) { InitializeComponent(); this.miscController = miscController; this.automobileController = automobileController; this.Model = Model; }
private void AssignValues() { lbl_cardNumber.Text = CardModel.Id.ToString(); dtp_arrival.Value = CardModel.DateOfArrival; dtp_departure.Value = CardModel.DateOfDeparture; if (CardModel.Description != null) { rtb_Description.Text = CardModel.Description; } if (CardModel.EmployeeName != null) { tb_Employee.Text = CardModel.EmployeeName; } lbl_PPrice.Text = CardModel.TotalPrice.ToString(); if (CardModel.Parts.Count > 0) { lb_Parts.Items.AddRange(Array.ConvertAll(CardModel.Parts.ToArray(), ConvertDataModel_To_ViewModel)); } cb_Finished.Checked = CardModel.Finished; tb_labour.Text = $"{ CardModel.TotalPrice - CardModel.Parts.Sum(p => p.Price)}"; Task t = new Task(() => { var name = AutomobileController.GetOwnerName(CardModel.AutomobileId); this.Invoke(new Action(() => { tb_Client.Text = name; })); }); t.Start(); }
public ServiceHistory(int Id, AutomobileController automobileController, MiscController miscController) { InitializeComponent(); this.AutomobileController = automobileController; this.MiscController = miscController; AutomobileId = Id; }
static void Main(string[] args) { Console.WriteLine("############################## The S of SOLID ######################################################################"); GarageStationUtility stationUtility = new GarageStationUtility(); GarageStation garage = new GarageStation(stationUtility); garage.OpenForService(); garage.DoService(); garage.CloseGarage(); Console.WriteLine("############################## The O of SOLID ######################################################################"); RegularSavingsAccount savingsAccount = new RegularSavingsAccount(); savingsAccount.Balance = 10000; Console.WriteLine($"The interest on the Regular Savings Account with a balance of ${savingsAccount.Balance} is ${savingsAccount.CalcInterest()}."); SalarySavingsAccount salarySavingsAccount = new SalarySavingsAccount(); salarySavingsAccount.Balance = 50000; Console.WriteLine($"The interest on the Salary Savings Account with a balance of ${salarySavingsAccount.Balance} is ${salarySavingsAccount.CalcInterest()}."); CorporateAccount corporateAccount = new CorporateAccount(); corporateAccount.Balance = 100000; Console.WriteLine($"The interest on the Corporate Account with a balance of ${corporateAccount.Balance} is ${corporateAccount.CalcInterest()}."); Console.WriteLine("############################## The L of SOLID ######################################################################"); Apple apple = new Apple(); Console.WriteLine(apple.GetColor()); Orange orange = new Orange(); Console.WriteLine(orange.GetColor()); Console.WriteLine("############################## The I of SOLID ######################################################################"); HPLaserJetPrinter HPPrinter = new HPLaserJetPrinter(); Console.WriteLine("~~~~ HP Printer ~~~~"); HPPrinter.Print("1234"); HPPrinter.Fax("1234"); HPPrinter.Scan("1234"); HPPrinter.PrintDuplex("1234"); Console.WriteLine("~~~~ Liquid Ink Printer ~~~~"); LiquidInkPrinter liquidInkPrinter = new LiquidInkPrinter(); liquidInkPrinter.Print("1234"); liquidInkPrinter.Scan("1234"); Console.WriteLine("############################## The D of SOLID ######################################################################"); IAutomobile automobile = new Jeep(); //IAutomobile automobile = new Dodge(); AutomobileController automobileController = new AutomobileController(automobile); //automobile.Ignition(); //automobile.Stop(); automobileController.Ignition(); automobileController.Stop(); }
static void Main(string[] args) { #region singleton //Singleton.GetInstance.Show(); //Singleton.GetInstance.Show(); //Singleton.GetInstance.Show(); #endregion #region factory pattern //VehicleFactory factory = new ConcreteVehicleFactory(); //IFactory bike = factory.GetVehicle("Bike"); //bike.Drive(10); //IFactory scooter = factory.GetVehicle("Scooter"); //scooter.Drive(20); #endregion #region abstract factory pattern #endregion #region Builder Pattern //var vehicleCreater = new VehicleCreator(new HondaBuilder()); //vehicleCreater.CreateVehicle(); //var vehicle = vehicleCreater.GetVehicle(); //vehicle.ShowInfo(); //Console.WriteLine("---------------------------------------------"); //vehicleCreater = new VehicleCreator(new HeroBuilder()); //vehicleCreater.CreateVehicle(); //vehicle = vehicleCreater.GetVehicle(); //vehicle.ShowInfo(); #endregion #region Prototype Pattern //Developer developer = new Developer(); //developer.Name = "Vijay Pandit"; //developer.Role = "Developer"; //developer.PreferredLanguage = "C#"; //Developer devCopy = (Developer)developer.Clone(); //devCopy.Name = "Subin Manandhar";//Not mention Role and PreferredLanguage, it will copy above //Console.WriteLine(developer.GetDetails()); //Console.WriteLine(devCopy.GetDetails()); //Console.WriteLine("---------------------------------------------------"); //Typist typist = new Typist(); //typist.Name = "Ajuba"; //typist.WordsPerMinute = 120; //typist.Role = "Typist"; //Typist typistCopy = (Typist)typist.Clone(); //typistCopy.Name = "Salo"; //Console.WriteLine(typist.GetDetails()); //Console.WriteLine(typistCopy.GetDetails()); #endregion #region SOLID Design Principle #region DependencyInversionPrinciple IAutomobile automobile = new Jeep(); AutomobileController automobileController = new AutomobileController(automobile); automobile.Ignition(); automobile.Stop(); #endregion #endregion Console.ReadKey(); }
public Card(AutomobileController automobileController, MiscController miscController, MaintenanceCardDataModel card) { InitializeComponent(); this.AutomobileController = automobileController; this.MiscController = miscController; this.CardModel = card; }
private void btn_delete_Click(object sender, EventArgs e) { var r = MessageBox.Show("Are you sure you want to delete this card?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { AutomobileController.DeleteMaintenanceCard(AutomobileId, Cards[lb_MH.SelectedIndex].Id); } }
private void LoadServiceHistory() { var viewModel = AutomobileController.GetServiceHistoryViewModel(AutomobileId); lbl_RegN.Text = viewModel.DRN; lbl_horsePower.Text = viewModel.HP.ToString(); lbl_Brand.Text = viewModel.Brand.Name; lbl_Model.Text = viewModel.Model.Name; lbl_Volume.Text = viewModel.Volume; }
private void PopulateMaintenanceCardListBox() { Task worker = new Task(() => { Cards = AutomobileController .GetMaintenanceCardDataModelsByChassisCode( AutomobileController.GetAutomobileDataModel(AutomobileId).ChassiNumber); foreach (var c in Cards) { DisplayCard(c); } }); worker.Start(); }
private void UpdateMaintenanceCard() { if (ValidateInput()) { var employeeName = tb_Employee.Text; double.TryParse(tb_labour.Text, out double labourPrice); var departureTime = dtp_departure.Value; var arrivalTime = dtp_arrival.Value; var description = rtb_Description.Text; var parts = Array.ConvertAll( lb_Parts.Items.Cast <PartsViewModel>().ToArray(), ConvertViewModel_To_DataModel); CardModel.DateOfDeparture = departureTime; CardModel.EmployeeName = employeeName; CardModel.Description = description; CardModel.DateOfDeparture = departureTime; if (CardModel.DateOfArrival.Date != arrivalTime.Date) { CardModel.DateOfArrival = arrivalTime; } foreach (var p in parts) { MiscController.LinkPartsToMaintenanceCards(p.Id, this.CardModel.Id); } CardModel.Finished = cb_Finished.Checked; AutomobileController.SaveMaintenanceCard(CardModel); this.Close(); } else { MessageBox.Show("Invalid Input!", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
public Dependancies() { DatabaseContext = new AutomobileDbContext(); MiscController = new MiscController(DatabaseContext); AutomobileController = new AutomobileController(DatabaseContext); }
private void btn_add_Click(object sender, EventArgs e) { AutomobileController.AddMaintenanceCard(this.AutomobileId); }
public AutomobileControllerTest() { var aAutomobileList = new List <Automobile> { new Automobile { Id = 5, VIN = "PDQ123ABC789chevy", VehicleNumber = "RENT-2", Name = "Chevy Impala", Class = "Full Size", Style = "Sedan", Color = "Red", Manufacturer = "Chevrolet", Model = "Impala", Code = "FCAR", LocationId = 1 }, new Automobile { Id = 6, VIN = "QRS123ABC7890ford", VehicleNumber = "RENT-3", Name = "Ford Taurus", Class = "Full Size", Style = "Sedan", Color = "Green", Manufacturer = "Ford", Model = "Taurus", Code = "FCAR", LocationId = 1 }, new Automobile { Id = 1, VIN = "XYZ123ABC789chevy", VehicleNumber = "RENT-1", Name = "Chevy Impala", Class = "Full Size", Style = "Sedan", Color = "Grey", Manufacturer = "Chevrolet", Model = "Impala", Code = "FCAR", LocationId = 1 } }; var aAutomobileService = new Mock <IAutomobileService>(); aAutomobileService.Setup(aItem => aItem.GetAutomobilesForCustomerAsync(1)) .ReturnsAsync(aAutomobileList.AsEnumerable()); aAutomobileService.Setup(aItem => aItem.GetAutomobilesForCustomerAsync(2)) .ReturnsAsync(Enumerable.Empty <Automobile>()); aAutomobileService.Setup(aItem => aItem.GetAutomobileAsync(1, 1)) .ReturnsAsync(aAutomobileList.FirstOrDefault(aItem => aItem.Id == 1)); aAutomobileService.Setup(aItem => aItem.GetAutomobileAsync(2, 1)) .ReturnsAsync(null); /********************************************************************************************* * build mock data for ControllerContext so that context-dependent properties can be tested * (headers, routing, etc...) *********************************************************************************************/ var config = new HttpConfiguration(); var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/automobile"); var route = config.Routes.MapHttpRoute("DefaultApi", "api/v{version}/{controller}/{id}"); var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "Automobile" } }); _controller = new AutomobileController(aAutomobileService.Object) { ControllerContext = new HttpControllerContext(config, routeData, request), Request = request }; _controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config; }