public MockCharityRepository() { for (int i = 0; i < 10; i++) { var charity = new CharityRequirement(); charity.CharityRequirementId = i; charity.CharityName = "Charity " + i; charity.BackgroundInformation = "Some background information"; charityList.Add(charity); } }
public ActionResult SignUp(CharityRequirement charity, FormCollection form) { var infrastructure = SelectedTechnologies(form, "Infrastructure."); var support = SelectedTechnologies(form,"Support."); Validate(charity, infrastructure, support); if (ModelState.IsValid) { var charityRepository = new CharityRepository(); charityRepository.Register(charity, infrastructure, support); charityRepository.Save(); return View("ThankYou"); } return View("Proposal", new CharitySignUpViewModel(charity)); }
public void Register(CharityRequirement charity, IList<Technology> infrastructure, IList<Technology> support) { foreach (var inf in infrastructure) { var charityInfrastructure = new CharityRequirementTechnologiesUsed { CharityRequirement = charity, CharityRequirementId = charity.CharityRequirementId, TechnologyId = inf.TechnologyID }; } foreach (var supp in support) { var charitySupport = new CharityRequirementSupportSkill { CharityRequirement = charity, TechnologyId = supp.TechnologyID, CharityRequirementId = charity.CharityRequirementId }; } _datacontext.CharityRequirements.InsertOnSubmit(charity); }
partial void DeleteCharityRequirement(CharityRequirement instance);
partial void UpdateCharityRequirement(CharityRequirement instance);
partial void InsertCharityRequirement(CharityRequirement instance);
private void Validate(CharityRequirement charity, List<Technology> infrastructure, List<Technology> support) { if (String.IsNullOrEmpty(charity.CharityName)) ModelState.AddModelError("CharityName", "Charity Name is required"); if (!String.IsNullOrEmpty(charity.CharityName)) if (charity.CharityName.Length > 100) ModelState.AddModelError("CharityName", "Charity Name cannot exceed 100 characters"); if (String.IsNullOrEmpty(charity.BackgroundInformation)) ModelState.AddModelError("BackgroundInformation", "Background Information is required"); if (!String.IsNullOrEmpty(charity.BackgroundInformation)) if (charity.BackgroundInformation.Length > 4000) ModelState.AddModelError("BackgroundInformation", "Background Information cannot exceed 4000 characters"); if (!String.IsNullOrEmpty(charity.OtherInfrastructure)) if (charity.OtherInfrastructure.Length > 1000) ModelState.AddModelError("OtherInfrastructure", "Additional Infrastructure cannot exceed 1000 characters"); if (!String.IsNullOrEmpty(charity.OtherSupportSkills)) if (charity.OtherSupportSkills.Length > 1000) ModelState.AddModelError("OtherSupportSkills", "Additional Support Skills cannot exceed 1000 characters"); }
private void Validate(CharityRequirement charity, List<Technology> infrastructure, List<Technology> support) { if (String.IsNullOrEmpty(charity.CharityName)) ModelState.AddModelError("CharityName", "Charity Name is required"); if (!String.IsNullOrEmpty(charity.CharityName)) { if (charity.CharityName.Length > 100) ModelState.AddModelError("CharityName", "Charity Name cannot exceed 100 characters"); } if (String.IsNullOrEmpty(charity.Email)) ModelState.AddModelError("Email", "Email must be supplied"); if (!String.IsNullOrEmpty(charity.Email)) { if (charity.Email.Length > 255) ModelState.AddModelError("Email", "Email cannot exceed 255 characters"); } if (String.IsNullOrEmpty(charity.PhoneNumber)) ModelState.AddModelError("PhoneNumber", "Phone number must be provided"); if (!String.IsNullOrEmpty(charity.PhoneNumber)) { if (charity.PhoneNumber.Length > 50) ModelState.AddModelError("PhoneNumber", "Phone number cannot exceed 50 characters"); } if (String.IsNullOrEmpty(charity.BackgroundInformation)) ModelState.AddModelError("BackgroundInformation", "Background Information is required"); if (!String.IsNullOrEmpty(charity.BackgroundInformation)) { if (charity.BackgroundInformation.Length > 4000) ModelState.AddModelError("BackgroundInformation", "Background Information cannot exceed 4000 characters"); } if (!String.IsNullOrEmpty(charity.OtherInfrastructure)) { if (charity.OtherInfrastructure.Length > 1000) ModelState.AddModelError("OtherInfrastructure", "Additional Infrastructure cannot exceed 1000 characters"); } if (!String.IsNullOrEmpty(charity.OtherSupportSkills)) { if (charity.OtherSupportSkills.Length > 1000) ModelState.AddModelError("OtherSupportSkills", "Additional Support Skills cannot exceed 1000 characters"); } }
public void Register(CharityRequirement charity) { Register(charity, new List<Technology>(), new List<Technology>()); }
public void Register(CharityRequirement charity, IList<Technology> infrastructure, IList<Technology> support) { }
private void Validate(CharityRequirement charity, List<Technology> infrastructure, List<Technology> support) { if (String.IsNullOrEmpty(charity.PhoneNumber)) ModelState.AddModelError("PhoneNumber", "PhoneNumber is required"); else { if (charity.PhoneNumber.Length > 15) ModelState.AddModelError("PhoneNumber", "Phone Number cannot exceed 15 characters"); } if (String.IsNullOrEmpty(charity.ContactName)) ModelState.AddModelError("ContactName", "Contact Name is required"); else { if (charity.ContactName.Length > 50) ModelState.AddModelError("ContactName", "Contact Name cannot exceed 50 characters"); } if (String.IsNullOrEmpty(charity.CharityName)) ModelState.AddModelError("CharityName", "Charity Name is required"); else { if (charity.CharityName.Length > 100) ModelState.AddModelError("CharityName", "Charity Name cannot exceed 100 characters"); } if (String.IsNullOrEmpty(charity.BackgroundInformation)) ModelState.AddModelError("BackgroundInformation", "Charity Information is required"); else { if (charity.BackgroundInformation.Length > 4000) ModelState.AddModelError("BackgroundInformation", "Background Information cannot exceed 4000 characters"); } if (String.IsNullOrEmpty(charity.Email)) ModelState.AddModelError("Email", "Email Address is required"); else { if (charity.Email.Length > 256) ModelState.AddModelError("Email", "Email cannot exceed 256 characters"); } if(!String.IsNullOrEmpty(charity.CallInstruction) && charity.CallInstruction.Length > 1000) ModelState.AddModelError("CallInstruction", "Best Time to Contact Information cannot exceed 1000 characters"); if (!String.IsNullOrEmpty(charity.OtherInfrastructure) && charity.OtherInfrastructure.Length > 1000) ModelState.AddModelError("OtherInfrastructure", "Additional Infrastructure cannot exceed 1000 characters"); if (!string.IsNullOrEmpty(charity.OtherSupportSkills) && charity.OtherSupportSkills.Length > 1000) ModelState.AddModelError("OtherSupportSkills", "Additional Support Skills cannot exceed 1000 characters"); }