/// <summary>
        /// This method is for sending mail just put an smtp according to your mail server
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <IActionResult> SendOTPToMail(CandidateViewModel model)
        {
            //generate otp
            string body = GenerateToken();

            UserEmailOptions options = new UserEmailOptions
            {
                Subject  = "Recruitment Portal : Confirm you Email for verifying your Application.",
                ToEmails = new List <string>()
                {
                    model.email
                },
                Body = body
            };

            //sending mail to Receivers
            try
            {
                await _emailService.SendTestEmail(options);

                ViewData["token"] = body;
                ViewData["email"] = model.email;
            }
            catch (Exception ex)
            {
                ViewData["error"] = "error";
            }
            return(View(model));
        }
        public List <Candidate> Refuse(CandidateViewModel vm)
        {
            var repo = new CandidateRepository(_connectionString);

            repo.RefuseCandidate(vm.CandidateId);
            return(repo.GetAll());
        }
        // GET: Candidates/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var candidate = await _context.Candidates
                            .Include(c => c.CandidateRaces)
                            .Include(c => c.Details)
                            .Include(c => c.Contacts)
                            .FirstOrDefaultAsync(c => c.CandidateId == id);

            if (candidate == null)
            {
                return(NotFound());
            }

            CandidateViewModel model = new CandidateViewModel
            {
                Candidate     = candidate,
                Organizations = new SelectList(_context.Organizations, "OrganizationId", "Name", candidate.OrganizationId),
                Races         = new SelectList(_context.Races
                                               .Where(r => r.ElectionId == _managedElectionID)
                                               .OrderBy(r => r.BallotOrder),
                                               "RaceId", "PositionName")
            };

            return(View(model));
        }
Ejemplo n.º 4
0
        //[ValidateAntiForgeryToken]
        public async Task <IHttpActionResult> Register(CandidateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    model.AuthID = user.Id;
                    try
                    {
                        await _candidateService.CreateCandidateAsync(model);
                    }
                    catch (Exception ex)
                    {
                    }
                    await SignInHelper.SignInAsync(user, false, false);

                    return(Ok(true));
                }
            }

            // If we got this far, something failed, redisplay form
            return(Ok(true));
        }
        public IActionResult GetCandidate(int id)
        {
            // var id = HttpContext.Session.GetInt32("CandidateId").Value;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var candidateVW = new CandidateViewModel();
            var cand        = _candidateRepository.GetCandidate(id);

            if (cand != null)
            {
                var addr = _addressRepository.GetAddress(cand.AddrId);
                var cont = _contactRepository.GetContact(cand.ContactId);

                candidateVW = new CandidateViewModel
                {
                    candidate = cand,
                    address   = addr,
                    contact   = cont
                };
            }

            return(Ok(candidateVW));
        }
Ejemplo n.º 6
0
        public ActionResult Create(CandidateViewModel candidateVM)
        {
            if (ModelState.IsValid)
            {
                db.Candidates.Add(candidateVM.Candidate);
                db.SaveChanges();

                var sKillToUpdate = db.Candidates
                                    .Include(i => i.Skills).First(i => i.CandidateId == candidateVM.Candidate.CandidateId);
                //var newSkills = db.Skills.Where(
                //  m => candidateVM.SelectedAllSkills.Contains(m.SkillID)).ToList();
                var newSkill = new HashSet <int>(candidateVM.SelectedAllSkills);
                foreach (Skill skill in db.Skills)
                {
                    if (newSkill.Contains(skill.SkillID))
                    {
                        sKillToUpdate.Skills.Add(skill);
                    }
                }

                db.Entry(sKillToUpdate).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(candidateVM));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(CandidateViewModel candidateView)
        {
            if (ModelState.IsValid)
            {
                var sKillToUpdate = db.Candidates
                                    .Include(i => i.Skills).First(i => i.CandidateId == candidateView.Candidate.CandidateId);

                if (TryUpdateModel(sKillToUpdate, "Candidate", new string[] { "FirstName", "LastName" }))
                {
                    // var newJobTags = db.Skills.Where(
                    //     m => candidateView.SelectedAllSkills.Contains(m.SkillID)).ToList();
                    var updatedSkill = new HashSet <int>(candidateView.SelectedAllSkills);
                    foreach (Skill skill in db.Skills)
                    {
                        if (!updatedSkill.Contains(skill.SkillID))
                        {
                            sKillToUpdate.Skills.Remove(skill);
                        }
                        else
                        {
                            sKillToUpdate.Skills.Add((skill));
                        }
                    }

                    db.Entry(sKillToUpdate).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
 private CandidateModel MapToCandidateDomainModel(CandidateViewModel viewModel)
 {
     return(new CandidateModel
     {
         ID = viewModel.ID,
         FirstName = viewModel.FirstName,
         LastName = viewModel.LastName,
         MiddleName = viewModel.MiddleName,
         FinCode = viewModel.FinCode,
         Mail = viewModel.Mail,
         Birthdate = viewModel.Birthdate,
         FamilyStatusId = viewModel.FamilyStatusId,
         GenderId = viewModel.GenderId,
         Profession = viewModel.Profession,
         ExamDate = viewModel.ExamDate,
         ExamTime = viewModel.ExamTime,
         ProfessionId = viewModel.ProfessionId,
         ExamProfessionId = viewModel.ExamProfessionId,
         Mobile = viewModel.Mobile,
         Status = viewModel.Status,
         Finish = viewModel.Finish,
         LocalCandidateStatus = viewModel.ProfessionId != 0,
         TicketID = viewModel.TicketId,
         Description = viewModel.Description
     });
 }
        public void AddCandidate(CandidateViewModel model)
        {
            string connectionString = "server=localhost;uid=root;password=Reset1234;database=OnlineTestManagement;";
            string queryString      =
                "INSERT INTO OnlineTestManagement.Candidate(Name, EmailId, MobileNumber, Password, AppliedFor,CreatedOn, ModifiedOn, TestId) " +
                "VALUES ('" + model.Name + "', '" + model.EmailId + "', '" + model.MobileNumber + "', '" + model.Password + "', '" + model.AppliedFor + "',@date,@date1," + model.TestId + ") ";

            using (MySqlConnection connection =
                       new MySqlConnection(connectionString))
            {
                MySqlCommand command =
                    new MySqlCommand(queryString, connection);
                command.Parameters.AddWithValue("@date", DateTime.Now);
                command.Parameters.AddWithValue("@date1", DateTime.Now);
                connection.Open();

                //command.ExecuteNonQuery();
                command.ExecuteNonQuery();

                // Call Close when done reading.
                connection.Close();
            }

            return;
        }
Ejemplo n.º 10
0
        public ActionResult Candidates(CandidateViewModel candidateViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    GuestService guestService = new GuestService();
                    Guest        guest        = new Guest();
                    guest.FirstName    = candidateViewModel.FirstName;
                    guest.LastName     = candidateViewModel.LastName;
                    guest.EmailAddress = candidateViewModel.EmailAddress;
                    guest = guestService.GetUserInfo(guest);

                    if (guest != null)
                    {
                        var res = guestService.InnerMetrixURLBuilder(guest, "Candidates", candidateViewModel.Language ?? TempData["Culture"].ToString());
                        return(RedirectPermanent(res));
                    }
                }
                return(View(candidateViewModel));
            }
            catch (Exception ex)
            {
                //ModelState.AddModelError("", ex.InnerException + " " + ex.Message);
                ModelState.AddModelError("", "Error upon submitting form, Please retry again.");
                throw ex;
            }
        }
Ejemplo n.º 11
0
        public ActionResult List()
        {
            CandidateViewModel model = new CandidateViewModel();

            model.Candidates = CandidateDALC.GetList().Select(row => MapToCandidateViewModel(row)).ToList();
            return(View(model));
        }
Ejemplo n.º 12
0
        public IActionResult Details(int id)
        {
            var candidate = _candidateRepository.GetById(id);

            if (candidate != null)
            {
                var candidateViewModel = new CandidateViewModel
                {
                    //Peson
                    Id    = candidate.Id,
                    City  = candidate.City,
                    Email = candidate.Email,
                    Name  = candidate.Name,
                    Phone = candidate.Phone,
                    State = candidate.State,
                    //Bank
                    BankInformationId            = candidate.BankInformation.Id,
                    BankInformationPersonName    = candidate.BankInformation.PersonName,
                    BankInformationBankName      = candidate.BankInformation.BankName,
                    BankInformationAgency        = candidate.BankInformation.Agency,
                    BankInformationAccountType   = candidate.BankInformation.AccountType,
                    BankInformationAccountNumber = candidate.BankInformation.AccountNumber,
                    BankInformationCpf           = candidate.BankInformation.Cpf
                };

                return(View(candidateViewModel));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 13
0
        public async Task <CandidateViewModel> UpdateCandidate(CandidateViewModel candidateVM)
        {
            var id     = new ObjectId(candidateVM._id);
            var filter = Builders <Candidates> .Filter.Eq("_id", id);

            var update = Builders <Candidates> .Update
                         .Set("CandidateName", candidateVM.CandidateName)
                         .Set("VideoUrl", candidateVM.VideoUrl)
                         .Set("ImageUrl", candidateVM.ImageUrl)
                         .Set("Objectives", candidateVM.Objectives)
                         .Set("Profile", candidateVM.Profile)
                         .Set("Position", candidateVM.Position)
                         .Set("Location", candidateVM.Location)
                         .Set("Experince", candidateVM.Experince)
                         .Set("CurrentSalary", candidateVM.CurrentSalary)
                         .Set("ExpectedSalaryFrom", candidateVM.ExpectedSalaryFrom)
                         .Set("ExpectedSalaryTo", candidateVM.ExpectedSalaryTo)
                         .Set("IsFullTime", candidateVM.IsFullTime)
                         .Set("IsPermanent", candidateVM.IsPermanent)
                         .Set("IsPartTime", candidateVM.IsPartTime)
                         .Set("IsRemote", candidateVM.IsRemote)
                         .Set("IsTemporary", candidateVM.IsTemporary)
                         .Set("IsLocum", candidateVM.IsLocum)
                         .Set("Skills", candidateVM.Skills)
                         .Set("MobileNo", candidateVM.MobileNo)
                         .Set("Email", candidateVM.Email)
                         .Set("Sex", candidateVM.Sex);

            var result = await _db.Candidates.UpdateOneAsync(filter, update);

            return(GetCandidateByID(candidateVM._id.ToString()));
        }
Ejemplo n.º 14
0
        public async Task <bool> UpdateCandidateById(CandidateViewModel candidateViewModel)
        {
            if (CandidateExist(candidateViewModel.CandidateId))
            {
                string url = null;
                if (candidateViewModel.File != null)
                {
                    url = _img.EditImage(candidateViewModel.File, candidateViewModel.MyImageUrl, _env);
                }

                Candidate candidate = await _ctx.Candidates.Where(c => c.CandidateId == candidateViewModel.CandidateId).SingleOrDefaultAsync();

                candidate.ElectionId         = candidateViewModel.ElectionId;
                candidate.MyImageUrl         = !string.IsNullOrEmpty(url) ? url : candidateViewModel.MyImageUrl;
                candidate.MyPromise          = candidateViewModel.MyPromise;
                candidate.TotalNumberOfVotes = candidateViewModel.TotalNumberOfVotes;
                candidate.UserId             = candidateViewModel.UserId;
                try
                {
                    _ctx.Candidates.Update(candidate);
                    await _ctx.SaveChangesAsync();

                    return(true);
                }
                catch (Exception ex)
                {
                    _logger.LogInformation($"There was an error {ex.Message}");
                    return(false);
                }
            }
            return(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CandidateView"/> class.
        /// </summary>
        public CandidateView()
        {
            this.candidateVM = new CandidateViewModel(new NavigationService());

            this.InitializeComponent();
            this.DataContext = this.candidateVM;
        }
Ejemplo n.º 16
0
        public async Task <ActionResult <AddressRegisterDto> > UpdatePersonAddress(AddressRegisterDto addressDto)
        {
            CandidateViewModel candidate = await GetCandidateById(_candidateId);

            if (candidate == null)
            {
                return(NotFound());
            }
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            var command = new UpdateAddressCandidateCommand(addressDto.Id,
                                                            candidate.Id, addressDto.CountryId,
                                                            addressDto.ZipCode, addressDto.District,
                                                            addressDto.Street, addressDto.Number,
                                                            addressDto.Complement, addressDto.State,
                                                            addressDto.City);

            var response = await _mediatorHandler.SendCommand(command);

            if (!response.IsValid)
            {
                return(CustomResponse(response));
            }
            return(CustomResponse(addressDto));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> AddCandidate(CandidateViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var path = string.Empty;

                if (model.ImageFile != null && model.ImageFile.Length > 0)
                {
                    var guid = Guid.NewGuid().ToString();
                    var file = $"{guid}.jpg";

                    path = Path.Combine(
                        Directory.GetCurrentDirectory(),
                        "wwwroot\\images\\Candidates",
                        file);

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await model.ImageFile.CopyToAsync(stream);
                    }

                    path = $"~/images/Candidates/{file}";
                }

                await this.votingEventRepository.AddCandidateAsync(model, path);

                return(this.RedirectToAction($"Details/{model.VotingEventId}"));
            }

            return(this.View(model));
        }
Ejemplo n.º 18
0
        public ActionResult AddOrEdit(int CandidateId)
        {
            List <Position> plist = db.Position.ToList();

            ViewBag.PositionList = new SelectList(plist, "PositionId", "PositionName");

            List <Level> llist = db.Level.ToList();

            ViewBag.LevelList = new SelectList(llist, "LevelId", "LevelName");

            CandidateViewModel model = new CandidateViewModel();

            if (CandidateId > 0)
            {
                Candidate emp = db.Candidate.FirstOrDefault(x => x.CandidateId == CandidateId);
                model.CandidateId   = emp.CandidateId;
                model.LevelId       = emp.LevelId;
                model.PositionId    = emp.PositionId;
                model.FullName      = emp.FullName;
                model.Birthday      = emp.Birthday;
                model.Address       = emp.Address;
                model.Phone         = emp.Phone;
                model.Email         = emp.Email;
                model.IntroduceName = emp.IntroduceName;
                model.CV            = emp.CV;
                emp.IsPDF           = model.IsPDF;
            }
            return(PartialView("_Modal", model));
        }
Ejemplo n.º 19
0
        // GET: Candidates/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            var candidateViewModel = new CandidateViewModel
            {
                Candidate = db.Candidates.Include(i => i.Skills).First(i => i.CandidateId == id),
            };

            if (candidateViewModel.Candidate == null)
            {
                return(HttpNotFound());
            }

            var allSkillList = db.Skills.ToList();

            candidateViewModel.AllSkills = allSkillList.Select(o => new SelectListItem
            {
                Text  = o.Name,
                Value = o.SkillID.ToString()
            });


            return(View(candidateViewModel));
        }
Ejemplo n.º 20
0
        public RegisterViewModel RegisterUser(RegisterViewModel registerViewModel)
        {
            OnlineExamAppDBEntities3 dbContext = new OnlineExamAppDBEntities3();
            User existingUser = dbContext.Users.Where(u => u.UserName == registerViewModel.UserName).FirstOrDefault();

            if (existingUser == null)
            {
                User user = new User();
                user.FirstName = registerViewModel.FirstName;
                user.LastName  = registerViewModel.LastName;
                user.UserName  = registerViewModel.UserName;
                user.Password  = registerViewModel.Password;

                dbContext.Users.Add(user);
                dbContext.SaveChanges();

                _candidate = new ViewModel.CandidateViewModel()
                {
                    Name = registerViewModel.UserName
                };
                registerViewModel.ErrorDescription = string.Empty;
            }
            else
            {
                registerViewModel.ErrorDescription = "The User Name already exists. Please supply a new User Name";
            }

            return(registerViewModel);
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> AddCandidate(CandidateViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var path = string.Empty;

                if (model.ImageFile != null && model.ImageFile.Length > 0)
                {
                    var guid = Guid.NewGuid().ToString();
                    var file = $"{guid}.jpg";


                    path = Path.Combine(Directory.GetCurrentDirectory(),
                                        "wwwroot\\images\\Candidates",
                                        file);

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await model.ImageFile.CopyToAsync(stream);
                    }

                    path = $"~/images/Candidates/{file}";
                }

                var candidate = this.ToCandidate(model, path);
                candidate.User = await this.userHelper.GetUserByEmailAsync("*****@*****.**");

                await this.eventRepository.AddCandidateAsync(candidate);

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

            return(this.View(model));
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> EditCandidate(CandidateViewModel view)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var path = view.ImageUrl;
                    if (view.ImageFile != null && view.ImageFile.Length > 0)
                    {
                        path = await this.PathImage(view);
                    }
                    var candidate = this.ToCandidate(view, path);
                    await this.eventRepository.UpdateCandidateAsync(candidate);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await this.eventRepository.ExistAsync(view.Id))
                    {
                        return(new NotFoundViewResult("EventNotFound"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(view));
        }
 public ActionResult Candidate(CandidateViewModel model, HttpPostedFileBase uploadImage)
 {
     if (UserDAL.GetUserByName(User.Identity.Name).Candidate != null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     if (ModelState.IsValid)
     {
         byte[] imageData = null;
         if (uploadImage != null)
         {
             using (var binaryReader = new BinaryReader(uploadImage.InputStream))
             {
                 imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
             }
         }
         if (CandidateDAL.Create(new Candidate {
             FullName = model.FullName, Birthday = model.Birthday, KeyWords = model.KeyWords, Photo = imageData, UserId = UserDAL.GetUserByName(User.Identity.Name), WorkExpirience = model.WorkExpirience
         }))
         {
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError(string.Empty, "Что-то пошло не так, попробуйте ещё раз");
         }
     }
     else
     {
         ModelState.AddModelError(string.Empty, "Registration failed.");
     }
     return(View());
 }
Ejemplo n.º 24
0
        public ActionResult Show(int Id)
        {
            var obj    = dataManager.Candidates.Get(Id);
            var person = dataManager.Persons.Get(obj.PersonId ?? 0);
            var model  = new CandidateViewModel
            {
                Candidate        = obj,
                Person           = person,
                RelatedPrecincts = new List <CandidatePrecinctRelationViewModel>(from cp in dataManager.CandidatePrecinctRelations.GetAll()
                                                                                 where cp.CandidateId == Id
                                                                                 select new CandidatePrecinctRelationViewModel
                {
                    CandidatePrecinctRelation = cp,
                    Precinct = dataManager.Precincts.Get(cp.PrecinctId ?? 0)
                }),
                RelatedMunicipalities = new List <CandidateMunicipalityRelationViewModel>(from cp in dataManager.CandidateMunicipalityRelations.GetAll()
                                                                                          where cp.CandidateId == Id
                                                                                          select new CandidateMunicipalityRelationViewModel
                {
                    CandidateMunicipalityRelation = cp,
                    Municipality = dataManager.Municipalities.Get(cp.MunicipalityId ?? 0)
                })
            };

            return(View(model));
        }
Ejemplo n.º 25
0
        public async Task <CandidateViewModel> AddNewCandidate(CandidateViewModel model)
        {
            var mapped   = _mapper.Map <Candidate>(model);
            var newmodel = await _candidateRepository.Add(mapped);

            return(_mapper.Map <CandidateViewModel>(newmodel));
        }
Ejemplo n.º 26
0
        public async Task UpdateCandidate(CandidateViewModel viewModel, int id)
        {
            var candidate = _mapper.Map <Candidate>(viewModel);

            _context.Update(candidate);

            var address = await _context.Addresses.FirstAsync(a => a.CandidateId == id);

            address.Location      = viewModel.Address.Location;
            address.AddressNumber = viewModel.Address.AddressNumber;
            address.Country       = viewModel.Address.Country;
            address.Comments      = viewModel.Address.Comments;
            address.PostCode      = viewModel.Address.PostCode;
            _context.Addresses.Update(address);

            var phone = await _context.Phones.FirstAsync(p => p.CandidateId == id);

            phone.Number    = viewModel.Phone.Number;
            phone.PhoneType = viewModel.Phone.PhoneType;
            _context.Phones.Update(phone);

            var email = await _context.Emails.FirstAsync(e => e.CandidateId == id);

            email.Mail     = viewModel.Email.Mail;
            email.MailType = viewModel.Email.MailType;
            _context.Emails.Update(email);
            await _context.SaveChangesAsync();
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> CandidatesAsync(long id)
        {
            List <CandidateViewModel> model      = new List <CandidateViewModel>();
            IEnumerable <JobApply>    jobapplies = _jobApplyRepository.Find(x => x.JobID == id);

            foreach (var jobapply in jobapplies)
            {
                string          address1 = "";
                ApplicationUser appuser  = await _userManager.FindByIdAsync(jobapply.UserID);

                var jobseeker = _jobseekerRepository.FindByAsyn(x => x.ApplicationUserId == appuser.Id).Result.FirstOrDefault();
                CandidateViewModel candidate = new CandidateViewModel();
                var postalCodeDetail         = _postalCodeRepository.GetPostalCodeDetail(jobseeker.PostalAddrss);
                if (postalCodeDetail != null)
                {
                    var province = _provinceRepository.GetById(postalCodeDetail.ProvinceID);
                    if (province != null)
                    {
                        address1 = postalCodeDetail.Code + " " + province.Name_Jp + " " + postalCodeDetail.CityName + " " + postalCodeDetail.CityName;
                    }
                }

                candidate.Name          = jobseeker.LastName + " " + jobseeker.FirstName;
                candidate.EmailAddress  = appuser.Email;
                candidate.AppliedDate   = jobapply.ApplyDate;
                candidate.Address       = address1 + " " + jobseeker.Address;
                candidate.ContactNumber = appuser.PhoneNumber;
                model.Add(candidate);
            }

            return(View(model));
        }
Ejemplo n.º 28
0
        public async Task CreateCandidateInfo(CandidateViewModel viewModel, int id)
        {
            var address = _mapper.Map <Address>(viewModel.Address);

            address.CandidateId = id;
            await _context.Addresses.AddAsync(address);

            var phone = _mapper.Map <Phone>(viewModel.Phone);

            phone.CandidateId = id;
            await _context.Phones.AddAsync(phone);

            var email = _mapper.Map <Email>(viewModel.Email);

            email.CandidateId = id;
            await _context.Emails.AddAsync(email);

            var candidatePosition = new CandidatePosition();

            candidatePosition.PositionId  = viewModel.PositionId;
            candidatePosition.CandidateId = id;
            await _context.CandidatePositions.AddAsync(candidatePosition);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 29
0
        public IResult GetCandidateById(Guid id)
        {
            var result = new Result
            {
                Operation = Operation.Read,
                Status    = Status.Success
            };

            try
            {
                var candidateViewModel = new CandidateViewModel();
                var getCandidate       = _candidateRepository.GetByID(id);
                var openingCandidate   = _candidateRepository.GetOpeningCandidate(getCandidate.CandidateId);
                candidateViewModel.OpeningId         = openingCandidate.Opening.OpeningId;
                candidateViewModel.OpeningTitle      = openingCandidate.Opening.Title;
                candidateViewModel.Qualification     = getCandidate.Qualification.QualificationId;
                candidateViewModel.QualificationName = getCandidate.Qualification.Name;
                candidateViewModel.OrganizationName  = getCandidate.Organisation.Name;
                var candidateDocument = new CandidateDocumentViewModel();
                candidateViewModel.CandidateDocument = (CandidateDocumentViewModel)candidateDocument.MapFromModel(getCandidate.CandidateDocuments.FirstOrDefault());
                result.Body = candidateViewModel.MapFromModel(getCandidate);
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.Status  = Status.Error;
            }
            return(result);
        }
        public async Task <IActionResult> Index(int id) //jobpost id
        {
            //creating a candidate applying for job
            CandidateViewModel model = new CandidateViewModel();

            model.jobpostID = id;

            //------------------------------------------------------------------------
            //fetching all the degrees for candidate to apply with.

            //getting data from database
            List <Degree> DegreeList = new List <Degree>();

            DegreeList = (from element in _dbContext.Degree select element).ToList();

            //inserting into dropdown list
            DegreeList.Insert(0, new Degree {
                ID = 0, degree_name = "Select Degree"
            });

            //assigning degreelist to viewbag.listofdegree
            ViewBag.ListOfDegree = DegreeList;
            //--------------------------------------------------------------------------

            return(View(model));
        }