Exemple #1
0
        public ActionResult EditProfile(EditCandidateViewModel vm)
        {
            return(RedirectIfNotLoggedIn(() =>
            {
                if (ModelState.IsValid)
                {
                    var selectedCandidate = _candidateRepository.Get(vm.Id, "Person");

                    if (selectedCandidate != null)
                    {
                        selectedCandidate.RecievedOn = vm.RecievedOn;
                        selectedCandidate.Source = vm.Source;
                        selectedCandidate.Qualification = vm.Qualification;
                        selectedCandidate.TotalExperience = vm.TotalExperience;
                        selectedCandidate.ResumePath = vm.ResumePath;
                        selectedCandidate.PhotoPath = vm.PhotoPath;
                        selectedCandidate.Status = vm.Status;
                        selectedCandidate.Comments = vm.Comments;
                        selectedCandidate.CurrentCTC = vm.CurrentCTC;
                        selectedCandidate.ExpectedCTC = vm.ExpectedCTC;
                        selectedCandidate.DesignationId = vm.CandidateDesignationId;

                        selectedCandidate.Person.FirstName = vm.Person.FirstName;
                        selectedCandidate.Person.LastName = vm.Person.LastName;
                        selectedCandidate.Person.Gender = vm.Person.Gender;
                        selectedCandidate.Person.Email = vm.Person.Email;
                        selectedCandidate.Person.Organization = vm.Person.Organization;
                        selectedCandidate.Person.Designation = vm.Person.Designation;
                        selectedCandidate.Person.PhoneNo = vm.Person.PhoneNo;
                        selectedCandidate.Person.SecondaryEmail = vm.Person.SecondaryEmail;
                        selectedCandidate.Person.OfficePhone = vm.Person.OfficePhone;
                        selectedCandidate.Person.Skype = vm.Person.Skype;
                        selectedCandidate.Person.Facebook = vm.Person.Facebook;
                        selectedCandidate.Person.Twitter = vm.Person.Twitter;
                        selectedCandidate.Person.GooglePlus = vm.Person.GooglePlus;
                        selectedCandidate.Person.LinkedIn = vm.Person.LinkedIn;
                        selectedCandidate.Person.Address = vm.Person.Address;
                        selectedCandidate.Person.CommunicationAddress = vm.Person.CommunicationAddress;
                        selectedCandidate.Person.DateOfBirth = vm.Person.DateOfBirth;

                        // Clean up white spaces for Email and Phone Numbers
                        if (!string.IsNullOrEmpty(selectedCandidate.Person.Email))
                        {
                            selectedCandidate.Person.Email = selectedCandidate.Person.Email.Trim();
                        }

                        if (!string.IsNullOrEmpty(selectedCandidate.Person.SecondaryEmail))
                        {
                            selectedCandidate.Person.SecondaryEmail = selectedCandidate.Person.SecondaryEmail.Trim();
                        }

                        if (!string.IsNullOrEmpty(selectedCandidate.Person.PhoneNo))
                        {
                            selectedCandidate.Person.PhoneNo = selectedCandidate.Person.PhoneNo.Trim();
                        }

                        if (!string.IsNullOrEmpty(selectedCandidate.Person.OfficePhone))
                        {
                            selectedCandidate.Person.OfficePhone = selectedCandidate.Person.OfficePhone.Trim();
                        }

                        // Update the Candidate Code, Fix for the existing missed candidates;
                        selectedCandidate.Code = $"LA{selectedCandidate.Id.ToString("D" + 6)}";

                        _candidateRepository.Update(selectedCandidate);
                        _unitOfWork.Commit();

                        // Remove the existing mapped Technologies
                        var existingMaps = _candidateTechnologyMapRepository.GetAllBy(m => m.CandidateId == selectedCandidate.Id).ToList();
                        foreach (var map in existingMaps)
                        {
                            _candidateTechnologyMapRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        // Map the New Technologies
                        if (vm.TechnologyIds != null)
                        {
                            foreach (var technologyId in vm.TechnologyIds)
                            {
                                var newMap = new CandidateTechnologyMap
                                {
                                    CandidateId = vm.Id,
                                    TechnologyId = technologyId
                                };

                                _candidateTechnologyMapRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        return RedirectToAction("Index");
                    }

                    return RedirectToAction("Index");
                }

                return View(vm);
            }));
        }
Exemple #2
0
        public ActionResult Create(NewCandidateViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var newCandidate = new Candidate
                {
                    Source          = vm.Source,
                    Qualification   = vm.Qualification,
                    TotalExperience = vm.TotalExperience,
                    ResumePath      = vm.ResumePath,
                    PhotoPath       = vm.PhotoPath,
                    Status          = vm.Status,
                    Comments        = vm.Comments,
                    CurrentCTC      = vm.CurrentCTC,
                    ExpectedCTC     = vm.ExpectedCTC,
                    Person          = vm.Person,
                    DesignationId   = vm.CandidateDesignationId
                };


                // Clean up white spaces for Email and Phone Numbers
                if (!string.IsNullOrEmpty(newCandidate.Person.Email))
                {
                    newCandidate.Person.Email = newCandidate.Person.Email.Trim();
                }

                if (!string.IsNullOrEmpty(newCandidate.Person.SecondaryEmail))
                {
                    newCandidate.Person.SecondaryEmail = newCandidate.Person.SecondaryEmail.Trim();
                }

                if (!string.IsNullOrEmpty(newCandidate.Person.PhoneNo))
                {
                    newCandidate.Person.PhoneNo = newCandidate.Person.PhoneNo.Trim();
                }

                if (!string.IsNullOrEmpty(newCandidate.Person.OfficePhone))
                {
                    newCandidate.Person.OfficePhone = newCandidate.Person.OfficePhone.Trim();
                }

                newCandidate.RecievedOn = vm.RecievedOn;

                newCandidate.CreatedByUserId = WebUser.Id;

                _candidateRepository.Create(newCandidate);
                _unitOfWork.Commit();

                // Update the Candidate Code.
                var selectedCandidate = _candidateRepository.Get(newCandidate.Id);
                if (selectedCandidate != null)
                {
                    selectedCandidate.Code = $"LA{selectedCandidate.Id.ToString("D" + 6)}";
                    _candidateRepository.Update(selectedCandidate);
                    _unitOfWork.Commit();
                }

                // Map the Technologies
                if (vm.TechnologyIds != null)
                {
                    foreach (var technologyId in vm.TechnologyIds)
                    {
                        var newMap = new CandidateTechnologyMap
                        {
                            CandidateId  = newCandidate.Id,
                            TechnologyId = technologyId
                        };

                        _candidateTechnologyMapRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                // Add the resume and map it to docs.
                if (vm.Resume != null)
                {
                    var newDocument = new CandidateDocument
                    {
                        CandidateId  = newCandidate.Id,
                        DocumentType = CandidateDocumentType.Resume
                    };

                    var siteSettings      = _settingsService.GetSiteSettings();
                    var blobUploadService = new BlobUploadService(siteSettings.BlobSettings);
                    var blobPath          = blobUploadService.UploadRecruitDocument(vm.Resume);
                    newDocument.DocumentPath = blobPath;
                    newDocument.FileName     = vm.Resume.FileName;

                    _candidateDocumentRepository.Create(newDocument);
                    _unitOfWork.Commit();
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.CandidateDesignationId = new SelectList(_candidateDesignationRepository.GetAll(), "Id", "Title");
            return(View(vm));
        }