public IQueryable <Abonnement> GetAbonnementsWithRelatedInfos() { return(Abonnements.Include(a => a.Adherent) .Include(a => a.Formule.Activite) .Include(a => a.Formule.Activite.Lieu) .Include(a => a.Formule)); }
public async Task <IActionResult> PutAbonnements([FromRoute] int id, [FromBody] Abonnements abonnements) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != abonnements.aboId) { return(BadRequest()); } _context.Entry(abonnements).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AbonnementsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void SynchroniserAbonnements() { string path = "Abonnement/"; Abonnements.Clear(); foreach (Abonnement abonnement in _restApiQueries.GetAbonnements(path)) { Abonnements.Add(abonnement); } }
public async Task <IActionResult> PostAbonnements([FromBody] Abonnements abonnements) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Abonnements.Add(abonnements); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAbonnements", new { id = abonnements.aboId }, abonnements)); }
public IActionResult CreateAbonnementUser([FromBody] FichierCentral UserModel, long id) { UserModel.FichierCentralID = id; UserModel.ProfilsID = 2; Abonnements Abonnement = new Abonnements(); Abonnement.AbonnementsID = UserModel.AbonnementsID; Abonnement.pkAbonne = UserModel.FichierCentralID; Abonnement.DateDebut = DateTime.Now; if (UserModel.AbonnementsID == 1) { Abonnement.DateFin = DateTime.Today.AddMonths(1); Abonnement.Prix_Abonnement = 10; Abonnement.Abonnement = "abonnement-1-mois"; } if (UserModel.AbonnementsID == 2) { Abonnement.DateFin = DateTime.Today.AddYears(1); Abonnement.Prix_Abonnement = 100; Abonnement.Abonnement = "abonnement-1-ans"; } if (UserModel.AbonnementsID == 3) { Abonnement.DateFin = DateTime.Today.AddYears(2); Abonnement.Prix_Abonnement = 180; Abonnement.Abonnement = "abonnement-2-ans"; } if (UserModel.AbonnementsID != 0) { try { context.FichierCentral.Update(UserModel); context.Abonnements.Add(Abonnement); context.SaveChanges(); } catch (DbUpdateException exception) { return(BadRequest(new { message = exception.Message })); } return(Ok()); } return(Json(new { isFailed = "manque de pk abonnement pour creer un abonnement" })); }
public async Task <IActionResult> PostPaiementRequest([FromBody] Paiement paiement, int idClient, int idMagazine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } RestClient client = new RestClient(new Uri(@"http://ec2-52-47-88-142.eu-west-3.compute.amazonaws.com/cardpay/")); string url = $"{paiement.uuid}/{paiement.cid}/{paiement.cardNumber}/{paiement.cardMonth}/{paiement.cardYear}/{paiement.amount.ToString().Replace(",", ".")}"; RestRequest request = new RestRequest(url) { Method = Method.GET }; var response = client.Execute(request); bool ok = response.StatusCode == HttpStatusCode.OK; if (ok) { Abonnements abo = new Abonnements(idClient, idMagazine); _context.Abonnements.Add(abo); await _context.SaveChangesAsync(); paiement.paiFKAbo = abo.aboId; _context.Paiement.Add(paiement); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPaiement", new { id = paiement.cid }, paiement)); } else { return(BadRequest()); } }
private void btnAjouterAbonnement_Click(object sender, EventArgs e) { // MessageBox.Show(((int)ddlTypesAbonnement.SelectedValue).ToString()); if (dependants.Count < nupNbEnfant.Value + 1 && ((int)ddlTypesAbonnement.SelectedValue > 2)) { MessageBox.Show("Veuillez ajouter la ou les personnes qui vous accompagnes avant de créer cet abonnement"); } else { if (ValidateChildren()) { Abonnements abonnement = new Abonnements(); // MessageBox.Show($"{tbNom.Text.Trim()}{dataContext.Abonnements.Count() + 1}P"); abonnement.Id = $"{tbNom.Text.Trim()}{dataContext.Abonnements.Count() + 1}P"; abonnement.DateAbonnement = DateTime.Today; abonnement.Nom = tbNom.Text.Trim(); abonnement.Prenom = tbPrenom.Text.Trim(); abonnement.Sexe = ddlSexes.SelectedValue.ToString(); abonnement.DateNaissance = dtpDateNaissance.Value.Date; abonnement.NoCivique = (int)numNoCivique.Value; abonnement.Rue = tbRue.Text.Trim(); abonnement.Ville = tbVille.Text.Trim(); abonnement.IdProvince = ddlProvinces.SelectedValue.ToString(); abonnement.CodePostal = mtbCodePostal.Text.Remove(3, 1); abonnement.Telephone = new string(mtbTelephone.Text.Where(c => char.IsDigit(c)).ToArray()); if (mtbCellulaire.MaskCompleted) { abonnement.Cellulaire = new string(mtbCellulaire.Text.Where(c => char.IsDigit(c)).ToArray()); } abonnement.Courriel = tbCourriel.Text.Trim(); abonnement.NoTypeAbonnement = (int)ddlTypesAbonnement.SelectedValue; if (!string.IsNullOrEmpty(tbRemarque.Text.Trim())) { abonnement.Remarque = tbRemarque.Text.Trim(); } foreach (Dependants dependant in dependants) { abonnement.Dependants.Add(dependant); } // foreach (Control controle in lstControlesDynamiques) // if (controle is SaisieDependant) // abonnement.Dependants.Add(((SaisieDependant)controle).creerDependant(abonnement.Id)); dataContext.Abonnements.InsertOnSubmit(abonnement); using (TransactionScope transaction = new TransactionScope()) { try { while (abonnement.Id != $"{tbNom.Text.Trim()}{dataContext.Abonnements.Count() + 1}P") { abonnement.Id = $"{tbNom.Text.Trim()}{dataContext.Abonnements.Count() + 1}P"; abonnement.Dependants.Clear(); foreach (Dependants dependant in dependants) { abonnement.Dependants.Add(dependant); } //foreach (Control controle in lstControlesDynamiques) // if (controle is SaisieDependant) // abonnement.Dependants.Add(((SaisieDependant)controle).creerDependant(abonnement.Id)); } dataContext.SubmitChanges(); transaction.Complete(); MessageBox.Show("L'abonnement a été enregistré dans la base de données.", "Enregistrement des données"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erreur lors de l'enregistrement des données"); } } this.Close(); } else { MessageBox.Show("Vous devez vous assurez que toutes les données saisies sont correct"); } } }
public frmInformationAjoutDepense(Abonnements abonnee, Services service, Depenses depense) { InitializeComponent(); }