public void InsertOrUpdate(CharityRequirement charityrequirement)
 {
     if (charityrequirement.CharityRequirementId == default(int)) {
         // New entity
         context.CharityRequirements.Add(charityrequirement);
     } else {
         // Existing entity
         context.Entry(charityrequirement).State = EntityState.Modified;
     }
 }
Exemple #2
0
        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)));
        }
    private void Construct(CharityRequirement charity)
    {
        if (charity == null)
        {
            CharityRequirement = new CharityRequirement();
        }
        else
        {
            CharityRequirement = charity;
        }

        var lookupRepository = new LookupRepository();

        var infrastructureTechnologies = lookupRepository.GetAllTechnologies();

        InfrastructureTechnologies = new SelectList(infrastructureTechnologies, "TechnologyID", "Description");
        SupportSkills = new SelectList(infrastructureTechnologies, "TechnologyID", "Description");
    }
        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");
                }
            }
        }
Exemple #6
0
        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);
        }
    private void Construct(CharityRequirement charity)
    {
        if (charity == null)
            CharityRequirement = new CharityRequirement();
        else
            CharityRequirement = charity;

        var lookupRepository = new LookupRepository();

        var infrastructureTechnologies = lookupRepository.GetAllTechnologies();
        InfrastructureTechnologies = new SelectList(infrastructureTechnologies, "TechnologyID", "Description");
        SupportSkills = new SelectList(infrastructureTechnologies, "TechnologyID", "Description");
    }
 public CharitySignUpViewModel(CharityRequirement charity)
 {
     Construct(charity);
 }
 public CharitySignUpViewModel(CharityRequirement charity)
 {
     Construct(charity);
 }
Exemple #10
0
 public void Register(CharityRequirement charity, IList <Technology> infrastructure, IList <Technology> support)
 {
 }
Exemple #11
0
 public void Register(CharityRequirement charity)
 {
     Register(charity, new List <Technology>(), new List <Technology>());
 }
 public CharityRequirementVM(CharityRequirement charityRequirement)
 {
     _charityRequirement = charityRequirement;
     StaffTechnologies = GetStaffTechnologies();
     ProjectTechnologies = GetProjectTechnologies();
 }
 public CharityRequirementVM()
 {
     _charityRequirement = new CharityRequirement();
     StaffTechnologies = GetStaffTechnologies();
     ProjectTechnologies = GetProjectTechnologies();
 }