/// <summary> /// Register a speaker /// </summary> /// <returns>speakerID</returns> public int?Register(IRepository repository) { //lets init some vars int? speakerId = null; bool good = false; bool appr = false; //var nt = new List<string> {"MVC4", "Node.js", "CouchDB", "KendoUI", "Dapper", "Angular"}; var ot = new List <string>() { "Cobol", "Punch Cards", "Commodore", "VBScript" }; //DEFECT #5274 DA 12/10/2012 //We weren't filtering out the prodigy domain so I added it. var domains = new List <string>() { "aol.com", "hotmail.com", "prodigy.com", "CompuServe.com" }; if (!string.IsNullOrWhiteSpace(FirstName)) { if (!string.IsNullOrWhiteSpace(LastName)) { if (!string.IsNullOrWhiteSpace(Email)) { //put list of employers in array var emps = new List <string>() { "Microsoft", "Google", "Fog Creek Software", "37Signals" }; //DFCT #838 Jimmy //We're now requiring 3 certifications so I changed the hard coded number. Boy, programming is hard. good = ((Exp > 10 || HasBlog || Certifications.Count() > 3 || emps.Contains(Employer))); if (!good) { //need to get just the domain from the email string emailDomain = Email.Split('@').Last(); if (!domains.Contains(emailDomain) && (!(Browser.Name == WebBrowser.BrowserName.InternetExplorer && Browser.MajorVersion < 9))) { good = true; } } if (good) { //DEFECT #5013 CO 1/12/2012 //We weren't requiring at least one session if (Sessions.Count() != 0) { foreach (var session in Sessions) { //foreach (var tech in nt) //{ // if (session.Title.Contains(tech)) // { // session.Approved = true; // break; // } //} foreach (var tech in ot) { if (session.Title.Contains(tech) || session.Description.Contains(tech)) { session.Approved = false; break; } else { session.Approved = true; appr = true; } } } } else { throw new ArgumentException("Can't register speaker with no sessions to present."); } if (appr) { //if we got this far, the speaker is approved //let's go ahead and register him/her now. //First, let's calculate the registration fee. //More experienced speakers pay a lower fee. if (Exp <= 1) { RegistrationFee = 500; } else if (Exp >= 2 && Exp <= 3) { RegistrationFee = 250; } else if (Exp >= 4 && Exp <= 5) { RegistrationFee = 100; } else if (Exp >= 6 && Exp <= 9) { RegistrationFee = 50; } else { RegistrationFee = 0; } //Now, save the speaker and sessions to the db. try { speakerId = repository.SaveSpeaker(this); } catch (Exception e) { //in case the db call fails } } else { throw new NoSessionsApprovedException("No sessions approved."); } } else { throw new SpeakerDoesntMeetRequirementsException("Speaker doesn't meet our abitrary and capricious standards."); } } else { throw new ArgumentNullException("Email is required."); } } else { throw new ArgumentNullException("Last name is required."); } } else { throw new ArgumentNullException("First Name is required"); } //if we got this far, the speaker is registered. return(speakerId); }
public bool ValidarDatos(List <string> domains) { //lets init some vars bool IsGood = false; bool CondicionAppr = false; var ListOt = new List <string>() { "Cobol", "Punch Cards", "Commodore", "VBScript" }; bool Validacion = false; if (ValidarCampos()) { //put list of employers in array var employers = new List <string>() { "Microsoft", "Google", "Fog Creek Software", "37Signals" }; //We're now requiring 3 certifications so I changed the hard coded number. Boy, programming is hard. IsGood = ((Exp > intDiez || HasBlog || Certifications.Count() > intTres || employers.Contains(Employer))); if (!IsGood) { //need to get just the domain from the email string emailDomain = Email.Split('@').Last(); IsGood = !domains.Contains(emailDomain) && (!(Browser.Name == WebBrowser.BrowserName.InternetExplorer && Browser.MajorVersion < intNueve)); } if (IsGood) { CondicionAppr = ValidaCondicionAppr(ListOt); var validarRagoUno = new List <int>() { 2, 3 }; var validarRagoDos = new List <int>() { 4, 5 }; var validarRagoTres = new List <int>() { 6, 7, 8, 9 }; if (CondicionAppr) { //if we got this far, the speaker is approved //let's go ahead and register him/her now. //First, let's calculate the registration fee. //More experienced speakers pay a lower fee. RegistrationFee = intCero; if (Exp <= intUno) { RegistrationFee = intQuinientos; } if (validarRagoUno.Contains(Convert.ToInt32(Exp))) { RegistrationFee = intDocientosCincuenta; } if (validarRagoDos.Contains(Convert.ToInt32(Exp))) { RegistrationFee = intCien; } if (validarRagoTres.Contains(Convert.ToInt32(Exp))) { RegistrationFee = intCincuenta; } Validacion = CondicionAppr; } else { throw new NoSessionsApprovedException("No sessions approved."); } } else { throw new SpeakerDoesntMeetRequirementsException("Speaker doesn't meet our abitrary and capricious standards."); } } return(Validacion); }