public Task <Result <Applicant> > RegisterApplicant(ApplicantDto dto) =>
        TryCatch(async() =>
        {
            await ValidateApplicantDtoAsync(dto);

            var applicant = new Applicant(new Name(dto.Name), new FamilyName(dto.FamilyName),
                                          new Address(dto.Address), dto.CountryOfOrigin, new EmailAddress(dto.EmailAddress),
                                          new Age(dto.Age), dto.Hired);
            await _applicantRepository.Create(applicant);
            return(Result.Success(applicant));
        });
Пример #2
0
        public void Create(Applicant applicant)
        {
            Applicant dupApplicant = _ApplicantRepository.GetById(applicant.ID);

            if (dupApplicant != null)
            {
                throw new Exception(string.Format("An applicant allready exists in the database by this id : {0}", dupApplicant.ID));
            }

            _ApplicantRepository.Create(applicant);
        }
        public async Task <IActionResult> Create(ApplicantDTO applicantDto)
        {
            var applicant = _mapper.Map <Applicant>(applicantDto);

            await _repo.Create(applicant);

            if (await _repo.SaveAll())
            {
                return(CreatedAtRoute("CreateApplicant", new { id = applicant.Id }, applicant));
            }

            return(BadRequest("creation unsuccessful"));
        }
Пример #4
0
        public async Task <Applicant> Create(Applicant applicant)
        {
            var success = await _repository.Create(applicant).ConfigureAwait(false);

            if (success)
            {
                return(applicant);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        public async Task <Applicant> Create(Applicant applicant)
        {
            if (applicant.Hired == null)
            {
                applicant.Hired = false;
            }

            var success = await _repository.Create(applicant);

            if (success)
            {
                return(applicant);
            }
            else
            {
                return(null);
            }
        }
        public async Task <ActionResult> Create(Applicant application, HttpPostedFileBase resume, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                application.UserId = userId;
                if (image != null)
                {
                    string ImageName = Path.GetFileNameWithoutExtension(image.FileName);
                    string ext       = Path.GetExtension(image.FileName);
                    ImageName             = ImageName + DateTime.Now.ToString("yymmssfff") + ext;
                    application.ImagePath = "~/ApplicantImages/" + ImageName;
                    string physicalPath = Server.MapPath("~/ApplicantImages/" + ImageName);
                    image.SaveAs(physicalPath);
                }
                if (resume != null)
                {
                    string ResumeName = Path.GetFileNameWithoutExtension(resume.FileName);
                    string ext        = Path.GetExtension(resume.FileName);
                    ResumeName            += DateTime.Now.ToString("yymmssfff") + ext;
                    application.ResumePath = "~/ApplicantResumes/" + ResumeName;

                    ResumeName = Path.Combine(Server.MapPath("~/ApplicantResumes/"), ResumeName);
                    resume.SaveAs(ResumeName);
                }

                await arepo.Create(application);

                if (true)
                {
                    TempData["message"] = string.Format("Your application for {0} has been submitted. ", application.JobTitle);
                    return(RedirectToAction("Index", "Manage"));
                }
            }

            return(View(application));
        }
 public async Task CreateApplicant(ApplicantInput input)
 {
     Applicant result = _mapper.Map <Applicant>(input);
     await _applicantrepository.Create(result);
 }
 public Task <Applicant> Create(Applicant applicant)
 {
     _logger.LogInformation("Executing {0} service method for applicant {1}.", nameof(Create),
                            applicant.EmailAddress);
     return(_repository.Create(applicant));
 }