public ActionResult ShowApplicantJobs()
        {
            ApplicantViewModel        appvm;
            List <ApplicantViewModel> appvmres = new List <ApplicantViewModel>();
            string userid         = User.Identity.GetUserId();
            var    applicantsdata = (from j in db.Jobs
                                     join uj in db.SeekersToJobs on j.job_id equals uj.job_id
                                     where uj.UserId == userid
                                     select new
            {
                job_id = j.job_id,
                Job_Title = j.job_title,
                Is_Accepted = uj.IsAccepted
            }).ToList();

            foreach (var item in applicantsdata)
            {
                appvm             = new ApplicantViewModel();
                appvm.Job_Id      = item.job_id;
                appvm.Job_Title   = item.Job_Title;
                appvm.Is_Accepted = item.Is_Accepted;
                appvmres.Add(appvm);
            }
            return(View(appvmres));
        }
示例#2
0
        public async Task <IActionResult> Post([FromBody] ApplicantViewModel inputApplicant)
        {
            // mapping shoud be done using Automapper or similar libraries but for simplicity it is mapped manually
            var applicant = new Applicant {
                Name = inputApplicant.Name, FamilyName = inputApplicant.FamilyName, Address = inputApplicant.Address, Age = inputApplicant.Age, CountryOfOrigin = inputApplicant.CountryOfOrigin, EmailAdress = inputApplicant.EmailAdress, Hired = inputApplicant.Hired
            };
            var applicantValidator = new ApplicantValidator();
            var result             = await applicantValidator.ValidateAsync(applicant);

            if (result.IsValid)
            {
                var addedApplicant = applicantManager.Add(applicant);
                if (addedApplicant != null)
                {
                    logger.Information($"Added new Apllicant with Id:{applicant.ID}");
                    return(CreatedAtAction("Get", new { id = applicant.ID }, applicant));
                }
                else
                {
                    logger.Warning("Failed to Add a new Applicant with Post request");
                    return(BadRequest());
                }
            }
            else
            {
                logger.Warning("Failed to Add a new Applicant with Post request, validation failed");
                return(BadRequest());
            }
        }
 public void Update(ApplicantViewModel ap)
 {
     using (_repository = new ApplicantRepository())
     {
         _repository.Update(Mapper.MapingApplicant(ap));
     }
 }
示例#4
0
        public ActionResult EditApplicant(int applicantId)
        {
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <ApplicantDTO, ApplicantViewModel>()).CreateMapper();
            ApplicantViewModel applicantEdit = mapper.Map <ApplicantDTO, ApplicantViewModel>(service.GetApplicant(applicantId));

            return(View(applicantEdit));
        }
示例#5
0
        public async Task <ActionResult> Create(ApplicantViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            if (Session["@Tracker"] is Guid existingTracker)
            {
                var existingApplicant = await _context.Applicant.FirstOrDefaultAsync(it => it.Tracker == existingTracker);

                _mapper.Map(viewModel, existingApplicant);

                _context.Entry(existingApplicant).State = EntityState.Modified;

                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Address"));
            }

            var tracker = Guid.NewGuid();

            Session["@Tracker"] = tracker;

            var applicant = _mapper.Map <Applicant>(viewModel);

            applicant.Tracker = tracker;

            _context.Applicant.Add(applicant);

            await _context.SaveChangesAsync();

            return(RedirectToAction("Create", "Address"));
        }
        public async Task <IActionResult> Update(int id, ApplicantViewModel applicantViewModel)
        {
            try
            {
                if (id != applicantViewModel.Id)
                {
                    return(BadRequest());
                }

                var updateTuple = await _applicantService.Update(id, applicantViewModel);

                if (!updateTuple.isSuccess && string.IsNullOrEmpty(updateTuple.errorMessage))
                {
                    return(BadRequest(updateTuple.errorMessage));
                }
                else if (!updateTuple.isSuccess && !string.IsNullOrEmpty(updateTuple.errorMessage))
                {
                    return(NotFound());
                }

                return(NoContent());
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(NotFound());
            }
        }
        public ApplicantViewModel GetAccountInfoBy(string Email)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("SELECT [PasswordHash]");
            sb.Append("FROM [dbo].[AspNetUsers]");
            sb.Append("WHERE [Email] = '" + Email + "'");

            String             sql = sb.ToString();
            ApplicantViewModel app = new ApplicantViewModel();

            using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            app.Password = DatabaseHelper.CheckNullString(reader, 0);
                        }
                    }
                }
            }

            return(app);
        }
示例#8
0
        public ActionResult AllInfoApplicant(int applicantId)
        {
            ApplicantDTO       applicantDto       = service.GetApplicant(applicantId);
            FacultyDTO         facultyDTO         = service.GetFaculty(applicantDto.FacultyId);
            ApplicantViewModel applicantViewModel = new ApplicantViewModel()
            {
                Id          = applicantDto.Id,
                Surname     = applicantDto.Surname,
                Name        = applicantDto.Name,
                Patronym    = applicantDto.Patronym,
                EmailApp    = applicantDto.EmailApp,
                City        = applicantDto.City,
                Region      = applicantDto.Region,
                Education   = applicantDto.Education,
                Math        = applicantDto.Math,
                UkrLanguage = applicantDto.UkrLanguage,
                EngLanguage = applicantDto.EngLanguage,

                FacultyId = applicantDto.FacultyId,
                Faculty   = new Faculty()
                {
                    Id = facultyDTO.Id, Name = facultyDTO.Name, QtyBudget = facultyDTO.QtyBudget, QtyAll = facultyDTO.QtyAll, Applicants = facultyDTO.Applicants
                }
            };

            return(View(applicantViewModel));
        }
        public async Task <IActionResult> Add(ApplicantViewModel applicantViewModel)
        {
            try
            {
                var validator = new ApplicantValidator();
                var result    = validator.Validate(applicantViewModel);
                if (!result.IsValid)
                {
                    return(BadRequest(result.Errors));
                }

                var addTuple = await _applicantService.Add(applicantViewModel);

                if (string.IsNullOrEmpty(addTuple.errorMessage))
                {
                    return(CreatedAtAction(nameof(Get), new { id = addTuple.applicantViewModel.Id }, addTuple.applicantViewModel));
                }
                else
                {
                    return(BadRequest(addTuple.errorMessage));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
        public applicant ToModel(ApplicantViewModel a)
        {
            return(new applicant
            {
                ApplicantID = a.ApplicantID,

                Email = a.Email,

                FirstName = a.FirstName,

                LastName = a.LastName,

                University = a.University,

                Alumni = a.Alumni,

                Profile = a.Profile,

                SocialMedia = a.SocialMedia,

                Resume = a.Resume,

                YearsExperience = a.YearsExperience,

                Internship = a.Internship,

                Active = a.Active,

                Fields = a.Fields
            });
        }
示例#11
0
 public void Insert(ApplicantViewModel ap)
 {
     using (_repository = new ApplicantRepository())
     {
         _repository.Insert(Mapper.MapingApplicant(ap));
     }
 }
示例#12
0
        public async Task <List <ApplicantViewModel> > ReadFromExcel(string TechName)
        {
            List <ApplicantViewModel> list = new List <ApplicantViewModel>();

            try
            {
                for (int i = 2; i <= this.xlRange.Rows.Count; i++)
                {
                    ApplicantViewModel applicant = (ApplicantViewModel)Activator.CreateInstance(typeof(ApplicantViewModel));
                    applicant.FirstName = xlRange.Cells[i, 1].Value2.ToString();
                    applicant.LastName  = xlRange.Cells[i, 2].Value2.ToString();
                    applicant.Email     = xlRange.Cells[i, 3].Value2.ToString();
                    applicant.Phone1    = xlRange.Cells[i, 4].Value2.ToString();
                    string sDate    = xlRange.Cells[i, 9].Value2.ToString();
                    double date     = double.Parse(sDate);
                    var    dateTime = DateTime.FromOADate(date).ToShortDateString();
                    applicant.Date        = Helper.GetDate(dateTime);
                    applicant.Description = xlRange.Cells[i, 8].Value2.ToString();
                    TechnologyController techctrl = new TechnologyController();
                    applicant.Technology = await techctrl.GetByNameAsync(TechName);

                    list.Add(applicant);
                }
            }
            finally
            {
                this.xlWorkbook.Close();
            }
            return(list);
        }
示例#13
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create(ApplicantViewModel model, CancellationToken cancellationToken)
        {
            var user = userManager.GetUserAsync(User);

            if (user.Result.IsFirstLogin)
            {
                return(View("~/Views/Home/ChangePassword.cshtml"));
            }

            var applicant = await this.applicantService.AddAsync(model.ToServiceModel(), cancellationToken);

            //return CreatedAtAction(nameof(GetByIdAsync), new { id = loanApplication.Id }, loanApplication.ToViewModel());
            //model.Id = applicant.Id;

            var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            var name = HttpContext.User.Identity.Name;

            // TODO service get user by email/username

            var loanViewModel = new LoanApplicationViewModel {
                ApplicantId = applicant.Id, OpenedById = userId, EmailId = model.EmailId
            };

            return(PartialView("_CreateLoanPartial", loanViewModel));
        }
示例#14
0
        public async Task <IActionResult> Edit(/*Guid id, */ ApplicantViewModel model, CancellationToken cancellationToken)
        {
            var user = userManager.GetUserAsync(User);

            if (user.Result.IsFirstLogin)
            {
                return(View("~/Views/Home/ChangePassword.cshtml"));
            }
            //model.Id = id;
            var applicant = await this.applicantService.UpdateAsync(model.ToServiceModel(), cancellationToken);

            //if (applicant is null)
            //{
            //    return NotFound();
            //}

            //return View("", loanApplication.ToViewModel());

            var name = HttpContext.User.Identity.Name;

            // get logged user id
            var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;


            var loanViewModel = new LoanApplicationViewModel {
                ApplicantId = applicant.Id, OpenedById = userId, EmailId = model.EmailId
            };

            return(PartialView("_CreateLoanPartial", loanViewModel));
        }
示例#15
0
        public async Task <ActionResult> _ApplicantReport(ApplicantReport model)
        {
            DateTime startDateTime = model.DateFrom;
            DateTime endDateTime   = model.DateTo.AddDays(1).AddTicks(-1);

            var user = await _userManager.GetUserAsync(HttpContext.User);

            var applicants = await _context.Applicants.Include(a => a.Position).Where(a => a.Status.Equals(model.ApplicantStatus))
                             .Where(a => a.DateCreated >= startDateTime && a.DateCreated <= endDateTime).ToListAsync();



            ApplicantViewModel m = new ApplicantViewModel();

            m.Applicants  = new List <Applicant>(applicants);
            m.DateFrom    = model.DateFrom;
            m.DateTo      = model.DateTo;
            m.GeneratedBy = user.FirstName + " " + user.LastName;

            return(new ViewAsPdf("_ApplicantReport", m)
            {
                PageOrientation = Orientation.Landscape,
                FileName = "APPLICANT_REP_" + DateTime.Now + ".pdf"
            });

            return(View(m));
        }
示例#16
0
        public async Task <ActionResult> RegisterApplicant(ApplicantViewModel model, HttpPostedFileBase fileUpload, FormCollection collection)
        {
            FieldDatabaseDataService Fds = new FieldDatabaseDataService();

            List <field> fields = Fds.Read();

            ViewBag.Fields         = fields;
            ViewBag.ErrCheckFields = model.Fields;
            ViewBag.States         = DAL.DataSettings.US_STATES;

            if (IsValidCaptcha())
            {
                if (ModelState.IsValid)
                {
                    var user = new ApplicationUser {
                        UserName = model.Email, Email = model.Email
                    };
                    var result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        try
                        {
                            UserManager.AddToRole(user.Id, "Applicant");
                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                            // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                            // Send an email with this link
                            // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                            // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                            // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                            if (fileUpload != null)
                            {
                                model.Resume = DAL.DatabaseHelper.UploadFile(DAL.DataSettings.RESUME_DIRECTORY, fileUpload, Server);
                            }
                            DAL.ApplicantRepository ar         = new DAL.ApplicantRepository();
                            List <applicant>        applicants = ar.SelectAll().ToList();

                            model.Active = true;
                            ar.Insert(ar.ToModel(model));

                            LoginViewModel loginModel = new LoginViewModel();
                            loginModel.Email = model.Email;

                            return(RedirectToAction("Index", "Home"));
                        }
                        catch (ArgumentException e)
                        {
                            ViewBag.Error = e.Message;
                            return(View());
                        }
                    }
                    AddErrors(result);
                }
            }
            // If we got this far, something failed, redisplay form
            return(View());
        }
示例#17
0
        public ActionResult Apply()
        {
            var model = new ApplicantViewModel();

            @ViewBag.FullAccessMask = Properties.Settings.Default.FullAPIAccessMask.ToString();

            return(View(model));
        }
示例#18
0
 public async void InsertOrUpdate(ApplicantViewModel ap)
 {
     using (_repository = new ApplicantRepository())
     {
         _repository.InsertOrUpdate(Mapper.MapingApplicant(ap));
         await _repository.SaveAsync();
     }
 }
示例#19
0
        public ApplicantViewModel SaveApplicant(ApplicantViewModel model)
        {
            var applicant          = _mapper.Map <ApplicantViewModel, Applicant>(model);
            var result             = _applicantRepository.SaveApplicantInfo(applicant);
            var applicantViewModel = _mapper.Map <Applicant, ApplicantViewModel>(result);

            return(applicantViewModel);
        }
        public async Task <ApplicantViewModel> Add(ApplicantViewModel applicantViewModel)
        {
            var applicant = _mapper.Map <Applicant>(applicantViewModel);

            applicants.Add(applicant);


            return(_mapper.Map <ApplicantViewModel>(applicant));
        }
示例#21
0
 public ActionResult Edit(ApplicantViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     DP.Edit(model);
     return(RedirectToAction("Applicants", "Admin"));
 }
示例#22
0
        public ActionResult ApplicantDetails(int id)
        {
            ApplicantRepository applicantRepository = new ApplicantRepository();
            ApplicantViewModel  applicant           = applicantRepository.SelectOneAsViewModel(id);

            ViewBag.Fields = applicant.Fields;

            return(View(applicant));
        }
示例#23
0
        public async Task <(bool isSuccess, string errorMessage)> Update(int id, ApplicantViewModel applicantViewModel)
        {
            if (await _applicantRepository.IsEmailExist(applicantViewModel.EmailAddress, id))
            {
                return(false, Resource.Error_EmailDuplicated);
            }
            bool isSuccess = await _applicantRepository.Update(id, applicantViewModel);

            return(isSuccess, string.Empty);
        }
示例#24
0
        public async Task <ApplicantViewModel> GetApplicant(int ID)
        {
            ApplicantViewModel applicantViewModel = null;

            using (_repository = new ApplicantRepository())
            {
                applicantViewModel = Mapper.MapingApplicantViewModel(await _repository.GetByIDAsync(ID));
            }
            return(applicantViewModel);
        }
示例#25
0
        public async Task <ApplicantViewModel> GetByIdAsync(int id)
        {
            ApplicantViewModel ap = new ApplicantViewModel();

            using (_repository = new ApplicantRepository())
            {
                ap = Mapper.MapingApplicantViewModel(await _repository.GetByIDAsync(id));
            }
            return(ap);
        }
        public ApplicantViewModel SelectOneAsViewModel(int id)
        {
            applicant app = _ds.Read(id);

            ApplicantViewModel selectedApplicant = ToViewModel(app);

            GetAccountInfoByUserID(selectedApplicant);

            return(selectedApplicant);
        }
        public async Task <ApplicantViewModel> Add(ApplicantViewModel applicantViewModel)
        {
            var applicant = _mapper.Map <Applicant>(applicantViewModel);

            await _context.Applicants.AddAsync(applicant);

            await _context.SaveChangesAsync();

            return(_mapper.Map <ApplicantViewModel>(applicant));
        }
        public ActionResult EditApplicant([Bind(Include = "ApplicantID,Email,FirstName,LastName,Fields,University,Alumni,Profile,SocialMedia,Resume,YearsExperience,Internship")] ApplicantViewModel applicant, HttpPostedFileBase fileUpload, FormCollection collection)
        {
            if (User.Identity.GetUserName() == applicant.Email)
            {
                try
                {
                    TechCareerFair.DAL.FieldDAL.FieldRepository fr = new TechCareerFair.DAL.FieldDAL.FieldRepository();
                    List <field> fields = fr.SelectAll().ToList();
                    foreach (field f in fields)
                    {
                        bool isChecked = Convert.ToBoolean(collection[f.Name].Split(',')[0]);

                        if (!applicant.Fields.Contains(f.Name) && isChecked)
                        {
                            applicant.Fields.Add(f.Name);
                        }
                        else if (applicant.Fields.Contains(f.Name) && !isChecked)
                        {
                            applicant.Fields.Remove(f.Name);
                        }
                    }

                    if (collection["removeResume"] != null && Convert.ToBoolean(collection["removeResume"].Split(',')[0]))
                    {
                        applicant.Resume = "";
                        if ((System.IO.File.Exists(Server.MapPath("~") + applicant.Resume)))
                        {
                            System.IO.File.Delete(Server.MapPath("~") + applicant.Resume);
                        }
                    }

                    if (fileUpload != null)
                    {
                        applicant.Resume = DatabaseHelper.UploadFile(DataSettings.RESUME_DIRECTORY, fileUpload, Server);
                    }

                    ApplicantRepository applicantRepository = new ApplicantRepository();
                    applicantRepository.UpdateApplicantProfile(applicantRepository.ToModel(applicant), Server.MapPath("~"));

                    //applicant = applicantRepository.SelectOne(id);

                    return(GetUserType(null));
                }
                catch (ArgumentException e)
                {
                    ViewBag.Error = e.Message;
                    return(View(applicant));
                }
            }
            else
            {
                return(RedirectToAction("AccessDenied", "Error"));
            }
        }
示例#29
0
 public AboutApplicant(ApplicantViewModel applicant, MainWindow parent, PersonsListWindow personsListWindow) : this(parent, personsListWindow)
 {
     this.applicant            = applicant;
     this.nameLabel.Content    = this.applicant.FirstName;
     this.surNameLabel.Content = this.applicant.LastName;
     this.phoneLabel.Content   = this.applicant.Phone1;
     this.emailLabel.Content   = this.applicant.Email;
     this.DescriptionLable.AppendText(this.applicant.Description);
     this.DateLable.Content = this.applicant.Date;
     this.TechName.Content  = this.applicant.Technology.Name;
 }
示例#30
0
        public void Edit(ApplicantViewModel model)
        {
            var applicantToEdit = _db.Applicants.FirstOrDefault(x => x.Id == model.Id);

            applicantToEdit.FirstName   = model.FirstName;
            applicantToEdit.LastName    = model.LastName;
            applicantToEdit.PhoneNumber = model.PhoneNumber;
            applicantToEdit.Bio         = model.Bio;

            _db.SaveChanges();
        }