示例#1
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = jobData.Employers.Find(newJobViewModel.EmployerID),
                    Location       = jobData.Locations.Find(newJobViewModel.LocationID),
                    CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID),
                    PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID)
                };

                jobData.Jobs.Add(newJob);

                return(Redirect(string.Format("/Job?id={0}", newJob.ID)));
            }

            return(View(newJobViewModel));
        }
示例#2
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            //This does the same thing as the ModelState.IsValid but better
            //if (newJobViewModel.Name == null)
            //{
            //    return View(newJobViewModel);
            //}

            if (ModelState.IsValid)
            {
                Employer       newEmployer         = jobData.Employers.Find(newJobViewModel.EmployerID);
                Location       foundLocation       = jobData.Locations.Find(newJobViewModel.Location);
                CoreCompetency foundCoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetency);
                PositionType   foundPositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionType);

                Job jerb = new Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = newEmployer,
                    Location       = foundLocation,
                    CoreCompetency = foundCoreCompetency,
                    PositionType   = foundPositionType
                };

                jobData.Jobs.Add(jerb);
                int jerbId = jerb.ID;

                return(Redirect($"/Job?id={jerbId}"));
            }


            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.

            return(View(newJobViewModel));
        }
示例#3
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            int emplid = newJobViewModel.EmployerID;
            int locid  = newJobViewModel.LocationID;
            int compid = newJobViewModel.CoreCompetencyID;
            int posid  = newJobViewModel.PositionTypeID;

            if (ModelState.IsValid)
            {
                /*Job newjob = new Job();
                 * newjob.Name = newJobViewModel.Name;
                 * newjob.Employer = jobData.Employers.Find(emplid);
                 * newjob.Location = newJobViewModel.Location;
                 * newjob.CoreCompetency = newJobViewModel.CoreCompetency;
                 * newjob.PositionType = newJobViewModel.PositionType;
                 */

                Job newjob = new Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = jobData.Employers.Find(emplid),
                    Location       = jobData.Locations.Find(locid),
                    CoreCompetency = jobData.CoreCompetencies.Find(compid),
                    PositionType   = jobData.PositionTypes.Find(posid)
                };

                jobData.Jobs.Add(newjob);
                //int newid = newjob.ID;
                return(Redirect("/job?id=" + newjob.ID));/*use redirect not view*/
            }

            return(View(newJobViewModel));

            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.
        }
示例#4
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.
            if (ModelState.IsValid)
            {
                Job newJob = new Job();

                newJob.Name = newJobViewModel.Name;

                newJob.Employer       = jobData.Employers.Find(newJobViewModel.EmployerID);
                newJob.Location       = jobData.Locations.Find(newJobViewModel.LocationID);
                newJob.CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID);
                newJob.PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID);

                jobData.Jobs.Add(newJob);


                //return Redirect("/Job?id=" + newJob.ID.ToString());
                return(Redirect("/Job/index?id=" + newJob.ID.ToString()));
            }
            return(View(newJobViewModel));
        }
示例#5
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    // set properties within braces
                    Name           = newJobViewModel.Name,
                    Employer       = jobData.Employers.Find(newJobViewModel.EmployerID),
                    Location       = jobData.Locations.Find(newJobViewModel.Location),
                    CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetency),
                    PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionType)
                };

                jobData.Jobs.Add(newJob);

                Response.Redirect("/Job?id=" + newJob.ID);
            }

            return(View(newJobViewModel));
        }
示例#6
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.
            if (ModelState.IsValid)
            {
                Job newJob = new Job();
                newJob.Name           = newJobViewModel.Name; // Because it is just a new string, nothing to compare to
                newJob.Employer       = jobData.Employers.Find(newJobViewModel.EmployerID);
                newJob.Location       = jobData.Locations.Find(newJobViewModel.LocationID);
                newJob.CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID);
                newJob.PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionID);

                jobData.Jobs.Add(newJob);
                // TODO 8 - Make sure this version of this works once I finish making 7s work.
                //return RedirectToAction("Index", new { id = newJob.ID });
                return(Redirect(string.Format("/Job?id={0}", newJob.ID)));
            }
            else
            {
                return(View(newJobViewModel));
            }
        }
示例#7
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = jobData.Employers.Find(newJobViewModel.EmployerID), //possible query into the data using the id. I need id
                    Location       = jobData.Locations.Find(newJobViewModel.LocationID),
                    CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID),
                    PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID),
                };

                jobData.Jobs.Add(newJob);

                //REDIRECT
                return(Redirect(string.Format("/Job?={0}", newJob.ID)));
            }
            //if model is not valid, go back to the new job form.
            return(View("New", newJobViewModel));
        }
示例#8
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.


            //this part from nick
            //validate first


            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = jobData.Employers.Find(newJobViewModel.EmployerID),
                    Location       = jobData.Locations.Find(newJobViewModel.LocationID),
                    CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID),
                    PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID)
                };

                jobData.Jobs.Add(newJob);
                return(Redirect(String.Format("/job?id={0}", newJob.ID)));
            }

            //JobData data = JobData.GetInstance();
            //Job newJob = new Job();
            //newJob.Employer = data.Employers.Find(newJobViewModel.EmployerID.ID);

            //populate rest of newJob properties by looking up objects in JobData intance
            //end of nick part

            //newJob.CoreCompetency = data.CoreCompetencies.AddUnique(newJobViewModel.CoreCompetency);
            return(View(newJobViewModel));
        }
示例#9
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // TODO #6 DONE - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.

            if (ModelState.IsValid)
            {
                //make job from new job
                Job newJob = new Job {
                    //so fundamentally enums are just ints right? and we have ints so..
                    Name           = newJobViewModel.Name,
                    CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID),
                    Employer       = jobData.Employers.Find(newJobViewModel.EmployerID),//WINNER!!!!!!!!!!!!!!!!!
                    Location       = jobData.Locations.Find(newJobViewModel.LocationID),
                    PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID)
                };
                jobData.Jobs.Add(newJob);

                return(Redirect($"/job?id={newJob.ID}"));
            }

            return(View(newJobViewModel));
        }
示例#10
0
        public IActionResult New()
        {
            NewJobViewModel newJobViewModel = new NewJobViewModel();

            return(View(newJobViewModel));
        }
示例#11
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = jobData.Employers.Find(newJobViewModel.EmployerID),
                    Location       = jobData.Locations.Find(newJobViewModel.City),
                    CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.Skill),
                    PositionType   = jobData.PositionTypes.Find(newJobViewModel.Position)
                };

                /*
                 * Employer newEmp  = new Employer();
                 * List<Employer> emp = jobData.Employers.ToList();
                 * foreach (Employer x in emp)
                 * {
                 *  if (x.ID == newJobViewModel.EmployerID)
                 *  {
                 *      newEmp = x;
                 *  }
                 * }
                 * CoreCompetency newCore = new CoreCompetency();
                 * List<CoreCompetency> core = jobData.CoreCompetencies.ToList();
                 * foreach (CoreCompetency x in core)
                 * {
                 *  if (x.ID == newJobViewModel.Skill)
                 *  {
                 *      newCore = x;
                 *  }
                 * }
                 * Location newLoca = new Location();
                 * List<Location> loca = jobData.Locations.ToList();
                 * foreach (Location x in loca)
                 * {
                 *  if (x.ID == newJobViewModel.City)
                 *  {
                 *      newLoca = x;
                 *  }
                 * }
                 * PositionType newPo = new PositionType();
                 * List<PositionType> po = jobData.PositionTypes.ToList();
                 * foreach (PositionType x in po)
                 * {
                 *  if (x.ID == newJobViewModel.Position)
                 *  {
                 *      newPo = x;
                 *  }
                 * }
                 *
                 * Job newJob = new Job
                 * {
                 *  Name = newJobViewModel.Name,
                 *  CoreCompetency = newCore,
                 *  Employer = newEmp,
                 *  Location = newLoca,
                 *  PositionType = newPo,
                 * }; */
                jobData.Jobs.Add(newJob);

                return(Redirect("/Job?Id=" + newJob.ID));
            }
            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.

            return(View(newJobViewModel));
        }