コード例 #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)));
            }
        }
コード例 #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));
        }
コード例 #3
0
        public IActionResult Post([FromBody] ReqCandidateVM req)
        {
            var result = service.CreateCandidate(req);

            return(Ok(new SuccessResponse <string>
            {
                Code = 200,
                Data = result
            }));
        }
コード例 #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));
 }
コード例 #5
0
        public IActionResult Create(IFormFile avatar, CandidateCreateViewModel candidateView)
        {
            if (ModelState.IsValid)
            {
                _candidateService.CreateCandidate(avatar, candidateView);

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

            return(RedirectToAction(nameof(Create)));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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"));
        }
コード例 #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));
        }