public Bitmap GetQRCodeUniqueParticipantCode(ConferenceAudienceModel _conferenceAudienceModel) { QRCoder.QRCodeGenerator QG = new QRCoder.QRCodeGenerator(); var data = QG.CreateQrCode(_conferenceAudienceModel.UniqueParticipantCode, QRCoder.QRCodeGenerator.ECCLevel.Q); var QRCode = new QRCoder.QRCode(data); MemoryStream memstream = new MemoryStream(); Bitmap QRCodeImage = QRCode.GetGraphic(20); QRCodeImage.Save(memstream, System.Drawing.Imaging.ImageFormat.Png); MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(_conferenceAudienceModel.Participant); mail.Subject = "QR Code To Join"; mail.Body = String.Format("This is an automatic message so you can join to the conference named {0} via QR Code", _conferenceAudienceModel.ConferenceName); memstream.Position = 0; var attachment = new System.Net.Mail.Attachment(memstream, "image.png"); mail.Attachments.Add(attachment); SmtpServer.Host = "smtp.gmail.com"; SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network; SmtpServer.UseDefaultCredentials = true; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Parola12345*"); SmtpServer.EnableSsl = true; try { SmtpServer.Send(mail); } catch (Exception ex) { } return(QRCodeImage); }
public int UpdateParticipant(ConferenceAudienceModel _conferenceAudienceModel) { ConferenceAudience result; if (_conferenceAudienceModel.ConferenceStatusId == 2) { result = _dbContext.ConferenceAudience.SingleOrDefault(x => x.ConferenceId == _conferenceAudienceModel.ConferenceId && x.Participant == _conferenceAudienceModel.Participant && x.ConferenceStatusId == 3); } else if (_conferenceAudienceModel.ConferenceStatusId == 3) { result = _dbContext.ConferenceAudience.SingleOrDefault(x => x.ConferenceId == _conferenceAudienceModel.ConferenceId && x.Participant == _conferenceAudienceModel.Participant); } else { result = null; } if (result != null) { result.ConferenceStatusId = _conferenceAudienceModel.ConferenceStatusId; _dbContext.SaveChanges(); return(1); } return(0); }
static async Task <bool> UpdateParticipantToJoin(ConferenceAudienceModel obj) { var json = JsonConvert.SerializeObject(obj); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); HttpClient client = new HttpClient(); HttpResponseMessage httpResponseMessage = client.PostAsync("http://localhost:2794/Participant/UpdateParticipantToJoin", httpContent).Result; return(httpResponseMessage.IsSuccessStatusCode); }
public void AddParticipant(ConferenceAudienceModel _conferenceAudienceModel) { ConferenceAudience current = new ConferenceAudience(); current.ConferenceId = _conferenceAudienceModel.ConferenceId; current.Participant = _conferenceAudienceModel.Participant; current.ConferenceStatusId = _conferenceAudienceModel.ConferenceStatusId; current.UniqueParticipantCode = _conferenceAudienceModel.UniqueParticipantCode; this._dbContext.ConferenceAudience.Add(current); this._dbContext.SaveChanges(); }
public IActionResult UpdateParticipantToJoin([FromBody] ConferenceAudienceModel obj) { int status = _participantRepository.UpdateParticipantToJoin(obj); if (status != 0) { return(Ok()); } else { return(NotFound()); } }
public int UpdateParticipantToJoin(ConferenceAudienceModel _conferenceAudienceModel) { var result = _dbContext.ConferenceAudience.SingleOrDefault(x => x.ConferenceId == _conferenceAudienceModel.ConferenceId && x.Participant == _conferenceAudienceModel.Participant && (x.ConferenceStatusId == 3 || x.ConferenceStatusId == 1)); if (result != null) { result.ConferenceId = _conferenceAudienceModel.ConferenceId; result.Participant = _conferenceAudienceModel.Participant; result.ConferenceStatusId = _conferenceAudienceModel.ConferenceStatusId; _dbContext.SaveChanges(); return(1); } return(0); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn) { bool isAttend = false; bool isJoin = false; bool inWithdraw = false; if (senderGrid.CurrentCell.OwningColumn.Name.ToString().Equals("AttendButton") && isAttend == false) { ConferenceAudienceModel _conferenceAudienceModel = new ConferenceAudienceModel(); isAttend = true; pressButtonGreen(sender, e.RowIndex, e.ColumnIndex); _conferenceAudienceModel.ConferenceId = (int)dataGridView1.Rows[e.RowIndex].Cells["ConferenceId"].Value; _conferenceAudienceModel.ConferenceName = (string)dataGridView1.Rows[e.RowIndex].Cells["ConferenceName"].Value; _conferenceAudienceModel.Participant = currentUser; _conferenceAudienceModel.ConferenceStatusId = 3; _conferenceAudienceModel.UniqueParticipantCode = _ConferenceRepository.GetUniqueParticipantCode(); try { bool success = AddParticipant(_conferenceAudienceModel).Result; if (success == true) { conferencesCurrentUserAttends.Clear(); conferencesCurrentUserAttends = GetConferenceAudience(currentUser); x.Clear(); x = GetAttendedConferencesFirst(); totalEntries = x.Count(); Thread thread = new Thread(() => _ConferenceRepository.GetQRCodeUniqueParticipantCode(_conferenceAudienceModel)); thread.Start(); } else { bool temp = UpdateParticipant(_conferenceAudienceModel).Result; conferencesCurrentUserAttends.Clear(); conferencesCurrentUserAttends = GetConferenceAudience(currentUser); x.Clear(); x = GetAttendedConferencesFirst(); totalEntries = x.Count(); } } catch (SqlException ex) { } changeColor(); changeColorForJoinButtons(); //InitTimer(sender, e.RowIndex, e.ColumnIndex); } if (senderGrid.CurrentCell.OwningColumn.Name.ToString().Equals("JoinButton") && isJoin == false) { isJoin = true; DateTime startDate = (DateTime)dataGridView1.Rows[e.RowIndex].Cells["StartDate"].Value; DateTime currentTime = DateTime.Now; if (currentTime.AddMinutes(5) >= startDate) { ConferenceAudienceModel _conferenceAudienceModel = new ConferenceAudienceModel(); _conferenceAudienceModel.ConferenceId = (int)dataGridView1.Rows[e.RowIndex].Cells["ConferenceId"].Value; _conferenceAudienceModel.Participant = currentUser; _conferenceAudienceModel.ConferenceStatusId = 1; bool success = UpdateParticipantToJoin(_conferenceAudienceModel).Result; if (success) { JoinConference jc = new JoinConference(); jc.Show(this); pressButtonGreen(sender, e.RowIndex, e.ColumnIndex); } else { SetBalloonTip("You need to attend first", "You can't join the conference yet!"); notifyIcon1.Visible = true; notifyIcon1.ShowBalloonTip(30); } } else { SetBalloonTip("You need to attend first", "You can't join the conference yet!"); notifyIcon1.Visible = true; notifyIcon1.ShowBalloonTip(3000); } } if (senderGrid.CurrentCell.OwningColumn.Name.ToString().Equals("WithdrawButton") && inWithdraw == false) { ConferenceAudienceModel _conferenceAudienceModel = new ConferenceAudienceModel(); _conferenceAudienceModel.ConferenceId = (int)dataGridView1.Rows[e.RowIndex].Cells["ConferenceId"].Value; _conferenceAudienceModel.Participant = currentUser; _conferenceAudienceModel.ConferenceStatusId = 2; bool success = UpdateParticipant(_conferenceAudienceModel).Result; if (!success) { SetBalloonTip("Please attend first", "You have to attend before you can withdraw!"); notifyIcon1.Visible = true; notifyIcon1.ShowBalloonTip(3000); } inWithdraw = true; pressButtonGreen(sender, e.RowIndex, e.ColumnIndex); isAttend = true; pressButtonGreen(sender, e.RowIndex, e.ColumnIndex - 2); conferencesCurrentUserAttends.Clear(); conferencesCurrentUserAttends = GetConferenceAudience(currentUser); changeColorForSingleButton(e.RowIndex); changeColorForJoinButtons(); } } }
public IActionResult AddParticipant([FromBody] ConferenceAudienceModel obj) { _participantRepository.AddParticipant(obj); return(Ok()); }