public string UserAccessRegistrationEmail(int id) { var r = ""; var i = 0; var j = 0; try { Business.Interfaces.IUser iUser = new User(new RentEntities()); var obj = iUser.Select(id); const string subject = "Rental Payment - Registration Access"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Welcome " + obj.Name + ","); stringBuilder.Append("<p>Below is your login credentials for the Rent Payment Web Application</br> "); stringBuilder.Append("Email: <strong>" + obj.Email + "</strong>"); stringBuilder.Append("</br> "); stringBuilder.Append("Password: <strong>" + obj.UsersPasswords.FirstOrDefault().Password + "</strong>"); stringBuilder.Append("</br></br> "); stringBuilder.Append("You can login with your information here: " + Rent.Business.Properties.Settings.Default.Host + Properties.Settings.Default.Login + " to view your payment."); stringBuilder.Append("</br> "); // send email and check if UsersNotification.Email = true if ((bool)obj.UsersNotifications.FirstOrDefault().Email) { i = Rent.Common.Helper.Email.MlfusionSmtp(new MailAddress(obj.Email), subject, stringBuilder.ToString(), true); // insert into LogEmail Business.Services.LogEmail.Insert(stringBuilder, obj.Uid, obj.Email); } else { var sb = new StringBuilder(Notifications.EmailNotice + stringBuilder); // insert into LogEmail Business.Services.LogEmail.Insert(sb, obj.Uid, obj.Email); } r = i > 0 ? "Your login creditinals has been email to you." : "Sorry, the web service is down. Please try again later.";; } catch (Exception exception) { Business.Services.LogError.Insert(exception, id); r = "Error: " + exception.Message; } return(r); }
public string UserRegistrationEmail(int id) { var r = ""; var i = 0; var j = 0; try { Business.Interfaces.IUser iUser = new User(new RentEntities()); var obj = iUser.Select(id); //var accessCode = Rent.Common.Helper.Generator.AccessCode(); //// insert into userAccess //Business.Interfaces.IUserAccess iAccess = new UserAcess(); //var result = iAccess.Insert(accessCode, id); //if (result != null) // return result; const string subject = "Rental Payment - Registration Email"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Welcome " + obj.Name + ","); stringBuilder.Append("<p>Below is your access code for the Rent Payment Web Application</br> "); stringBuilder.Append("Access Code: <strong>" + obj.UsersAccesses.FirstOrDefault().AccessCode + "</strong>"); stringBuilder.Append("</br> "); stringBuilder.Append("</br></br> "); stringBuilder.Append("You can login with your information here: " + Rent.Business.Properties.Settings.Default.Host + " to view your account."); stringBuilder.Append("</br> "); // send email and check if UsersNotification.Email = true if ((bool)obj.UsersNotifications.FirstOrDefault().Email) { i = Rent.Common.Helper.Email.MlfusionSmtp(new MailAddress(obj.Email), subject, stringBuilder.ToString(), true); // insert into LogEmail Business.Services.LogEmail.Insert(stringBuilder, obj.Uid, obj.Email); } else { var sb = new StringBuilder(Notifications.EmailNotice + stringBuilder); // insert into LogEmail Business.Services.LogEmail.Insert(sb, obj.Uid, obj.Email); } // send text message if (obj.Phone != null) { foreach (var source in Rent.Common.Helper.Carriers.SelectMobileCarriers(obj.Phone)) { //check if UsersNotification.Phone = true if ((bool)obj.UsersNotifications.FirstOrDefault().Phone) { i = +Rent.Common.Helper.Email.MlfusionSmtp(new MailAddress(source), subject, stringBuilder.ToString(), false); // insert into LogEmail Business.Services.LogEmail.Insert(stringBuilder, obj.Uid, source); } else { var sb = new StringBuilder(Notifications.PhoneNotice + stringBuilder); // insert into LogEmail Business.Services.LogEmail.Insert(sb, obj.Uid, source); } } } r = i > 0 ? "Registration email send successfully." : obj.UsersNotifications.FirstOrDefault().Phone == false && obj.UsersNotifications.FirstOrDefault().Email == false ? "Notification settings are turned off." : "Sorry, the web service is down. Please try again later."; } catch (Exception exception) { Business.Services.LogError.Insert(exception, id); r = "Error: " + exception.Message; } return(r); }