예제 #1
0
        //public JobSeekerPersonalDetailsViewModel GetPersonalDetails(string id)
        public JobSeekerPersonalDetailsViewModel GetPersonalDetails(string id)
        {
            try
            {
                var seeker = jobSeekerRepository.Get(id);

                if (seeker != null)
                {
                    var personalDetails = new JobSeekerPersonalDetailsViewModel();

                    personalDetails.FirstName       = seeker.FirstName;
                    personalDetails.LastName        = seeker.LastName;
                    personalDetails.IdNumber        = seeker.IdNumber;
                    personalDetails.Phone           = seeker.Phone;
                    personalDetails.TitleId         = seeker.TitleId;
                    personalDetails.GenderId        = seeker.GenderId;
                    personalDetails.ProvinceId      = seeker.ProvinceId;
                    personalDetails.CityId          = seeker.CityId;
                    personalDetails.AddressId       = seeker.AddressId;
                    personalDetails.StreetName      = addressRepository.Get(seeker.AddressId).StreetName;
                    personalDetails.StreetNumber    = addressRepository.Get(seeker.AddressId).StreetNumber;
                    personalDetails.BuildingNumber  = addressRepository.Get(seeker.AddressId).BuildingNumber;
                    personalDetails.PersonalProfile = seeker.PersonalProfile;
                    personalDetails.Email           = userRepository.
                                                      FindByCondition(c => c.UserId.Equals(id) && c.IsActive == true).
                                                      FirstOrDefault().Email;

                    var academicRecordAttachment = attachmentRepository.
                                                   FindByCondition(a => a.JobSeekerId.Equals(seeker.Id) &&
                                                                   a.AttachmentType.Equals("AcademicRecord")).
                                                   FirstOrDefault();

                    personalDetails.AcademicRecordUrl = academicRecordAttachment != null ? academicRecordAttachment.AttachmentName : null;

                    var cvAttachement = attachmentRepository.FindByCondition(a => a.JobSeekerId.
                                                                             Equals(seeker.Id) && a.AttachmentType.Equals("CV")).
                                        FirstOrDefault();

                    personalDetails.CVUrl = cvAttachement != null ? cvAttachement.AttachmentName : null;

                    var idAttachment = attachmentRepository.FindByCondition(a => a.JobSeekerId.
                                                                            Equals(seeker.Id) && a.AttachmentType.Equals("ID")).
                                       FirstOrDefault();

                    personalDetails.IdUrl       = idAttachment != null ? idAttachment.AttachmentName : null;
                    personalDetails.JobSeekerId = id;

                    return(personalDetails);
                }
                return(null);
            }
            catch (Exception exception)
            {
                logger.LogError("Couldn't find user data " + id);
                return(null);
            }
        }
예제 #2
0
        //Lets update personal profile
        public void UpdatePersonalDetails(JobSeekerPersonalDetailsViewModel jobSeekerPersonalDetailsViewModel)
        {
            //Add ID Number later
            var jobSeeker    = jobSeekerRepository.Get(jobSeekerPersonalDetailsViewModel.JobSeekerId);
            var newAddressId = Guid.NewGuid().ToString();

            if (jobSeeker == null)
            {
                addressRepository.Insert(new Address {
                    StreetName     = jobSeekerPersonalDetailsViewModel.StreetName,
                    StreetNumber   = jobSeekerPersonalDetailsViewModel.StreetNumber,
                    BuildingNumber = jobSeekerPersonalDetailsViewModel.BuildingNumber,
                    Id             = newAddressId,
                    IsActive       = true
                });

                jobSeekerRepository.Insert(new JobSeeker
                {
                    ProvinceId      = jobSeekerPersonalDetailsViewModel.ProvinceId,
                    CityId          = jobSeekerPersonalDetailsViewModel.CityId,
                    GenderId        = jobSeekerPersonalDetailsViewModel.GenderId,
                    EthnicityId     = jobSeekerPersonalDetailsViewModel.EthnicityId,
                    TitleId         = jobSeekerPersonalDetailsViewModel.TitleId,
                    LastName        = jobSeekerPersonalDetailsViewModel.LastName,
                    FirstName       = jobSeekerPersonalDetailsViewModel.FirstName,
                    Phone           = jobSeekerPersonalDetailsViewModel.Phone,
                    PersonalProfile = jobSeekerPersonalDetailsViewModel.PersonalProfile,
                    IdNumber        = jobSeekerPersonalDetailsViewModel.IdNumber,
                    Id        = jobSeekerPersonalDetailsViewModel.JobSeekerId,
                    AddressId = newAddressId,
                    IsActive  = true
                });
            }
            else
            {
                //Update Address
                var address = addressRepository.Get(jobSeeker.AddressId);
                address.StreetName     = jobSeekerPersonalDetailsViewModel.StreetName;
                address.StreetNumber   = jobSeekerPersonalDetailsViewModel.StreetNumber;
                address.BuildingNumber = jobSeekerPersonalDetailsViewModel.BuildingNumber;

                addressRepository.Update(address);
                //Update Jobsekker

                jobSeeker.ProvinceId      = jobSeekerPersonalDetailsViewModel.ProvinceId;
                jobSeeker.CityId          = jobSeekerPersonalDetailsViewModel.CityId;
                jobSeeker.GenderId        = jobSeekerPersonalDetailsViewModel.GenderId;
                jobSeeker.EthnicityId     = jobSeekerPersonalDetailsViewModel.EthnicityId;
                jobSeeker.TitleId         = jobSeekerPersonalDetailsViewModel.TitleId;
                jobSeeker.LastName        = jobSeekerPersonalDetailsViewModel.LastName;
                jobSeeker.FirstName       = jobSeekerPersonalDetailsViewModel.FirstName;
                jobSeeker.Phone           = jobSeekerPersonalDetailsViewModel.Phone;
                jobSeeker.PersonalProfile = jobSeekerPersonalDetailsViewModel.PersonalProfile;
                jobSeeker.IdNumber        = jobSeekerPersonalDetailsViewModel.IdNumber;
                jobSeekerRepository.Update(jobSeeker);
            }
        }
예제 #3
0
        //Update or Add Profile data


        public JsonResult UpdatePersonalDetails(JobSeekerPersonalDetailsViewModel jobSeekerPersonalDetailsViewModel)
        {
            jobSeekerPersonalDetailsViewModel.JobSeekerId = HttpContext.Session.Get <string>("JobSeekerId");
            var  response     = new HustlersResponse <JobSeekerPersonalDetailsViewModel>();
            bool isValidInput = true;

            if (String.IsNullOrEmpty(jobSeekerPersonalDetailsViewModel.FirstName))
            {
                response.Status   = "fail";
                response.Messages = "FirstName is required\n";
                isValidInput      = false;
                return(Json(response));
            }

            if (jobSeekerPersonalDetailsViewModel.FirstName.Length > 50)
            {
                response.Status   = "fail";
                response.Messages = "FirstName cannot exceed 50 characters\n";
                isValidInput      = false;
                return(Json(response));
            }


            if (String.IsNullOrEmpty(jobSeekerPersonalDetailsViewModel.LastName))
            {
                response.Status   = "fail";
                response.Messages = "LastName is required\n";
                isValidInput      = false;
                return(Json(response));
            }

            if (jobSeekerPersonalDetailsViewModel.LastName.Length > 50)
            {
                response.Status   = "fail";
                response.Messages = "LastName cannot exceed 50 characters\n";
                isValidInput      = false;
                return(Json(response));
            }

            if (String.IsNullOrEmpty(jobSeekerPersonalDetailsViewModel.IdNumber))
            {
                response.Status   = "fail";
                response.Messages = "Id Number is required\n";
                isValidInput      = false;
                return(Json(response));
            }


            if (jobSeekerPersonalDetailsViewModel.IdNumber.Length > 13)
            {
                response.Status   = "fail";
                response.Messages = "Id Number cannot be more than 13 digits\n";
                isValidInput      = false;
                return(Json(response));
            }

            if (String.IsNullOrEmpty(jobSeekerPersonalDetailsViewModel.Phone))
            {
                response.Status   = "fail";
                response.Messages = "Phone is required\n";
                isValidInput      = false;
                return(Json(response));
            }

            if (jobSeekerPersonalDetailsViewModel.Phone.Length > 10)
            {
                response.Status   = "fail";
                response.Messages = "Phone cannot be more than 10 digits \n";
                isValidInput      = false;
                return(Json(response));
            }

            if (!Regex.Match(jobSeekerPersonalDetailsViewModel.FirstName, "^[A-Z][a-zA-Z]*$").Success)
            {
                response.Status   = "fail";
                response.Messages = "Enter a valid FirstName\n";
                isValidInput      = false;
            }

            if (!Regex.Match(jobSeekerPersonalDetailsViewModel.LastName, "^[A-Z][a-zA-Z]*$").Success)
            {
                response.Messages = response.Messages + " Enter a valid LastName\n";
                isValidInput      = false;
            }

            var dob = jobSeekerPersonalDetailsViewModel.IdNumber.Substring(0, 6);

            if (Int32.Parse(dob.Substring(2, 2)) > 12 || Int32.Parse(dob.Substring(4, 2)) > 31)
            {
                isValidInput      = false;
                response.Messages = response.Messages + " Enter a valid ID Number\n";
            }

            if (isValidInput)
            {
                //Call update personal details service
                response.Status   = "ok";
                response.Messages = "Personal Details Updated Successfully";
                _jobSeekerService.UpdatePersonalDetails(jobSeekerPersonalDetailsViewModel);
            }


            return(Json(response));
        }