예제 #1
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new Jobseeker {
                    UserName = Input.UserName, Email = Input.Email, Firstname = Input.Firstname, Lastname = Input.Lastname, DateOfBirth = Input.DateOfBirth
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _userManager.AddToRoleAsync(user, "Jobseeker").Wait();
                    _logger.LogInformation("User created a new account with password.");


                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(LocalRedirect(returnUrl));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
예제 #2
0
        public ActionResult Save(Jobseeker jobseeker)
        {
            //if (!ModelState.IsValid)
            //{
            //    return View("JobseekerForm");
            //}
            if (jobseeker.Id == 0)
            {
                _context.Jobseekers.Add(jobseeker);
            }

            else
            {
                var jobseekerInDb = _context.Jobseekers.Single(c => c.Id == jobseeker.Id);

                jobseekerInDb.J_Name     = jobseeker.J_Name;
                jobseekerInDb.J_Email    = jobseeker.J_Email;
                jobseekerInDb.J_Address  = jobseeker.J_Address;
                jobseekerInDb.J_DOB      = jobseeker.J_DOB;
                jobseekerInDb.J_City     = jobseeker.J_City;
                jobseekerInDb.J_Cnumber  = jobseeker.J_Cnumber;
                jobseekerInDb.J_Country  = jobseeker.J_Country;
                jobseekerInDb.J_Gender   = jobseeker.J_Gender;
                jobseekerInDb.J_State    = jobseeker.J_State;
                jobseekerInDb.Extra_achi = jobseeker.Extra_achi;
                jobseekerInDb.User_type  = jobseeker.User_type;
                jobseekerInDb.Skill_area = jobseeker.Skill_area;
                jobseekerInDb.Exp_detail = jobseeker.Exp_detail;
            }
            _context.SaveChanges();

            return(RedirectToAction("Index", "Jobseekers"));
        }
예제 #3
0
        public JsonResult GetMatchingDetail2(string applicantID1, string applicantID2, int jobID)
        {
            if (!String.IsNullOrEmpty(applicantID1) &&
                !String.IsNullOrEmpty(applicantID2))
            {
                AppliedJob appliedJob1 = applicantUnitOfWork.AppliedJobRepository.Get(s => s.JobSeekerID == applicantID1 && s.JobID == jobID).FirstOrDefault();
                AppliedJob appliedJob2 = applicantUnitOfWork.AppliedJobRepository.Get(s => s.JobSeekerID == applicantID2 && s.JobID == jobID).FirstOrDefault();

                if (appliedJob1 != null && appliedJob2 != null)
                {
                    int profileID1 = appliedJob1.ProfileID;
                    int profileID2 = appliedJob2.ProfileID;

                    var sosanhItemList1 = applicantUnitOfWork.GetMatchingDetail(profileID1, jobID);
                    var sosanhItemList2 = applicantUnitOfWork.GetMatchingDetail(profileID2, jobID);

                    Jobseeker applicant1 = applicantUnitOfWork.JobseekerRepository.GetByID(applicantID1);
                    Jobseeker applicant2 = applicantUnitOfWork.JobseekerRepository.GetByID(applicantID2);

                    return(Json(new { profile1 = sosanhItemList1, profile2 = sosanhItemList2, applicantname1 = applicant1.FullName, applicantname2 = applicant2.FullName }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(this.Json(string.Empty));
                }
            }
            else
            {
                return(this.Json(string.Empty));
            }
        }
 public ActionResult Create(Jobseeker Jobseeker)
 {
     Jobseeker.JobseekerId   = Guid.NewGuid();
     Jobseeker.ApplicationId = User.Identity.GetUserId();
     db.Jobseekers.Add(Jobseeker);
     db.SaveChanges();
     return(RedirectToAction("Index", "Jobseeker", new { id = Jobseeker.JobseekerId }));
 }
예제 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Jobseeker jobseeker = _context.Jobseekers.Find(id);

            _context.Jobseekers.Remove(jobseeker);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,FirstName,MiddleName,LastName,Address,PermanentAddress,DateOfBirth")] Jobseeker jobseeker)
 {
     if (ModelState.IsValid)
     {
         db.Entry(jobseeker).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(jobseeker));
 }
예제 #7
0
 public ActionResult Edit([Bind(Include = "JobseekerId,Name,Email,Password,PhoneNo,Qualification,FieldOfStudy,PreferredLocation,PreferredSalary,PreferredField,Resume,Picture")] Jobseeker jobseeker)
 {
     if (ModelState.IsValid)
     {
         db.Entry(jobseeker).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(jobseeker));
 }
        public ActionResult Create([Bind(Include = "Id,FirstName,MiddleName,LastName,Address,PermanentAddress,DateOfBirth")] Jobseeker jobseeker)
        {
            if (ModelState.IsValid)
            {
                db.Jobseekers.Add(jobseeker);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(jobseeker));
        }
예제 #9
0
        public ActionResult Create([Bind(Include = "JobseekerId,Name,Email,Password,PhoneNo,Qualification,FieldOfStudy,PreferredLocation,PreferredSalary,PreferredField,Resume,Picture")] Jobseeker jobseeker)
        {
            if (ModelState.IsValid)
            {
                db.Jobseekers.Add(jobseeker);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(jobseeker));
        }
        // GET: Interview/Create
        public ActionResult Create(Guid?id)
        {
            var       userId    = User.Identity.GetUserId();
            Jobseeker jobseeker = db.Jobseekers.FirstOrDefault(t => t.ApplicationId == userId);

            new Checklist {
                ChecklistId = Guid.NewGuid()
            };
            return(View(new Interview {
                InterviewId = Guid.NewGuid(), JobseekerId = jobseeker.JobseekerId
            }));
        }
예제 #11
0
        public ActionResult Insert(SignUpViewModel model, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                //    var file = Request.Files[0];
//                byte[] uploadedFile = new byte[model.Picture.InputStream.Length];


                Jobseeker jobseeker = new Jobseeker();
                jobseeker.Name              = model.Name;
                jobseeker.Email             = model.Email;
                jobseeker.Password          = model.Password;
                jobseeker.PhoneNo           = model.PhoneNo;
                jobseeker.Qualification     = model.Qualification;
                jobseeker.FieldOfStudy      = model.FieldOfStudy;
                jobseeker.PreferredLocation = model.PreferredLocation;
                jobseeker.PreferredSalary   = model.PreferredSalary;
                jobseeker.PreferredField    = model.PreferredField;
                //           model.Picture.InputStream.Read(uploadedFile,0,uploadedFile.Length);

                db.Jobseekers.Add(jobseeker);
                db.SaveChanges();

                int lastId = jobseeker.JobseekerId;

                Language language = new Language();
                language.LanguageLearned = model.LanguageLearned;
                language.JobseekerId     = lastId;

                db.Languages.Add(language);
                db.SaveChanges();

                WorkingExperience exp = new WorkingExperience();
                exp.WorkingExp  = model.WorkingExp;
                exp.JobseekerId = lastId;

                db.WorkingExperiences.Add(exp);
                db.SaveChanges();

                Skill skill = new Skill();
                skill.SkillAcquired = model.SkillAcquired;
                skill.JobseekerId   = lastId;

                db.Skills.Add(skill);
                db.SaveChanges();
                int lastProductId = db.Jobseekers.Max(item => item.JobseekerId);
                return(RedirectToAction("Details", new { id = lastProductId }));
            }
            return(View(model));
        }
예제 #12
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Jobseeker jobseeker = _context.Jobseekers.Find(id);

            if (jobseeker == null)
            {
                return(HttpNotFound());
            }
            return(View(jobseeker));
        }
예제 #13
0
        public bool ApplyJob(int jobID, int profileID, string userID)
        {
            Job       job       = this.JobRepository.GetByID(jobID);
            Profile   profile   = this.ProfileRepository.GetByID(profileID);
            Jobseeker jobseeker = this.JobseekerRepository.GetByID(userID);

            if (job != null && profile != null && jobseeker != null)
            {
                AppliedJob appliedJob = this.AppliedJobRepository.Get(s => s.JobID == jobID && s.JobSeekerID == userID).FirstOrDefault();
                if (appliedJob != null)
                {
                    if (appliedJob.IsDeleted == true)
                    {
                        appliedJob.ProfileID       = profileID;
                        appliedJob.ApplyDate       = DateTime.Now;
                        appliedJob.MatchingPercent = this.Matching(profileID, jobID);
                        appliedJob.Status          = 0;
                        appliedJob.AcceptDate      = null;
                        appliedJob.IsDeleted       = false;
                        this.AppliedJobRepository.Update(appliedJob);
                        this.Save();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    AppliedJob newAppliedJob = new AppliedJob();
                    newAppliedJob.JobID           = jobID;
                    newAppliedJob.ProfileID       = profileID;
                    newAppliedJob.JobSeekerID     = userID;
                    newAppliedJob.ApplyDate       = DateTime.Now;
                    newAppliedJob.MatchingPercent = this.Matching(profileID, jobID);
                    newAppliedJob.Status          = 0;
                    newAppliedJob.AcceptDate      = null;
                    newAppliedJob.IsDeleted       = false;

                    this.AppliedJobRepository.Insert(newAppliedJob);
                    this.Save();

                    return(true);
                }
            }

            return(false);
        }
예제 #14
0
        public void SendEmail(string receiverUsername, string title, string content)
        {
            if (!String.IsNullOrEmpty(receiverUsername) &&
                !String.IsNullOrEmpty(title) &&
                !String.IsNullOrEmpty(content))
            {
                AspNetUser user = this.AspNetUserRepository.Get(s => s.UserName == receiverUsername).FirstOrDefault();
                if (user == null)
                {
                    return;
                }

                try
                {
                    MailMessage mail       = new MailMessage();
                    SmtpClient  smtpClient = new SmtpClient("smtp.gmail.com");

                    UnitOfWork unitOfWork = new UnitOfWork();
                    mail.From = new MailAddress("*****@*****.**");
                    Jobseeker jobseeker = unitOfWork.JobseekerRepository.GetByID(user.Id);
                    Recruiter recruiter = unitOfWork.RecruiterRepository.GetByID(user.Id);
                    if (jobseeker != null)
                    {
                        mail.To.Add(jobseeker.Email);
                    }
                    else if (recruiter != null)
                    {
                        mail.To.Add(recruiter.Email);
                    }
                    else
                    {
                        return;
                    }
                    mail.Subject    = "[JSS] " + title;
                    mail.IsBodyHtml = true;
                    mail.Body       = content;

                    smtpClient.Port        = 587;
                    smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Kogarashi789");
                    smtpClient.EnableSsl   = true;

                    smtpClient.Send(mail);
                }
                catch (Exception)
                {
                    return;
                }
            }
        }
        //Jobseeker responds to a jobposting
        // GET: Application/ NewSubmission
        public ActionResult NewSubmission(Guid?id)
        {
            //find user logged in
            var       userId    = User.Identity.GetUserId();
            Jobseeker jobseeker = db.Jobseekers.FirstOrDefault(j => j.ApplicationId == userId);
            //find jobPosting that user clicked apply on
            JobPosting jobPostingRespondingTo = db.JobPostings.Where(i => i.JobPostingId == id).SingleOrDefault();

            new Application {
                ApplicationId = Guid.NewGuid()
            };
            return(View(new Application {
                ApplicationId = Guid.NewGuid(), JobPostingId = jobPostingRespondingTo.JobPostingId
            }));
        }
        public async Task <ActionResult> Create(Interview interview, Checklist checklist)
        {
            //logged in user
            var       userId        = User.Identity.GetUserId();
            Jobseeker thisJobseeker = db.Jobseekers.FirstOrDefault(j => j.ApplicationId == userId);

            interview.JobseekerId = thisJobseeker.JobseekerId;
            interview.InterviewId = Guid.NewGuid();
            await GetDistanceAndDuration(thisJobseeker, interview);

            db.Interviews.Add(interview);
            checklist.ChecklistId = Guid.NewGuid();
            checklist.InterviewId = interview.InterviewId;
            db.Checklists.Add(checklist);
            db.SaveChanges();
            return(RedirectToAction("ViewInterviews", "Jobseeker"));
        }
예제 #17
0
        public ActionResult Index(Jobseeker jobseeker)
        {
            var userLoggedIn = db.Jobseekers.SingleOrDefault(x => x.Email == jobseeker.Email && x.Password == jobseeker.Password);

            if (userLoggedIn != null)
            {
                Session["Email"] = jobseeker.Email;
                var registedUserID = db.Jobseekers.FirstOrDefault(x => x.Email == jobseeker.Email);

                int    id   = registedUserID.JobseekerId;
                string name = registedUserID.Name;
                return(RedirectToAction("main", "jobseekers", new { id = id, Name = name }));
            }
            else
            {
                return(View());
            }
        }
예제 #18
0
        public bool UpdateContact(Contact contact)
        {
            Jobseeker jobseeker = this.JobseekerRepository.GetByID(contact.UserID);

            if (jobseeker == null)
            {
                return(false);
            }
            if (jobseeker.IsDeleted == true)
            {
                return(false);
            }

            try
            {
                if (this.ContactRepository.GetByID(jobseeker.JobSeekerID) == null)
                {
                    this.ContactRepository.Insert(contact);
                    this.Save();
                }
                else
                {
                    Contact contactToUpdate = this.ContactRepository.GetByID(jobseeker.JobSeekerID);
                    contactToUpdate.FullName      = contact.FullName;
                    contactToUpdate.Gender        = contact.Gender;
                    contactToUpdate.MaritalStatus = contact.MaritalStatus;
                    contactToUpdate.Nationality   = contact.Nationality;
                    contactToUpdate.Address       = contact.Address;
                    contactToUpdate.DateofBirth   = contact.DateofBirth;
                    contactToUpdate.PhoneNumber   = contact.PhoneNumber;
                    contactToUpdate.CityID        = contact.CityID;
                    contactToUpdate.District      = contact.District;
                    contactToUpdate.IsVisible     = contact.IsVisible;
                    this.ContactRepository.Update(contactToUpdate);
                    this.Save();
                }
            }
            catch (DataException)
            {
                return(false);
            }

            return(true);
        }
        public ActionResult ViewInterviews()
        {
            var      userId     = User.Identity.GetUserId();
            DateTime currentDay = DateTime.Now;
            //first find jobseeker logged in
            Jobseeker jobseeker = db.Jobseekers.FirstOrDefault(j => j.ApplicationId == userId);
            //then find all itineraries that jobseeker has (jobseeker id)
            //db.Interviews.Where(i => i.JobseekerId == jobseeker.JobseekerId).ToList();
            List <Interview> jobseekerInterviews = db.Interviews.Where(i => i.JobseekerId == jobseeker.JobseekerId).ToList();
            List <Interview> descendingOrder     = jobseekerInterviews.Where(i => i.DateAndTimeOfInterview > currentDay).OrderByDescending(i => i.DateAndTimeOfInterview).ToList();
            List <Interview> ascendingOrder      = new List <Interview>();

            for (int i = descendingOrder.Count - 1; i >= 0; i--)
            {
                //add current i to list
                ascendingOrder.Add(descendingOrder[i]);
            }

            return(View(ascendingOrder));
        }
        public async Task GetDistanceAndDuration(Jobseeker jobseeker, Interview interview)
        {
            string              jobseekerAddress = jobseeker.HomeAddress;
            string              interviewAddress = interview.CompanyAddress;
            var                 key      = APIKey.GoogleDirectionsKey;
            string              url      = $"https://maps.googleapis.com/maps/api/directions/json?origin={jobseekerAddress}&destination={interviewAddress}&key={key}";
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(url);

            string jsonresult = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                DirectionsJSON directionsJSON = JsonConvert.DeserializeObject <DirectionsJSON>(jsonresult);
                string         duration       = directionsJSON.routes[0].legs[0].duration.text;
                interview.DurationToInterview = duration;
                string distance = directionsJSON.routes[0].legs[0].distance.text;
                interview.DistanceToInterview = distance;
            }
        }
예제 #21
0
        public ActionResult Edit(int?id)
        {
            Jobseeker jobseeker = db.Jobseekers.Find(id);
            var       result    = from language in db.Languages
                                  join name in db.Jobseekers on language.JobseekerId equals name.JobseekerId
                                  join skill in db.Skills on name.JobseekerId equals skill.JobseekerId
                                  join exp in db.WorkingExperiences on skill.JobseekerId equals exp.JobseekerId
                                  where name.JobseekerId == id
                                  select new SignUpViewModel()
            {
                LanguageLearned = language.LanguageLearned,
                Name            = name.Name,
                SkillAcquired   = skill.SkillAcquired,
                WorkingExp      = exp.WorkingExp,
                JobseekerId     = name.JobseekerId,
                Email           = name.Email,
            };

            return(View(result));
        }
        public ActionResult NewSubmission(Application application, JobPosting jobPosting)
        {
            //find logged in user
            var       userId    = User.Identity.GetUserId();
            Jobseeker jobseeker = db.Jobseekers.FirstOrDefault(j => j.ApplicationId == userId);

            //link application to jobposting
            application.JobPostingId = jobPosting.JobPostingId;
            //new id for application
            application.ApplicationId = Guid.NewGuid();
            db.Applications.Add(application);
            //connnect to JobseekerApplication "junction" table
            JobseekerApplication jobseekerApplication = new JobseekerApplication();

            jobseekerApplication.JobseekerApplicationId = Guid.NewGuid();
            jobseekerApplication.JobseekerId            = jobseeker.JobseekerId;
            jobseekerApplication.ApplicationId          = application.ApplicationId;
            db.JobseekerApplications.Add(jobseekerApplication);
            db.SaveChanges();
            return(View("ApplicationSubmitted"));
        }
예제 #23
0
        public JsonResult GetMatchingDetail4(string profileID1, string profileID2, int jobID)
        {
            if (!String.IsNullOrEmpty(profileID1) &&
                !String.IsNullOrEmpty(profileID2))
            {
                int profileID1Num = Int32.Parse(profileID1);
                int profileID2Num = Int32.Parse(profileID2);

                var sosanhItemList1 = applicantUnitOfWork.GetMatchingDetail(profileID1Num, jobID);
                var sosanhItemList2 = applicantUnitOfWork.GetMatchingDetail(profileID2Num, jobID);

                Jobseeker applicant1 = applicantUnitOfWork.JobseekerRepository.GetByID(applicantUnitOfWork.ProfileRepository.GetByID(profileID1Num).JobSeekerID);
                Jobseeker applicant2 = applicantUnitOfWork.JobseekerRepository.GetByID(applicantUnitOfWork.ProfileRepository.GetByID(profileID2Num).JobSeekerID);

                return(Json(new { profile1 = sosanhItemList1, profile2 = sosanhItemList2, applicantname1 = applicant1.FullName, applicantname2 = applicant2.FullName }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(this.Json(string.Empty));
            }
        }
예제 #24
0
        public async Task<ActionResult> Register([Bind(Include = "UserName, Password, ConfirmPassword, Email, FullName, PhoneNumber, RoleName")]RegisterViewModel model, string returnUrl)
        {
            UnitOfWork unitOfWork = new UnitOfWork();
            AspNetUser u = unitOfWork.AspNetUserRepository.Get(s => s.UserName == model.UserName).FirstOrDefault();
            if (u != null)
            {
                TempData["warningmessage"] = "Username đã tồn tại, xin hãy dùng Username khác!";

                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return Redirect("../" + returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            Jobseeker js = accountUnitOfWork.JobseekerRepository.Get(s => s.Email == model.Email).FirstOrDefault();
            Recruiter rc = accountUnitOfWork.RecruiterRepository.Get(s => s.Email == model.Email).FirstOrDefault();
            if (js != null || rc != null)
            {
                TempData["warningmessage"] = "Email đã tồn tại, xin hãy dùng Email khác!";

                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return Redirect("../" + returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            var user = new ApplicationUser() { UserName = model.UserName };
            var result = await UserManager.CreateAsync(user, model.Password);
            if (result.Succeeded)
            {
                var createdUser = await UserManager.FindAsync(model.UserName, model.Password);
                var roleResult = await UserManager.AddToRoleAsync(createdUser.Id, model.RoleName);
                if (model.RoleName == "Recruiter")
                {
                    Recruiter recruiter = new Recruiter();
                    recruiter.RecruiterID = createdUser.Id;
                    recruiter.Email = model.Email;
                    recruiter.IsDeleted = false;
                    unitOfWork.RecruiterRepository.Insert(recruiter);
                    unitOfWork.Save();

                    await SignInAsync(user, isPersistent: false);
                    TempData["warningmessage"] = "Đăng ký thành công, xin hãy cập nhật thông tin công ty!";
                    return RedirectToAction("Update", "CompanyInfo");
                }
                else
                {
                    Jobseeker jobseeker = new Jobseeker();
                    jobseeker.JobSeekerID = createdUser.Id;
                    jobseeker.Email = model.Email;
                    jobseeker.FullName = model.FullName;
                    jobseeker.PhoneNumber = model.PhoneNumber;
                    jobseeker.IsDeleted = false;
                    unitOfWork.JobseekerRepository.Insert(jobseeker);
                    unitOfWork.Save();

                    await SignInAsync(user, isPersistent: false);
                    TempData["successmessage"] = "Đăng ký thành công.";

                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return Redirect("../" + returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
            }
            else
            {
                TempData["errormessage"] = "Đăng ký thất bại!";

                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return Redirect("../" + returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
        }
예제 #25
0
        public bool UpdateSkill(string skillList, string jobseekerId)
        {
            if (!String.IsNullOrEmpty(jobseekerId) &&
                this.JobseekerRepository.GetByID(jobseekerId) != null)
            {
                Jobseeker jobseeker = this.JobseekerRepository.GetByID(jobseekerId);

                IEnumerable <OwnSkill> willbeRemovedSkills = this.OwnSkillRepository.Get(s => s.JobSeekerID == jobseeker.JobSeekerID).AsEnumerable();
                foreach (OwnSkill s in willbeRemovedSkills)
                {
                    this.OwnSkillRepository.Delete(s);
                }
                this.Save();

                if (!String.IsNullOrEmpty(skillList))
                {
                    List <string> skills = skillList.Split(',').ToList();
                    foreach (string skilltag in skills)
                    {
                        Skill oldSkill = this.SkillRepository.Get(s => s.SkillTag.ToUpper() == skilltag.ToUpper()).FirstOrDefault();

                        if (oldSkill != null)
                        {
                            OwnSkill newOwnSkill = new OwnSkill();
                            newOwnSkill.Skill_ID    = oldSkill.Skill_ID;
                            newOwnSkill.JobSeekerID = jobseeker.JobSeekerID;
                            newOwnSkill.IsDeleted   = false;

                            this.OwnSkillRepository.Insert(newOwnSkill);
                        }
                        else
                        {
                            Skill newSkill = new Skill();
                            newSkill.SkillTag  = skilltag;
                            newSkill.IsDeleted = false;

                            this.SkillRepository.Insert(newSkill);
                            this.Save();

                            Skill addedSkill = this.SkillRepository.Get(s => s.SkillTag.ToUpper() == skilltag.ToUpper()).LastOrDefault();
                            if (addedSkill != null)
                            {
                                OwnSkill newOwnSkill = new OwnSkill();
                                newOwnSkill.Skill_ID    = addedSkill.Skill_ID;
                                newOwnSkill.JobSeekerID = jobseeker.JobSeekerID;
                                newOwnSkill.IsDeleted   = false;

                                this.OwnSkillRepository.Insert(newOwnSkill);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                    this.Save();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #26
0
 public bool Delete(Jobseeker Entity)
 {
     _db.Jobseeker.Remove(Entity);
     return(Save());
 }
예제 #27
0
        public async Task <ActionResult> ResetPassword(string emailAdress, string returnUrl)
        {
            if (!String.IsNullOrEmpty(emailAdress))
            {
                var chars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                var random      = new Random();
                var newPassword = new string(Enumerable.Repeat(chars, 8)
                                             .Select(s => s[random.Next(s.Length)])
                                             .ToArray());
                string userId = "";

                try
                {
                    MailMessage mail       = new MailMessage();
                    SmtpClient  smtpClient = new SmtpClient("smtp.gmail.com");

                    UnitOfWork unitOfWork = new UnitOfWork();
                    mail.From = new MailAddress("*****@*****.**");
                    Jobseeker jobseeker = unitOfWork.JobseekerRepository.Get(s => s.Email == emailAdress && s.IsDeleted == false).FirstOrDefault();
                    Recruiter recruiter = unitOfWork.RecruiterRepository.Get(s => s.Email == emailAdress && s.IsDeleted == false).FirstOrDefault();
                    if (jobseeker != null)
                    {
                        mail.To.Add(jobseeker.Email);
                        userId = jobseeker.JobSeekerID;
                    }
                    else if (recruiter != null)
                    {
                        mail.To.Add(recruiter.Email);
                        userId = recruiter.RecruiterID;
                    }
                    else
                    {
                        TempData["errormessage"] = "Không tìm thấy Id tài khoản!";

                        if (!String.IsNullOrEmpty(returnUrl))
                        {
                            return(Redirect("../" + returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    mail.Subject = "[JSS] Thông báo mật khẩu mới";
                    mail.Body    = "Mật khẩu của bạn đã được tạo mới là: " + newPassword;

                    smtpClient.Port        = 587;
                    smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Kogarashi789");
                    smtpClient.EnableSsl   = true;

                    smtpClient.Send(mail);
                }
                catch (Exception)
                {
                    TempData["errormessage"] = "Quá trình gửi mật khẩu mới gặp lỗi!";

                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return(Redirect("../" + returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }

                await UserManager.RemovePasswordAsync(userId);

                IdentityResult result = await UserManager.AddPasswordAsync(userId, newPassword);

                if (result.Succeeded)
                {
                    TempData["successmessage"] = "Bạn hãy vào mail để xem mật khẩu mới.";
                }
                else
                {
                    TempData["errormessage"] = "Quá trình tạo mật khẩu mới gặp lỗi!";
                }
            }
            else
            {
                TempData["warningmessage"] = "Email trống!";
            }

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect("../" + returnUrl));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
예제 #28
0
 public bool Update(Jobseeker Entity)
 {
     _db.Jobseeker.Update(Entity);
     return(Save());
 }
예제 #29
0
        public async Task <ActionResult> Register([Bind(Include = "UserName, Password, ConfirmPassword, Email, FullName, PhoneNumber, RoleName")] RegisterViewModel model, string returnUrl)
        {
            UnitOfWork unitOfWork = new UnitOfWork();
            AspNetUser u          = unitOfWork.AspNetUserRepository.Get(s => s.UserName == model.UserName).FirstOrDefault();

            if (u != null)
            {
                TempData["warningmessage"] = "Username đã tồn tại, xin hãy dùng Username khác!";

                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect("../" + returnUrl));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }

            Jobseeker js = accountUnitOfWork.JobseekerRepository.Get(s => s.Email == model.Email).FirstOrDefault();
            Recruiter rc = accountUnitOfWork.RecruiterRepository.Get(s => s.Email == model.Email).FirstOrDefault();

            if (js != null || rc != null)
            {
                TempData["warningmessage"] = "Email đã tồn tại, xin hãy dùng Email khác!";

                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect("../" + returnUrl));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }

            var user = new ApplicationUser()
            {
                UserName = model.UserName
            };
            var result = await UserManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                var createdUser = await UserManager.FindAsync(model.UserName, model.Password);

                var roleResult = await UserManager.AddToRoleAsync(createdUser.Id, model.RoleName);

                if (model.RoleName == "Recruiter")
                {
                    Recruiter recruiter = new Recruiter();
                    recruiter.RecruiterID = createdUser.Id;
                    recruiter.Email       = model.Email;
                    recruiter.IsDeleted   = false;
                    unitOfWork.RecruiterRepository.Insert(recruiter);
                    unitOfWork.Save();

                    await SignInAsync(user, isPersistent : false);

                    TempData["warningmessage"] = "Đăng ký thành công, xin hãy cập nhật thông tin công ty!";
                    return(RedirectToAction("Update", "CompanyInfo"));
                }
                else
                {
                    Jobseeker jobseeker = new Jobseeker();
                    jobseeker.JobSeekerID = createdUser.Id;
                    jobseeker.Email       = model.Email;
                    jobseeker.FullName    = model.FullName;
                    jobseeker.PhoneNumber = model.PhoneNumber;
                    jobseeker.IsDeleted   = false;
                    unitOfWork.JobseekerRepository.Insert(jobseeker);
                    unitOfWork.Save();

                    await SignInAsync(user, isPersistent : false);

                    TempData["successmessage"] = "Đăng ký thành công.";

                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return(Redirect("../" + returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }
            else
            {
                TempData["errormessage"] = "Đăng ký thất bại!";

                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect("../" + returnUrl));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
        }
예제 #30
0
 public bool Create(Jobseeker Entity)
 {
     _db.Jobseeker.Add(Entity);
     return(Save());
 }
예제 #31
0
        public bool UpdateCommonInfo(Profile profile, int expectedCityNum, int categoryID)
        {
            Jobseeker jobseeker = this.JobseekerRepository.GetByID(profile.JobSeekerID);

            if (jobseeker == null)
            {
                return(false);
            }
            if (jobseeker.IsDeleted == true)
            {
                return(false);
            }

            try
            {
                if (this.ProfileRepository.Get(filter: d => d.Name == profile.Name && d.JobSeekerID == profile.JobSeekerID).FirstOrDefault() == null)
                {
                    // Add new
                    this.ProfileRepository.Insert(profile);
                    this.Save();

                    Profile insertedProfile = this.ProfileRepository.Get(filter: d => d.Name == profile.Name).LastOrDefault();
                    if (insertedProfile == null)
                    {
                        return(false);
                    }

                    City city = this.CityRepository.GetByID(expectedCityNum);
                    if (city != null)
                    {
                        ExpectedCity expectedCity = new ExpectedCity();
                        expectedCity.ProfileID = insertedProfile.ProfileID;
                        expectedCity.CityID    = city.CityID;
                        expectedCity.IsDeleted = false;

                        this.ExpectedCityRepository.Insert(expectedCity);
                        this.Save();
                    }

                    Category category = this.CategoryRepository.GetByID(categoryID);
                    if (category != null)
                    {
                        ExpectedCategory expectedCategory = new ExpectedCategory();
                        expectedCategory.ProfileID  = insertedProfile.ProfileID;
                        expectedCategory.CategoryID = category.CategoryID;
                        expectedCategory.IsDeleted  = false;

                        this.ExpectedCategoryRepository.Insert(expectedCategory);
                        this.Save();
                    }
                }
                else
                {
                    // Update
                    Profile profileToUpdate = this.ProfileRepository.Get(filter: d => d.Name == profile.Name && d.JobSeekerID == profile.JobSeekerID).FirstOrDefault();
                    profileToUpdate.YearOfExperience      = profile.YearOfExperience;
                    profileToUpdate.HighestSchoolLevel_ID = profile.HighestSchoolLevel_ID;
                    profileToUpdate.LanguageID            = profile.LanguageID;
                    profileToUpdate.Level_ID            = profile.Level_ID;
                    profileToUpdate.MostRecentCompany   = profile.MostRecentCompany;
                    profileToUpdate.MostRecentPosition  = profile.MostRecentPosition;
                    profileToUpdate.CurrentJobLevel_ID  = profile.CurrentJobLevel_ID;
                    profileToUpdate.ExpectedPosition    = profile.ExpectedPosition;
                    profileToUpdate.ExpectedJobLevel_ID = profile.ExpectedJobLevel_ID;
                    profileToUpdate.ExpectedSalary      = profile.ExpectedSalary;
                    profileToUpdate.UpdatedTime         = DateTime.Now;
                    profileToUpdate.Objectives          = profile.Objectives;
                    profileToUpdate.JobSeekerID         = profile.JobSeekerID;
                    profileToUpdate.IsActive            = profile.IsActive;
                    profileToUpdate.IsDeleted           = false;

                    this.ProfileRepository.Update(profileToUpdate);
                    this.Save();

                    IEnumerable <ExpectedCity> oldExpectedCities = this.ExpectedCityRepository.Get(filter: d => d.ProfileID == profileToUpdate.ProfileID).AsEnumerable();
                    foreach (ExpectedCity item in oldExpectedCities)
                    {
                        if (item.IsDeleted == false)
                        {
                            item.IsDeleted = true;
                            this.ExpectedCityRepository.Update(item);
                            this.Save();
                        }
                    }
                    ExpectedCity expectedCity = this.ExpectedCityRepository.Get(s => s.ProfileID == profileToUpdate.ProfileID && s.CityID == expectedCityNum).FirstOrDefault();
                    if (expectedCity != null)
                    {
                        expectedCity.IsDeleted = false;
                        this.ExpectedCityRepository.Update(expectedCity);
                        this.Save();
                    }
                    else
                    {
                        City city = this.CityRepository.GetByID(expectedCityNum);
                        if (city != null)
                        {
                            ExpectedCity newExpectedCity = new ExpectedCity();
                            newExpectedCity.ProfileID = profileToUpdate.ProfileID;
                            newExpectedCity.CityID    = city.CityID;
                            newExpectedCity.IsDeleted = false;

                            this.ExpectedCityRepository.Insert(newExpectedCity);
                            this.Save();
                        }
                    }

                    IEnumerable <ExpectedCategory> oldExpectedCategories = this.ExpectedCategoryRepository.Get(filter: d => d.ProfileID == profileToUpdate.ProfileID).AsEnumerable();
                    foreach (ExpectedCategory item in oldExpectedCategories)
                    {
                        if (item.IsDeleted == false)
                        {
                            item.IsDeleted = true;
                            this.ExpectedCategoryRepository.Update(item);
                            this.Save();
                        }
                    }
                    ExpectedCategory expectedCategory = this.ExpectedCategoryRepository.Get(s => s.ProfileID == profileToUpdate.ProfileID && s.CategoryID == categoryID).FirstOrDefault();
                    if (expectedCategory != null)
                    {
                        expectedCategory.IsDeleted = false;
                        this.ExpectedCategoryRepository.Update(expectedCategory);
                        this.Save();
                    }
                    else
                    {
                        Category category = this.CategoryRepository.GetByID(categoryID);
                        if (category != null)
                        {
                            ExpectedCategory newExpectedCategory = new ExpectedCategory();
                            newExpectedCategory.ProfileID  = profileToUpdate.ProfileID;
                            newExpectedCategory.CategoryID = category.CategoryID;
                            newExpectedCategory.IsDeleted  = false;

                            this.ExpectedCategoryRepository.Insert(newExpectedCategory);
                            this.Save();
                        }
                    }
                }
            }
            catch (DataException)
            {
                return(false);
            }

            return(true);
        }