public Appointement[] GetByArray(string[] ids) { List <Appointement> list = new List <Appointement>(); MySqlConnection cnn = new MySqlConnection(_cnnStr); try { cnn.Open(); MySqlCommand cmd = cnn.CreateCommand(); cmd.CommandText = "SELECT * FROM appointments WHERE appointment_id IN (" + String.Join(",", ids) + ") AND deletionDate IS NULL"; MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Appointement appointement = CreateAppointment(reader); list.Add(appointement); } reader.Close(); } finally { cnn.Close(); } return(list.ToArray()); }
public Appointement GetByUserId(int userId) { MySqlConnection cnn = new MySqlConnection(_cnnStr); Appointement appointement = null; try { cnn.Open(); MySqlCommand cmd = cnn.CreateCommand(); cmd.CommandText = "SELECT a.* FROM appointments a, availabilities av WHERE a.availability_id = av.availability_id AND a.user_id = @user_id AND av.Start_time > Now() AND deletionDate IS NULL"; cmd.Parameters.AddWithValue("@user_id", userId); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { appointement = CreateAppointment(reader); } reader.Close(); } finally { cnn.Close(); } return(appointement); }
public Appointement Get(int id) { MySqlConnection cnn = new MySqlConnection(_cnnStr); Appointement appointement = null; try { cnn.Open(); MySqlCommand cmd = cnn.CreateCommand(); cmd.CommandText = "SELECT * FROM appointments WHERE appointment_id = @id AND deletionDate IS NULL"; cmd.Parameters.AddWithValue("@id", id); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { appointement = CreateAppointment(reader); } reader.Close(); } finally { cnn.Close(); } return(appointement); }
protected void btnAnnuler_Click(object sender, EventArgs e) { //Annuler le RDV Appointement appointement = apf.GetByUserId(user.userId); Availability availability = af.GetById(appointement.availabilityId); apf.DeleteAndFreeAvail(appointement.appointementId); //Envoyer le email d'annulation a jmGuay EmailController ec = new EmailController(); string body = string.Empty; using (StreamReader reader = new StreamReader(Server.MapPath("~/Email/AnnulationRDV.html"))) { body = reader.ReadToEnd(); } body = body.Replace("{date}", availability.strdt.ToString("D", CultureInfo.CreateSpecificCulture("fr-FR"))); body = body.Replace("{prenom}", user.firstname); body = body.Replace("{nom}", user.lastname); body = body.Replace("{email}", user.email); ec.SendMail(emailAddress, "Annulation du rendez-vous de " + user.firstname + " " + user.lastname, body); Response.Redirect("RendezVous.aspx"); }
public Appointement[] GetConfirmed() { MySqlConnection cnn = new MySqlConnection(_cnnStr); List <Appointement> list = new List <Appointement>(); try { cnn.Open(); MySqlCommand cmd = cnn.CreateCommand(); cmd.CommandText = "SELECT a.* FROM appointments a, availabilities av WHERE a.availability_id = av.availability_id AND a.confirmed = true AND deletionDate IS NULL ORDER BY av.Start_time"; MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Appointement appointement = CreateAppointment(reader); list.Add(appointement); } reader.Close(); } finally { cnn.Close(); } return(list.ToArray()); }
protected void Click_Confirm(object sender, EventArgs e) { string confirmValue = Request.Form["confirm_rdv"]; if (confirmValue == "Oui") { Button button = (Button)sender; int id = Convert.ToInt32(button.Attributes["data-id"]); Appointement app = af.Get(id); af.confirm(id); User user = uf.Get(app.userId); Availability avail = avf.GetById(app.availabilityId); //On envoie un mail de confirmation EmailController ec = new EmailController(); string body = string.Empty; using (StreamReader reader2 = new StreamReader(Server.MapPath("~/Email/ConfirmationRDV.html"))) { body = reader2.ReadToEnd(); } body = body.Replace("{user}", user.firstname); body = body.Replace("{date}", avail.strdt.ToString("f", CultureInfo.CreateSpecificCulture("fr-FR"))); body = body.Replace("{AdresseCabinet}", adresseCabinet); ec.SendMail(user.email, "JMGuay.ca - Confirmation du rendez-vous [Message automatique]", body); Response.Redirect(Request.RawUrl + "?notif=confirm"); return; } Response.Redirect(Request.RawUrl); }
private Appointement CreateAppointment(MySqlDataReader reader) { int _appointmentId = (Int32)reader["appointment_id"]; int _userId = (Int32)reader["user_id"]; int _availabilityId = (Int32)reader["availability_id"]; bool _confirmed = (bool)reader["confirmed"]; string _message = reader["message"].ToString(); Appointement appointement = new Appointement(); appointement.appointementId = _appointmentId; appointement.userId = _userId; appointement.availabilityId = _availabilityId; appointement.confirmed = _confirmed; appointement.message = _message; return(appointement); }
public void OnSubmit() { int idx = FilteredApointements.IndexOf(SelectedApointement); if (idx >= 0) { FilteredApointements[idx].Room = SelectedRoom; var ap = FilteredApointements[idx]; app.AppointementController.Update(ap); } AddApointements(); OnPropertyChanged("FilteredApointements"); SelectedApointement = null; SelectedRoom = null; }
private void Refuse(int id) { Appointement app = af.Get(id); User user = uf.Get(app.userId); Availability avail = avf.GetById(app.availabilityId); af.DeleteAndFreeAvail(id); //On envoie un mail de refus EmailController ec = new EmailController(); string body = string.Empty; using (StreamReader reader2 = new StreamReader(Server.MapPath("~/Email/RefusRDV.html"))) { body = reader2.ReadToEnd(); } body = body.Replace("{user}", user.firstname); body = body.Replace("{date}", avail.strdt.ToString("f", CultureInfo.CreateSpecificCulture("fr-FR"))); ec.SendMail(user.email, "JMGuay.ca - Annulation du rendez-vous [Message automatique]", body); }
public void Delete(Appointement appointement) => service.Delete(appointement);
public void Update(Appointement appointement) => service.Update(appointement);
public Appointement Create(Appointement appointement) => service.Create(appointement);
public void Update(Appointement apointement) => _repository.Update(apointement);
public void Delete(Appointement apointement) => _repository.Delete(apointement);
public Appointement Create(Appointement appointement) => _repository.Create(appointement);
protected void Page_Load(object sender, EventArgs e) { divConnexion.Visible = false; // ----------- Vérification le l'état du module ----------- // ModuleFactory moduleFactory = new ModuleFactory(cnnStr); Module m = moduleFactory.Get((int)Module.AllModules.Appointment);/* Module id 1 = Module des prises de rendez-vous */ if (m.active == false) { Response.Redirect("Default.aspx"); } // ------------------------------------------------------- // // ----------- Vérification de la connexion ----------- // if (Session["User"] != null) { user = (User)Session["User"]; } else { divConnexion.Visible = true; divRendezVous.Visible = false; divRenseignement.Visible = false; divRendezVousPris.Visible = false; } // ------------------------------------------------------- // // ----------- Vérification de l'autorisation ----------- // if (user != null) { Appointement appointement = apf.GetByUserId(user.userId); if (appointement != null) //Un rendez-vous déja actif { divRendezVousPris.Visible = true; divRendezVous.Visible = false; divRenseignement.Visible = false; Availability availability = af.GetById(appointement.availabilityId); lblInfoRDV.Text = availability.strdt.ToString("f", CultureInfo.CreateSpecificCulture("fr-FR")); if (appointement.confirmed) { lblConfirmation.Style.Add("color", "Green"); lblConfirmation.Text = "Confirmé"; lblNotice.Text = ""; } else { lblConfirmation.Style.Add("color", "orange"); lblConfirmation.Text = "en attente de confirmation"; } } else if (user.authorized == true) //aucun rendez-vous actif et autoriser { divRendezVous.Visible = true; divRenseignement.Visible = false; divRendezVousPris.Visible = false; } else //aucun rendez-vous actif et non autoriser { divRendezVous.Visible = false; divRenseignement.Visible = true; divRendezVousPris.Visible = false; Module m2 = moduleFactory.Get((int)Module.AllModules.Contact); if (m2.active == false) { etat = "Accueil"; btnRedirection.Text = "Retour à l'accueil"; lblcontact.Text = ""; } } } // ------------------------------------------------------- // //Rempissage des dropdowns if (!Page.IsPostBack) { Availability[] availabilities = af.GetAllFree(); HashSet <string> set = new HashSet <string>(); foreach (Availability availability in availabilities) { //Dates string dateToDisplay = availability.strdt.ToString("D", CultureInfo.CreateSpecificCulture("fr-FR")); //CultureInfo.CurrentCulture.DateTimeFormat if (!set.Contains(dateToDisplay)) { ddlDate.Items.Add(new ListItem(dateToDisplay, dateToDisplay)); } set.Add(dateToDisplay); //ddlDate.Items.Add(new ListItem(dateToDisplay, availability.availabilityId.ToString())); } ddlDate_SelectedIndexChanged(null, null); } }