public ActionResult Mail(AdminEmail model, List <HttpPostedFileBase> attachments) { using (MailMessage mm = new MailMessage(model.Email, model.To)) { mm.Subject = model.Subject; mm.Body = model.Body; foreach (HttpPostedFileBase attachment in attachments) { if (attachment != null) { string fileName = Path.GetFileName(attachment.FileName); mm.Attachments.Add(new Attachment(attachment.InputStream, fileName)); } } mm.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(model.Email, model.Password); smtp.UseDefaultCredentials = false; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); ViewBag.Message = "Email sent."; } return(View()); }
public RequestResult <IEnumerable <AdminEmail> > GetEmails() { int pageIndex = 0; DBResult <List <Email> > dbEmail = this.emailDelegate.GetEmails(pageIndex, this.maxEmails); IEnumerable <MessagingVerification> emailInvites = this.emailInviteDelegate.GetAllEmail(); RequestResult <IEnumerable <AdminEmail> > result = new RequestResult <IEnumerable <AdminEmail> >() { ResourcePayload = dbEmail.Payload.Select(e => { MessagingVerification emailInvite = emailInvites.First(ei => e.To !.Equals(ei.Email?.To, System.StringComparison.CurrentCultureIgnoreCase)); string inviteStatus = GetEmailInviteStatus(emailInvite); return(AdminEmail.CreateFromDbModel(e, inviteStatus)); }), PageIndex = pageIndex, PageSize = this.maxEmails, TotalResultCount = dbEmail.Payload.Count, ResultStatus = dbEmail.Status == DBStatusCode.Read ? ResultType.Success : ResultType.Error, ResultError = dbEmail.Status == DBStatusCode.Read ? null : new RequestResultError() { ResultMessage = dbEmail.Message, ErrorCode = ErrorTranslator.ServiceError(ErrorType.CommunicationInternal, ServiceType.Database) }, }; return(result); }
protected void CounselingsGrid_PageIndexChanging(Object sender, GridViewPageEventArgs e) { CounselingsGrid.PageIndex = e.NewPageIndex; DataTable counselings = AdminEmail.GetCounselings(); CounselingsGrid.DataSource = counselings; CounselingsGrid.DataBind(); }
protected void btnUpdate_Click(object sender, EventArgs e) { AdminEmail.UpdateCounselingStatus(_counselingID, cbProcessed.Checked); _counselingID = int.Parse(hdlCounselingID.Value); counseling = AdminEmail.GetCounseling(_counselingID); BindData(); }
private void BtnLogin_Click(object sender, EventArgs e) { string email = txtUsername.Text; string password = txtPassword.Text; if (email != null && password != null) { AdminEmail selectAdmin = db.AdminEmails.FirstOrDefault(ad => ad.AdminEmail1 == email); if (selectAdmin != null) { if (selectAdmin.AdminPassword == password) { AdminDashboard Adm = new AdminDashboard(); Adm.ShowDialog(); } } else { Worker selectWorker = db.Workers.FirstOrDefault(wr => wr.Username == email); if (selectWorker != null) { if (selectWorker.Password != password) { WorkersDashboard wd = new WorkersDashboard(); wd.ShowDialog(); } else { lblError.Text = "Şifrə yanlışdır !"; lblError.Visible = true; lblError0.Text = "Şifrə yanlışdır !"; lblError.Visible = true; } } else { lblError.Text = "Email yanlışdır !"; lblError.Visible = true; lblError0.Text = "Email yanlışdır !"; lblError.Visible = true; } } } else { lblError.Text = "Zəhmət olmasa boşluqları doldurun !"; lblError.Visible = true; lblError0.Text = "Zəhmət olmasa boşluqları doldurun !"; lblError.Visible = true; } }
private void BindCounselings() { try { DataTable counselings = AdminEmail.GetCounselings(); CounselingsGrid.DataSource = counselings; CounselingsGrid.DataBind(); //logger.Debug("contents - " + contents.Rows.Count); } catch (Exception ex) { logger.Error("BindContents Exception - " + ex.Message); } }
public HttpResponseMessage ChangePassword(AdminEmail mail) { proc_OtpCheckadmin_Result res = null; res = entities.proc_OtpCheckadmin(mail.email_id, mail.otp).FirstOrDefault(); if (res == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "OTP not matched Please enter correct otp")); } else { return(Request.CreateResponse <proc_OtpCheckadmin_Result>(res)); } }
protected void CounselingsGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int counselingID = int.Parse(CounselingsGrid.Rows[e.RowIndex].Cells[1].Text); bool deleted = AdminEmail.DeleteCounseling(counselingID); if (deleted) { lblMessage.Text = "Sucessfully deleted"; } else { lblMessage.Text = "Deletion error. Please try again."; } BindCounselings(); }
public static async Task AddAdminUser(ApplicationDbContext context, UserManager <ApplicationUser> userManager) { if (await context.Users.AnyAsync()) { return; } ApplicationUser user = new ApplicationUser() { UserName = AdminEmail, NormalizedUserName = AdminEmail.ToUpper(), Email = AdminEmail, NormalizedEmail = AdminEmail.ToUpper(), EmailConfirmed = true, ConcurrencyStamp = Guid.NewGuid().ToString() }; await userManager.CreateAsync(user, AdminPassword); }
protected void Page_Load(object sender, EventArgs e) { Master.SetSectionName("Email Counselings"); Master.SetSubSectionName("Counseling Details"); if (Request.QueryString["CounselingID"] != null) { int.TryParse(Request.QueryString["CounselingID"].ToString(), out _counselingID); } if (!IsPostBack) { if (_counselingID > 0) { counseling = AdminEmail.GetCounseling(_counselingID); BindData(); } } }
public async Task SendEmail(AdminEmail email) { // string email = email_id.ToString(); var message = new MailMessage(); message.To.Add(new MailAddress(email.email_id)); message.From = new MailAddress("RDNS Bank <*****@*****.**>"); //message.Bcc.Add(new MailAddress("Amit Mohanty <*****@*****.**>")); message.Subject = "the otp to reset your password"; Random rnd = new Random(); int otp = rnd.Next(100000, 999999); message.Body = otp.ToString(); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { await smtp.SendMailAsync(message); await Task.FromResult(0); entities.proc_InsertintotblwithEmailadmin(email.email_id, otp); } }
//Admin signup public static string AdminSignUpDB(AdminInfo adminDetails) { AdminFname = adminDetails.AdminFName; AdminLname = adminDetails.AdminLName; AdminEmail = adminDetails.AdminEmail; Code = PasswordCreation.GenerateCode(); Hashpwd = HashPassword.ComputeSha256Hash(Code); DateTime current = DateTime.Now; SqlCommand cmd = new SqlCommand(); try { if (AdminFname == "" || AdminLname == "") { throw new Exception(); } if (AdminEmail == "") { throw new Exception(); } if (!AdminEmail.Contains("@gmail.com")) { throw new Exception(); } cmd.Parameters.Clear(); cmd.Connection = con; cmd.CommandText = @"INSERT INTO Admin(AdminFirstName, AdminLastName, AdminEmail, AdminToken, Created_at) VALUES(@fname, @lname, @email, @token, @timestamp)"; cmd.Parameters.AddWithValue("@fname", AdminFname); cmd.Parameters.AddWithValue("@lname", AdminLname); cmd.Parameters.AddWithValue("@email", AdminEmail); cmd.Parameters.AddWithValue("@token", Hashpwd); cmd.Parameters.AddWithValue("@timestamp", current); con.Open(); cmd.ExecuteNonQuery(); con.Close(); try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(AdminEmail); mail.Subject = "Admin Info"; mail.Body = $"Your Access code: {Code} \n Use email and access code to login"; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", Pwd); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } catch (Exception ex) { return($"Failed from inner catch msg sending why => {ex.Message}"); } return($"Sucessfull Signup"); } catch (Exception ex) { return($"Failed from catch why => {ex.Message}"); } }
void ReleaseDesignerOutlets() { if (AdminEmail != null) { AdminEmail.Dispose(); AdminEmail = null; } if (CloseButton != null) { CloseButton.Dispose(); CloseButton = null; } if (ExpiresAfter != null) { ExpiresAfter.Dispose(); ExpiresAfter = null; } if (MinimumTTL != null) { MinimumTTL.Dispose(); MinimumTTL = null; } if (PrimaryServerName != null) { PrimaryServerName.Dispose(); PrimaryServerName = null; } if (RefreshInterval != null) { RefreshInterval.Dispose(); RefreshInterval = null; } if (RetryInterval != null) { RetryInterval.Dispose(); RetryInterval = null; } if (SerialNumber != null) { SerialNumber.Dispose(); SerialNumber = null; } if (UpdateButton != null) { UpdateButton.Dispose(); UpdateButton = null; } if (ZoneType != null) { ZoneType.Dispose(); ZoneType = null; } }