Example #1
0
        public async Task <IActionResult> Create(IFormFile resume, [FromForm] UpdateCandidateModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(GetModelStateErrors(ModelState)));
                }

                if (resume == null)
                {
                    return(Ok(WebApiResponses <CandidateModel> .ErrorOccured("No resume found")));
                }

                var response = await _candidateService.CreateCandidate(resume.OpenReadStream(), resume.ContentType, model);

                if (response.ResponseCode != ResponseCode.Ok)
                {
                    return(Ok(WebApiResponses <CandidateModel> .ErrorOccured(response.Message)));
                }
                return(Ok(WebApiResponses <CandidateModel> .Successful(response.ResponseData)));
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(Ok(WebApiResponses <CandidateModel> .ErrorOccured(ex.Message)));
            }
        }
Example #2
0
        public async Task <IActionResult> CreateNewCandidate(CreateNewCandidateRequest request)
        {
            var newPersonName    = PersonName.Create(request.firstName, request.lastName);
            var newCandidate     = new Candidate(newPersonName);
            var createdCandidate = await _candidateService.CreateCandidate(newCandidate);

            return(CreatedAtAction(nameof(GetCandidateById), new { id = createdCandidate.Id }, createdCandidate));
        }
        public IActionResult Post([FromBody] ReqCandidateVM req)
        {
            var result = service.CreateCandidate(req);

            return(Ok(new SuccessResponse <string>
            {
                Code = 200,
                Data = result
            }));
        }
Example #4
0
 public ActionResult Edit([Bind(Include = "CandidateID,UserName,FirstName,LastName,Email,Phone,BirthDate,Photo,State")] Candidate candidate)
 {
     if (ModelState.IsValid)
     {
         candidateService.CreateCandidate(candidate);
         candidateService.SaveCandidate();
         return(RedirectToAction("Index"));
     }
     return(View(candidate));
 }
        public IActionResult Create(IFormFile avatar, CandidateCreateViewModel candidateView)
        {
            if (ModelState.IsValid)
            {
                _candidateService.CreateCandidate(avatar, candidateView);

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

            return(RedirectToAction(nameof(Create)));
        }
Example #6
0
        public async Task <CandidateDto> Handle(CreateCandidateCommand request, CancellationToken cancellationToken)
        {
            request.Candidate.Status = true;

            var result = await _service.CreateCandidate(request.Candidate);

            if (!result)
            {
                throw new ErrorException("01", "Error tratando de crear candidato");
            }

            return(_mapper.Map <CandidateDto>(request.Candidate));
        }
Example #7
0
        public async Task <IActionResult> Create(CandidateViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                foreach (var file in Request.Form.Files)
                {
                    var memoryStream = new MemoryStream();
                    file.CopyTo(memoryStream);
                    viewModel.CV       = memoryStream.ToArray();
                    viewModel.FileName = file.FileName;
                }

                var candidate = await _service.CreateCandidate(viewModel);

                await _service.CreateCandidateInfo(viewModel, candidate.Id);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(viewModel));
        }
Example #8
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD

        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var userName = User.Identity.Name;

            var advertisementCandidateService = new AdvertisementCandidateService(_context);
            var candidate = this._context.Candidates.FirstOrDefault(c => c.Email == Candidate.Email);

            if (candidate == null)
            {
                candidate = service.CreateCandidate(Candidate.FirstName, Candidate.LastName, Candidate.Email);
            }

            var advId = Convert.ToInt32(Request.Form["advId"]);

            advertisementCandidateService.AddCandidateToAdvertisement(advId, candidate.Id);

            return(RedirectToPage("/Index"));
        }
Example #9
0
        public async Task <IActionResult> Create(CandidateViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                foreach (var file in Request.Form.Files)
                {
                    var memoryStream = new MemoryStream();
                    file.CopyTo(memoryStream);
                    viewModel.CV       = memoryStream.ToArray();
                    viewModel.FileName = file.FileName;
                }

                var candidate = await _service.CreateCandidate(viewModel);

                await _service.CreateCandidateInfo(viewModel, candidate.Id);

                TempData["Candidate"] = "Thank you for applying!";

                return(RedirectToAction("Index", "Home"));
            }
            return(View(viewModel));
        }