Beispiel #1
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            JobOpening job = db.Job(id.Value);

            if (job == null)
            {
                return(HttpNotFound());
            }
            JobOpeningViewModel jobVM = MapJobOpening(job);

            //Moved here in order to prevent multiple concurrent read actions
            jobVM.Applicants = job.GetAllApplicants().Select(a => new ApplicantViewModel()
            {
                Email          = a.Email,
                DepartmentName = a.GetDepartmentName(),
                CVID           = a.GetMostRecentCVID()
            });
            jobVM.Messages = job.Messages
                             .Where(m => m.IsFirstMessage)
                             .Select(m => new MessageViewModel()
            {
                SenderName = m.Sender.UserName, RecipientName = m.Recipient.UserName, SendTime = m.SendTime, BodyContent = m.BodyContent
            });
            return(View(jobVM));
        }
Beispiel #2
0
        // GET: Jobs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            JobOpening job = db.Job(id.Value);

            if (job == null)
            {
                return(HttpNotFound());
            }
            //When editing, select only departments that user manages or the current department
            List <Department> departments = new List <Department>();

            departments.AddRange(db.GetManagedDepartmentsByUserName(User.Identity.Name));
            if (!departments.Contains(job.Department))
            {
                departments.Add(job.Department);
            }
            //Convert list of departents to a list of selectitem
            ViewBag.Departments = departments.Select(d => new SelectListItem()
            {
                Text = d.Name, Value = d.ID.ToString()
            });
            JobOpeningViewModel jobVM = MapJobOpening(job);

            return(View(jobVM));
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "ID,Title,Description,JobType,DepartmentID")] JobOpeningViewModel jobVM)
        {
            if (ModelState.IsValid)
            {
                JobOpening job = new JobOpening()
                {
                    Title = jobVM.Title, ID = jobVM.ID, Description = jobVM.Description, JobType = jobVM.JobType, Department = db.Department(jobVM.DepartmentID)
                };
                db.Add(job);
                return(RedirectToAction("Index"));
            }

            return(View(jobVM));
        }
Beispiel #4
0
 public ActionResult Edit([Bind(Include = "ID,Title,Description,JobType,DepartmentID")] JobOpeningViewModel jobVM)
 {
     if (ModelState.IsValid) //Refers to the model that has been bound by the modelbinder; in this case it is jobVM
     {
         JobOpening job = db.Job(jobVM.ID);
         job.JobType     = jobVM.JobType;
         job.Title       = jobVM.Title;
         job.Description = jobVM.Description;
         job.Department  = db.Department(jobVM.DepartmentID);
         db.Edit(job);
         return(RedirectToAction("Index"));
     }
     return(View(jobVM));
 }
        public ActionResult Edit(int id)
        {
            var jobOpening = _jobOpeningRepository.Get(id);

            var jobOpeningViewmodel = new JobOpeningViewModel
            {
                Id                     = jobOpening.Id,
                Title                  = jobOpening.Title,
                Description            = jobOpening.Description,
                OpeningStatus          = jobOpening.OpeningStatus,
                JobDescriptionFilePath = jobOpening.JobDescriptionPath,
                NoOfVacancies          = jobOpening.NoOfVacancies
            };

            return(View(jobOpeningViewmodel));
        }
        public ActionResult Edit(JobOpeningViewModel jobOpening)
        {
            if (ModelState.IsValid)
            {
                var selectedJobOpening = _jobOpeningRepository.Get(jobOpening.Id);

                selectedJobOpening.Title              = jobOpening.Title;
                selectedJobOpening.NoOfVacancies      = jobOpening.NoOfVacancies;
                selectedJobOpening.Description        = jobOpening.Description;
                selectedJobOpening.OpeningStatus      = jobOpening.OpeningStatus;
                selectedJobOpening.JobDescriptionPath = jobOpening.JobDescriptionFilePath;

                _jobOpeningRepository.Update(selectedJobOpening);
                _unitOfWork.Commit();

                return(RedirectToAction("Index"));
            }
            return(View(jobOpening));
        }
        public ActionResult Create(JobOpeningViewModel jobOpening)
        {
            if (ModelState.IsValid)
            {
                var newJobOpening = new JobOpening
                {
                    Title              = jobOpening.Title,
                    NoOfVacancies      = jobOpening.NoOfVacancies,
                    Description        = jobOpening.Description,
                    OpeningStatus      = jobOpening.OpeningStatus,
                    JobDescriptionPath = jobOpening.JobDescriptionFilePath
                };

                _jobOpeningRepository.Create(newJobOpening);
                _unitOfWork.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(jobOpening));
        }