public void SignUp(IUser user, UserType userType) { if (new VerifyString().ArePropertiesNull(user)) { throw new Exception("אנא מלא את כל השדות"); } if (BL.GetAllAdmins(x => x.MailAddress == user.GetMailAddress()).Count != 0 || BL.GetAllVolunteers(x => x.MailAddress == user.GetMailAddress()).Count != 0) { throw new Exception("המשתמש כבר קיים במערכת"); } if (!new VerifyAddress().IsValidAddress(user.GetAddress())) { throw new Exception("הכתובת שהזנת לא קיימת"); } double[] location = new Tools.VerifyAddress().GetLocation(user.GetAddress()); user.SetAddress(location[0], location[1]); if (userType == UserType.Admin) { BL.AddAdmin(user as Admin); } else { BL.AddVolunteer(user as Volunteer); } // send mail string to = user.GetMailAddress(); string subject = "ברוך הבא לעמותת יד ביד"; string body = "שלום " + user.GetFirstName() + "," + "\n\n" + "הרשמתך נקלטה במערכת בהצלחה." + "\n\n" + "אנו שמחים שהצטרפת למשפחת יד ביד!" + "\n\n" + "הסיסמה למערכת היא: " + user.GetPassword(); Thread thread = new Thread(() => new MailSender().SendMail(to, subject, body)); thread.Start(); }
public void SignUp(Recipient recipient) { if (new Tools.VerifyString().ArePropertiesNull <Recipient>(recipient)) { throw new Exception("אנא מלא את כל השדות"); } if (BL.GetAllRecipients(x => x.MailAddress == recipient.MailAddress).Count != 0) { throw new Exception("המשתמש כבר קיים במערכת"); } if (!new Tools.VerifyAddress().IsValidAddress(recipient.Address)) { throw new Exception("הכתובת שהזנת לא קיימת"); } double[] location = new Tools.VerifyAddress().GetLocation(recipient.Address); recipient.Address.Lat = location[0]; recipient.Address.Lon = location[1]; BL.AddRecipient(recipient); }