Ejemplo n.º 1
0
        public ActionResult CreateAppliance(CreateApplianceModel data)
        {
            //Adding new appliance
            JobAppliance newAppliance = new JobAppliance();

            newAppliance.Name    = data.ApplianceData.Name;
            newAppliance.Comment = data.ApplianceData.Comment;
            newAppliance.UserId  = GetCurrentUser().UserId;

            if (!_appRepository.Create(newAppliance))
            {
                return(RedirectToAction("/Error/Index"));
            }

            _appRepository.Save();

            int newAppId = newAppliance.Id;

            //Adding abilities and ability set for new appliance
            foreach (Ability ability in data.ApplianceAbilities)
            {
                Ability newAbilities = new Ability();

                newAbilities.SkillId      = ability.SkillId;
                newAbilities.SkillLevelId = ability.SkillLevelId;

                if (!_abilRepository.Create(newAbilities))
                {
                    return(RedirectToAction("/Error/Index"));
                }

                _abilRepository.Save();

                int newAbilId = newAbilities.Id;

                AbilitySet newAbilitySet = new AbilitySet();

                newAbilitySet.ApplianceId = newAppliance.Id;
                newAbilitySet.AbilitiesId = newAbilities.Id;

                if (!_abilSetRepository.Create(newAbilitySet))
                {
                    return(RedirectToAction("/Error/Index"));
                }

                _abilSetRepository.Save();
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult CreateProfession(CreateProfessionModel dataModel)
        {
            Ability newAbilities = new Ability();

            newAbilities.SkillId      = dataModel.SkillId;
            newAbilities.SkillLevelId = dataModel.SkillLevelId;

            if (_abilRepository.Create(newAbilities))
            {
                _abilRepository.Save();
            }

            if (newAbilities.Id == 0)
            {
                //TODO Repalce with error page
                return(Redirect("/Home/Index"));
            }

            AbilitySet newAbilSet = new AbilitySet();

            newAbilSet.AbilitiesId = newAbilities.Id;
            newAbilSet.ApplianceId = 0;

            if (_abilSetRepository.Create(newAbilSet))
            {
                _abilSetRepository.Save();
            }

            if (newAbilSet.Id == 0)
            {
                //TODO Repalce with error page
                return(Redirect("/Home/Index"));
            }

            Profession newProfession = new Profession();

            newProfession.Name         = dataModel.ProfessionData.Name;
            newProfession.AbilitySetId = newAbilSet.Id;

            if (_profRepo.Create(newProfession))
            {
                _profRepo.Save();
            }

            return(Redirect("/CreateVacancy/Index"));
        }