Esempio n. 1
0
        public async Task <IActionResult> PutCandidate(int id, Candidate candidate)
        {
            if (id != candidate.CandidateId)
            {
                return(BadRequest());
            }

            _context.Entry(candidate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CandidateExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutJobOffer(int id, JobOffer jobOffer)
        {
            if (id != jobOffer.JobOfferId)
            {
                return(BadRequest());
            }

            _context.Entry(jobOffer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!JobOfferExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("Name,Risk,MinimumSalary,MaximumSalary,Status,ID")] JobPosition jobPosition)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jobPosition);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobPosition));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("DocumentNumber,Name,InitialDate,Department,JobPositionID,Salary,Status")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["JobPositionID"] = new SelectList(_context.JobPositions, "ID", "Name", employee.JobPositionID);
            return(View(employee));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("DocumentNumber,Name,JobPositionID,Department,SalaryWished,Languages,RecommendedBy,ID")] Candidate candidate)
        {
            if (!Validations.ValidateDocumentNumber(candidate.DocumentNumber))
            {
                ViewBag.Error             = "El documento indicado es invalido!";
                ViewData["JobPositionID"] = new SelectList(_context.JobPositions, "ID", "Name", candidate.JobPositionID);
                return(View(candidate));
            }
            if (_context.Candidates.Any(x => x.DocumentNumber == candidate.DocumentNumber))
            {
                ViewBag.Error             = "Este candidato ya se encuentra registrado!";
                ViewData["JobPositionID"] = new SelectList(_context.JobPositions, "ID", "Name", candidate.JobPositionID);
                return(View(candidate));
            }
            if (_context.Employees.Any(x => x.DocumentNumber == candidate.DocumentNumber && x.Status))
            {
                ViewBag.Error             = "Este candidato ya existe como empleado!";
                ViewData["JobPositionID"] = new SelectList(_context.JobPositions, "ID", "Name", candidate.JobPositionID);
                return(View(candidate));
            }
            var jobPosition = _context.JobPositions.Where(x => x.ID == candidate.JobPositionID).FirstOrDefault();

            if (candidate.SalaryWished > jobPosition.MaximumSalary)
            {
                ViewBag.Error             = "El salario deseado por el candidato no puede ser mayor al máximo ofertado para la vacante.";
                ViewData["JobPositionID"] = new SelectList(_context.JobPositions, "ID", "Name", candidate.JobPositionID);
                return(View(candidate));
            }
            if (ModelState.IsValid)
            {
                _context.Add(candidate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["JobPositionID"] = new SelectList(_context.JobPositions, "ID", "Name", candidate.JobPositionID);
            return(View(candidate));
        }