private void AddMecanicButton_OnClick(object sender, RoutedEventArgs e) { string name = AddMecanicNameTextBox.Text; string firstName = AddMecanicFirstNameTextBox.Text; if (!FieldsCompleted(name, firstName)) { AddMecanicDisplayInfoTextBlock.Text = @"Must complete mandatory fields."; } else { AddMecanicButton.IsEnabled = true; Mecanic mechanic = new Mecanic() { Nume = name, Prenume = firstName }; _client.AddMecanic(mechanic); AddMecanicDisplayInfoTextBlock.Text = @"Mecanic added."; AddMecanicDisplayInfoTextBlock.Visibility = Visibility.Visible; } MechanicsTabItem_OnLoaded(sender, e); }
public void WhenMechanicExists_MechanicExists_ItShouldReturnTrue() { Mecanic testMechanic = CreateTestMechanicEntity(); MechanicRepository testMechanicRepository = CreateTestMechanicRepository(); testMechanicRepository.MechanicExists(testMechanic).Should().BeTrue(); }
static void Main(string[] args) { MagistralaCommands.Instance.Value.InregistreazaProcesatoareStandard(); MagistralaEvenimente.Instanta.Value.InregistreazaProcesatoareStandard(); MagistralaEvenimente.Instanta.Value.InchideInregistrarea(); List <Eveniment> eve = new List <Eveniment>(); var writeRepo = new WriteRepository(); var readRepo = new ReadRepository(); var masina = new Masina(new PlainText("WV Passat"), 2005, new CIV("EI309MNN"), new SerieSasiu("ALABALAPR")); var mecanic = new Mecanic(new PlainText("Nelutu"), 1); var client = new Client(new PlainText("Orlando"), 1); var comanda = new Comanda(mecanic, client, new IDComanada(1), masina, "reparatie turbina"); writeRepo.PlaseazaComanda(comanda); //var commandPlasareComanda = new CommandPlasareComanda(); //MagistralaCommands.Instance.Value.Trimite(commandPlasareComanda); //AtlierAuto.Evenimente.ProcesatorPlasareComanda procesatorPlasareComanda = new ProcesatorPlasareComanda() //AtelierAuto.Evenimente.ProcesatorPlasareComanda procesatorPlasareComanda = new AtelierAuto.Evenimente.ProcesatorPlasareComanda(); // SalvareEvenimente(comanda); //readRepo.CautaComanda(new Guid()); // readRepo.IncarcaDinListaDeEvenimente(); //eve = ReadRepository.IncarcaDinListaDeEvenimente(); Console.ReadLine(); Console.ReadKey(); }
public void WhenMechanicsWithCloseNamesExists_PartialMechanicSearch_ItShouldReturnResults() { Mecanic testMechanic = CreateTestMechanicEntity(); MechanicRepository testMechanicRepository = CreateTestMechanicRepository(); testMechanicRepository.PartialMechanicsSearch(testMechanic).Count.Should().BeGreaterThan(1); }
public void WhenMechanicAdded_AddMechanic_ItShouldAddSuccessfully() { Mecanic testMechanic = CreateTestMechanicEntity(); MechanicRepository testMechanicRepository = CreateTestMechanicRepository(); testMechanicRepository.AddMechanic(testMechanic); CreateTestEntities().Mecanics.FirstOrDefault(m => m.MecanicId == testMechanic.MecanicId).Should().NotBeNull(); }
public void Add(Mecanic mecanic) { if (mecanic == null) { return; } Context.Mecanics.Add(mecanic); Context.SaveChanges(); }
public static MechanicModel FromEntityToModel(Mecanic entityMechanic) { MechanicModel mechanicModel = new MechanicModel(); mechanicModel.MechanicId = entityMechanic.MecanicId; mechanicModel.FirstName = entityMechanic.Nume; mechanicModel.LastName = entityMechanic.Prenume; return(mechanicModel); }
public void WhenMechanicExists_DeleteMechanic_ItShouldDeleteSuccessfully() { Entities applicationContext = CreateTestEntities(); MechanicRepository testMechanicRepository = new MechanicRepository(applicationContext); int testMechanicId = 1; Mecanic testMechanic = applicationContext.Mecanics.FirstOrDefault(m => m.MecanicId == testMechanicId); testMechanicRepository.DeleteMechanic(testMechanicId); applicationContext.Mecanics.FirstOrDefault(m => m.MecanicId == testMechanicId).Should().BeNull(); }
public void AddMecanic(Mecanic mecanic) { if (mecanic == null) { throw new ArgumentException("Mecanic must not be null."); } _context.Mecanici.Add(mecanic); _context.SaveChanges(); }
public void Create(Mecanic mecanic) { if (mecanic != null) { throw new System.ArgumentNullException(); } mecanicRepository.Add(mecanic); mecanicRepository.Save(); }
public Mecanic GetMechanic(Mecanic mechanic) { if (mechanic == null) { return(null); } var foundMechanic = _applicationContext.Mecanics.FirstOrDefault(m => m.MecanicId == mechanic.MecanicId); return(foundMechanic); }
public bool MechanicExists(Mecanic mechanic) { if (mechanic == null) { return(false); } var foundMechanic = _applicationContext.Mecanics.FirstOrDefault(m => m.MecanicId == mechanic.MecanicId); return(foundMechanic != null); }
public void WhenClientExists_UpdateMechanic_ItShouldUpdateSuccessfully() { Entities applicationContext = CreateTestEntities(); MechanicRepository testMechanicRepository = new MechanicRepository(applicationContext); int testMechanicId = 3; Mecanic testMechanic = applicationContext.Mecanics.FirstOrDefault(m => m.MecanicId == testMechanicId); testMechanic.Nume = "Marinel"; testMechanicRepository.UpdateMechanic(testMechanic); applicationContext.Mecanics.FirstOrDefault(m => m.MecanicId == testMechanicId)?.Nume.Should().Be("Marinel"); }
public Mecanic Add(Mecanic mecanic) { if (GetById(mecanic.MecanicId) != null) { return(null); } db.Mecanics.Add(mecanic); db.SaveChanges(); return(mecanic); }
public void AddMechanic(Mecanic mechanic) { if (mechanic == null) { return; } if (MechanicExists(mechanic)) { return; } _applicationContext.Mecanics.Add(mechanic); _applicationContext.SaveChanges(); }
public static Mecanic FromModelToEntity(MechanicModel mechanicModel) { Mecanic mechanicEntity = new Mecanic(); if (mechanicModel != null) { mechanicEntity.MecanicId = mechanicModel.MechanicId; mechanicEntity.Nume = mechanicModel.FirstName; mechanicEntity.Prenume = mechanicModel.LastName; } return(mechanicEntity); }
public Boolean Delete(int id) { Mecanic mecanic = GetById(id); if (mecanic == null) { return(false); } db.Mecanics.Remove(mecanic); db.SaveChanges(); return(true); }
public ActionResult PlasareComandaControlerr() { //View var masina = new Masina(new PlainText("WV Passat"), 2005, new CIV("EI309MNN"), new SerieSasiu("ALABALAPR")); var mecanic = new Mecanic(new PlainText("Nelutu"), 1); var client = new Client(new PlainText("Orlando"), 1); var comandaa = new Comanda(mecanic, client, new IDComanada(1), masina, "reparatie turbina"); return(View()); }
public void UpdateMechanic(Mecanic mechanic) { if (mechanic == null) { return; } if (MechanicExists(mechanic)) { var clonedMechanic = mechanic; MechanicTransformer.MergeMechanicEntities(clonedMechanic, mechanic); } _applicationContext.SaveChanges(); }
static void Main(string[] args) { MagistralaCommands.Instance.Value.InregistreazaProcesatoareStandard(); MagistralaEvenimente.Instanta.Value.InregistreazaProcesatoareStandard(); MagistralaEvenimente.Instanta.Value.InchideInregistrarea(); List <Eveniment> eve = new List <Eveniment>(); var writeRepo = new WriteRepository(); var readRepo = new ReadRepository(); Masina masina = new Masina(new PlainText("WV Passat"), 2005, new CIV("EI309MNN"), new SerieSasiu("ALABALAPR")); Mecanic mecanic = new Mecanic(new PlainText("Nelutu"), 1); Client client = new Client(new PlainText("Orlando"), 1); Masina masina2 = new Masina(new PlainText("Audi A6"), 2014, new CIV("AAAAAAAA"), new SerieSasiu("BBBBBBBB")); Mecanic mecanic2 = new Mecanic(new PlainText("Dorel"), 4); Client client2 = new Client(new PlainText("Tarce"), 14); var comanda = new Comanda(mecanic, client, new IDComanada(5), masina, "distributie"); //readRepo.CautaComanda("5"); var comanda2 = new Comanda(mecanic2, client2, new IDComanada(2), masina2, "reparatie turbina"); //ReadRepository.IncarcaDinListaDeEvenimente(); /* ADAUG COMANDA 1 * var commandPlasareComanda = new CommandPlasareComanda(); * commandPlasareComanda.Comanda = comanda; * MagistralaCommands.Instance.Value.Trimite(commandPlasareComanda); */ // ADAUG COMANDA 2 var commandPlasareComanda2 = new CommandPlasareComanda(); commandPlasareComanda2.Comanda = comanda2; MagistralaCommands.Instance.Value.Trimite(commandPlasareComanda2); //AtlierAuto.Evenimente.ProcesatorPlasareComanda procesatorPlasareComanda = new ProcesatorPlasareComanda() //AtelierAuto.Evenimente.ProcesatorPlasareComanda procesatorPlasareComanda = new AtelierAuto.Evenimente.ProcesatorPlasareComanda(); // SalvareEvenimente(comanda); //readRepo.CautaComanda(new Guid()); //readRepo.IncarcaDinListaDeEvenimente(); Console.ReadLine(); Console.ReadKey(); }
public void Delete(Mecanic mecanic) { if (mecanic == null) { return; } var foundMecanic = Context.Mecanics.FirstOrDefault(m => m.MecanicId == mecanic.MecanicId); if (foundMecanic != null) { Context.Mecanics.Remove(foundMecanic); Context.SaveChanges(); } }
private void buttonUpdateMecanic_Click_1(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridViewDisplayMechanics.SelectedRows) { int id = Convert.ToInt32(row.Cells[0].Value); Mecanic mecanic = _carService.FindMecanicById(id); mecanic.Nume = row.Cells[1].Value.ToString(); mecanic.Prenume = row.Cells[2].Value.ToString(); _carService.UpdateMecanic(mecanic); } // reload to view changes FormDisplayDetails_Load(sender, e); }
public void Update(Mecanic mecanic) { if (mecanic != null) { throw new System.ArgumentNullException(); } var mecanicU = mecanicRepository.Where(m => m.Id == mecanic.Id).FirstOrDefault(); mecanicU.Nume = mecanic.Nume == null ? mecanicU.Nume : mecanic.Nume; mecanicU.Prenume = mecanic.Prenume == null ? mecanicU.Prenume : mecanic.Prenume; mecanicU.DetaliuComanda = mecanic.DetaliuComanda == null ? mecanicU.DetaliuComanda : mecanic.DetaliuComanda; mecanicRepository.Save(); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Mecanic = await _context.Mecanic.FirstOrDefaultAsync(m => m.ID == id); if (Mecanic == null) { return(NotFound()); } return(Page()); }
/// <inheritdoc /> /// <summary> /// Creates the mecanic. /// </summary> /// <param name="mecanic">The mecanic.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool CreateMecanic(Mecanic mecanic) { try { _mecanicWrite = new WriteMecanicRepository(_context); _mecanicWrite.Create(mecanic); _context.SaveChanges(); return(true); } catch (Exception e) { var message = DbEntityCustomException.BuildMessageExceptions(e); throw new DbEntityCustomException(message); } }
public void UpdateMecanic(Mecanic mecanic) { if (mecanic == null) { throw new ArgumentException("Mecanic must not be null."); } var toUpdate = _context.Mecanici.Find(mecanic.Id); if (toUpdate == null) { return; } _context.Entry(toUpdate).CurrentValues.SetValues(mecanic); _context.SaveChanges(); }
public void CreateNew(MecanicDto mecanicDto) { if (mecanicDto == null) { throw new ArgumentOutOfRangeException(nameof(mecanicDto)); } var mecanic = new Mecanic { //DetaliuComanda = mecanicDto.DetaliuComanda, Nume = mecanicDto.Nume, Prenume = mecanicDto.Prenume }; mecanicRepository.Add(mecanic); unitOfWork.Commit(); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Mecanic = await _context.Mecanic.FindAsync(id); if (Mecanic != null) { _context.Mecanic.Remove(Mecanic); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public List <Mecanic> PartialMechanicsSearch(Mecanic mechanic) { if (mechanic == null) { return(null); } var queryByFirstName = _applicationContext.Mecanics.Where(m => m.Nume.Contains(mechanic.Nume)); var queryByLastName = _applicationContext.Mecanics.Where(m => m.Prenume.Contains(mechanic.Prenume)); if (queryByFirstName.Any()) { return(queryByFirstName.ToList()); } return(queryByLastName.Any() ? queryByLastName.ToList() : null); }
public void Update(Mecanic mecanic, Mecanic mecanic2) { if (mecanic == null && mecanic2 == null) { return; } var foundMechanic = Context.Mecanics.FirstOrDefault(m => m.MecanicId == mecanic.MecanicId); if (foundMechanic != null) { foundMechanic.Prenume = mecanic2.Prenume; foundMechanic.Nume = mecanic2.Nume; Context.Mecanics.AddOrUpdate(foundMechanic); Context.SaveChanges(); } }