public async Task <IActionResult> NewUserDate([FromBody] Date date) { _log.Info("Calling new user date endpoint..."); try { await _repository.NewDate(date); } catch (ArgumentException) { _log.Error("The provided vehicle already has a date"); return(BadRequest()); } var reparation = new Reparation { Id = Guid.NewGuid().ToString(), WorkshopId = date.WorkshopId, PlateNumber = date.PlateNumber, Date = date.ReparationDate, Type = date.Reason, Status = date.Status, Details = new List <string>() }; await _repository.NewReparation(reparation); return(Ok()); }
public async Task <IActionResult> UpdateWorkshopReparation([FromBody] Reparation reparation) { _log.Info("Calling update workshop reparation endpoint"); if (reparation.Id == default) { reparation.Id = Guid.NewGuid().ToString(); await _repository.NewReparation(reparation); } else { try { await _repository.UpdateWorkshopReparation(reparation); await _repository.UpdateDateStatus(reparation.PlateNumber, reparation.Status); } catch (ArgumentException e) { _log.Error("Reparation with the provided id does not exists"); return(Forbid()); } } return(Ok()); }
private void Repair(IList <IChromosome> chromosomes) { foreach (var c in chromosomes) { Reparation.Repair(c); } }
public static ReparationGetDTO FromReparation(Reparation reparation) { return(new ReparationGetDTO { Description = reparation.Description, Price = reparation.Price }); }
public AddReparation(Reparation r, MainWindow mw) : this() { this.main = mw; FeedUi(r); this.reparation = r; this.mode = Mode.Edit; this.DataContext = this.reparation; }
private void FeedUi(Reparation r) { //this.tbNom.Text = r.Nom; this.tbPrenom.Text = r.Prenom; this.tbMobile.Text = r.Contact; this.tbModel.Text = r.ModelPhone; this.tbEmail.Text = r.Email; this.tbDescription.Text = r.Description; }
private void SaveCustomer() { var customer = new Customer(); customer.NameSurname = txtCustomerNameSurname.Text; customer.PhoneNumber = txtCustomerMobileNumber.Text; customer.Address = txtCustomerAddress.Text; var reparation = new Reparation(); reparation.Operation = txtReparationOperation.Text; reparation.Price = txtReparationPrice.Text; reparation.AcceptanceTime = dtpReparationAcceptanceTime.Value.Date; reparation.DeliverTime = dtpReparationDeliverTime.Value.Date; var staff = new Staff(); staff.NameSurname = txtStaffNameSurname.Text; staff.Speciality = txtStaffSpeciality.Text; staff.Reparation = reparation; var vehicle = new Vehicle(); vehicle.Brand = txtVehicleBrand.Text; vehicle.Model = txtVehicleModel.Text; vehicle.NumberPlate = txtVehicleNumberPlate.Text; vehicle.Staff = staff; customer.Vehicle = vehicle; try { _dbContext.Set <Customer>().Add(customer); _dbContext.SaveChanges(); customerCollection = _dbContext.Set <Customer>().IncludeRelations(x => x.Vehicle, x => x.Vehicle.Staff, x => x.Vehicle.Staff.Reparation).OrderByDescending(x => x.CreatedDate).ToList(); ClearGrid(); FillGrid(customerCollection); MessageBox.Show(new Form() { TopMost = true }, "Müşteri kaydedildi.", "Bilgilendirme"); } catch (Exception ex) { var exception = new AppException("Kaydetme işlemi sırasında hata oluştu. Hata : " + ex, ex); MessageBox.Show(new Form() { TopMost = true }, "Kaydetme işlemi sırasında hata oluştu.", "Hata"); } }
/// <summary> /// This method updates the provided workshop reparation information in the database. /// </summary> /// <param name="reparation">The reparation data</param> /// <param name="cancellationToken">The cancellation token</param> public async Task UpdateWorkshopReparation(Reparation reparation, CancellationToken cancellationToken = default) { var result = await GetReparationById(reparation.Id, cancellationToken); if (result == default(Reparation)) { throw new ArgumentException("No reparation with the provided id was found"); } await Reparations.ReplaceOneAsync(c => c.Id == reparation.Id, reparation, new ReplaceOptions { IsUpsert = false }, cancellationToken); }
public Reparation Upsert(int id, Reparation reparation) { var existing = context.Reparations.AsNoTracking().FirstOrDefault(r => r.ReparationId == id); if (existing == null) { context.Reparations.Add(reparation); context.SaveChanges(); return(reparation); } reparation.ReparationId = id; context.Reparations.Update(reparation); context.SaveChanges(); return(reparation); }
async Task PopulateReparations() { var id = "e462fe80-63e3-4130-8128-eed38527dd2f"; var result = await _repository.GetReparationById(id); if (result == null) { var reparation = new Reparation { Id = id, WorkshopId = "1", Date = DateTime.UtcNow.Ticks, PlateNumber = "1234ABC", Type = ReparationType.Reparation, Status = ReparationStatus.Repairing }; await _repository.NewReparation(reparation); } id = "8cee76b3-6ed9-4fd5-af23-8a641c3dac63"; result = await _repository.GetReparationById(id); if (result == null) { var reparation = new Reparation { Id = id, WorkshopId = "1", AirFilter = true, Date = DateTime.UtcNow.AddMonths(-1).Ticks, GasFilter = true, PlateNumber = "1234ABC", Type = ReparationType.Maintenance, Status = ReparationStatus.Completed, Details = new List <string> { "Changed oil filter", "Changed oil", "Changed gas filter", "Other minor reparations" } }; await _repository.NewReparation(reparation); } }
private void Creer() { // récupérer le contenue des textbox dans des variables String TextNom = this.NomTextbox.Text; String TextPrénom = this.Prénom.Text; String TextModelPhone = this.ModelPhone.Text; int TextMobile = int.Parse(this.Mobile.Text);; String TextEmail = this.Email.Text; int TextDate = int.Parse(this.DateRecue.Text); String TextDescrip = this.Descxription.Text; String TextStat = this.Statuts.Text; int TextPrix = int.Parse(this.PrixReparation.Text); // créer un object réparation a l'aide de ses variables Reparation NewClient = new Reparation(TextNom, TextPrénom, TextModelPhone, TextMobile, TextEmail, new DateTime(TextDate), TextDescrip, TextStat, TextPrix); Business.Reparation.Add(NewClient); }
public void Record_Reparation_Click(object sender, RoutedEventArgs e) { try { if (this.mode == Mode.Edit) { this.reparation.Nom = this.tbNom.Text; //this.main.Refresh(); } else { Reparation rep = new Reparation(this.tbNom.Text, this.tbPrenom.Text, this.tbMobile.Text, this.tbEmail.Text, this.tbModel.Text, this.tbDescription.Text); Business.Reparations.Add(rep); } this.Close(); MessageBox.Show("Le téléphone a bien été enregistré", "toto", MessageBoxButton.OK); }catch (Exception ex) { } }
/// <summary> /// This method saves in the database the provided reparation data. /// </summary> /// <param name="reparation">The reparation data</param> /// <param name="cancellationToken">The cancellation token</param> public async Task NewReparation(Reparation reparation, CancellationToken cancellationToken = default) { await Reparations.InsertOneAsync(reparation, new InsertOneOptions { BypassDocumentValidation = false }, cancellationToken); }
public void SaveReparation(Reparation reparation) { DataContext.Reparations.InsertOnSubmit(reparation); DataContext.SubmitChanges(); }
public Reparation Create(Reparation reparation) { context.Reparations.Add(reparation); context.SaveChanges(); return(reparation); }
public IActionResult Put(int id, [FromBody] Reparation reparation) { var result = reparationService.Upsert(id, reparation); return(Ok(result)); }
public void Post([FromBody] Reparation reparation) { reparationService.Create(reparation); }
public void ShowEditDialog(Reparation r) { this.mode = Mode.Edit; this.tbNom.Text = r.Nom; this.ShowDialog(); }
private static Reparation SwapValues(Reparation[] repairs, int min, int i) { Reparation temp; temp = repairs[i]; repairs[i] = repairs[min]; repairs[min] = temp; return temp; }
static void Main(string[] args) { //1. Instaciation personne Personne p = new Personne(); p.Nom = "Rodriguez"; p.Prenom = "Belen"; p.DateDeNaissance = new DateTime(1985, 02, 01); Console.WriteLine($"Nom: {p.Nom} - Prenom: {p.Prenom}, Date de Naissance: {p.DateDeNaissance}"); //2.1 Lier vehicule avec la personne //Vehicule v = new Vehicule(); //-->une fois que la classe devienne abstraite on ne pourra pas l'instancier //v.Proprietaire = p; //v.Modele = "Citadine"; //v.Immatriculation = "1234567"; //2.2 Instancier une voiture et un camion et les lier avec la personne Voiture v = new Voiture() { Proprietaire = p, Modele = "Citadine", Immatriculation = "1234567", NombresDePlace = 4 }; //les deux, camion et voiture ont le meme propietaire Camion c = new Camion() { Proprietaire = p, Modele = "Unknown", Immatriculation = "7891234", NombresKm = 300000 }; //les deux, camion et voiture ont le meme propietaire v.Proprietaire = p; c.Proprietaire = p; Console.WriteLine($"La personne {v.Proprietaire.Prenom}, {v.Proprietaire.Nom} possede la voiture modele {v.Modele} avec immatriculation {v.Immatriculation} et nombre de places {v.NombresDePlace}"); Console.WriteLine($"La personne {v.Proprietaire.Prenom}, {v.Proprietaire.Nom} possede le camion modele {c.Modele} avec immatriculation {c.Immatriculation} ave nombres de km {c.NombresKm}"); //3. Instaciation reparation Reparation reparationRoue = new Reparation(); reparationRoue.Intitulé = "Reparation roues"; reparationRoue.Duree = 2; Reparation reparationEssuiGlass = new Reparation(); reparationEssuiGlass.Intitulé = "Reparation essui glass"; reparationEssuiGlass.Duree = 3; Reparation reparationPneus = new Reparation(); reparationPneus.Intitulé = "Reparation Pneus"; reparationPneus.Duree = 4; Reparation reparationRetroviseur = new Reparation(); reparationRetroviseur.Intitulé = "Reparation Retroviseur "; reparationRetroviseur.Duree = 1; Reparation reparationCoffre = new Reparation(); reparationCoffre.Intitulé = "Reparation Coffre"; reparationCoffre.Duree = 1; Reparation reparationPeinture = new Reparation(); reparationPeinture.Intitulé = "Reparation Peinture"; reparationPeinture.Duree = 1; //4. Lier le vehicule (voiture ou camion) avec la facture Facture fVoiture = new Facture(); // Instantiation de la facture pour la voiture fVoiture.Vehicule = v; //Lié avec la voiture Facture fCamion = new Facture(); fCamion.Vehicule = c; //Lié avec le camion //5. Mettre tous les reparations d'un vehicule dans la facture fVoiture.Ajouter(reparationRoue); fVoiture.Ajouter(reparationEssuiGlass); fVoiture.Ajouter(reparationPneus); fVoiture.Ajouter(reparationRetroviseur); fVoiture.Ajouter(reparationPeinture); fVoiture.Ajouter(reparationCoffre); //fVoiture.AfficherTousReparations(); //f.CalculerCoutTotal(v); // on ne peut acceder directement a la méthode car est uen méthode privée. //6.Afficher la facture //f.AfficherFacture(v); Console.WriteLine(v.calculPrixHoraire()); //Affiche le prix horaire applique à la voiture Console.WriteLine(c.calculPrixHoraire()); //Afficher le prix horarie applique au camion //6.Afficher la facture fVoiture.AfficherFacture(); fCamion.AfficherFacture(); }
public static Reparation[] SelectionSortingAlgorithm(Reparation[] repairs) { int min; Reparation temp; for (int i = 0; i < repairs.Length - 1; i++) { min = i; for (int j = i + 1; j < repairs.Length; j++) if (repairs[j].priority < repairs[min].priority) min = j; temp = SwapValues(repairs, min, i); } return repairs; }