Ejemplo n.º 1
0
        public JsonResult Create(ResumeModel model)
        {
            UserResume candidate = new UserResume();

            candidate.JobProfession  = model.JobProfession;
            candidate.ExpierenceYear = model.ExperienceYear;
            candidate.UserId         = _auth.User.UserId;
            candidate.PersonalSkill  = model.PersonalSkill;

            _context.UserResumes.Add(candidate);
            _context.SaveChanges();
            _auth.User.HasResume = true;


            if (model.Works != null)
            {
                for (var i = 0; i < model.Works.Count; i++)
                {
                    Work experience = new Work
                    {
                        CompanyName   = model.Works[i].CompanyName,
                        StartWorkYear = model.Works[i].StartWork,
                        EndWorkYear   = model.Works[i].EndWork,
                        ResumeId      = candidate.ResumeId,
                        Position      = model.Works[i].Position,
                    };
                    _context.Works.Add(experience);
                    _context.SaveChanges();
                }
            }

            if (model.Educations != null)
            {
                for (var i = 0; i < model.Educations.Count; i++)
                {
                    Education education = new Education
                    {
                        SchoolName         = model.Educations[i].SchoolName,
                        StartEducationYear = model.Educations[i].StartSchool,
                        EndEducationYear   = model.Educations[i].EndSchool,
                        ResumeId           = candidate.ResumeId,
                        Qualification      = model.Educations[i].Qualification
                    };
                    _context.Educations.Add(education);
                    _context.SaveChanges();
                }
            }
            return(Json(new
            {
                status = "OK",
                code = 200,
                message = "added Cv",
                data = model,
                redirectUrl = Url.Action("Index", "Home"),
                isRedirect = true
            }));
        }
Ejemplo n.º 2
0
        public IActionResult Register(AccountRegisterModel register)
        {
            if (ModelState.IsValid)
            {
                if (!_context.Users.Any(u => u.Email == register.Email))
                {
                    User user = new User
                    {
                        Email     = register.Email,
                        Username  = register.Username,
                        Password  = Crypto.HashPassword(register.Password),
                        CreatedAt = DateTime.Now,
                        Token     = Guid.NewGuid().ToString(),
                        IsCompany = register.IsCompany
                    };

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

                    Response.Cookies.Append("token", user.Token, new Microsoft.AspNetCore.Http.CookieOptions
                    {
                        Expires  = DateTime.Now.AddYears(1),
                        HttpOnly = true
                    });
                    return(RedirectToAction("profile", "account"));
                }

                else
                {
                    ModelState.AddModelError("Email", "This user is already in registered");
                }
            }

            AccountIndexViewModel data = new AccountIndexViewModel
            {
                Register = register
            };

            data.Breadcumb = new BreadcumbViewModel
            {
                Title = "Register",
                Path  = new Dictionary <string, string>()
            };
            data.Breadcumb.Path.Add("index", "Home");
            data.Breadcumb.Path.Add("Register", null);

            ViewBag.Partial = data.Breadcumb;

            return(View("~/Views/Account/Register.cshtml"));
        }
Ejemplo n.º 3
0
        public IActionResult Create(JobIndexViewModel job)
        {
            if (ModelState.IsValid)
            {
                User LoggedUser = _context.Users.Find(_auth.User.UserId);

                Job newJob = new Job
                {
                    Title          = job.JobCreate.Title,
                    Jobtype        = job.JobCreate.Jobtype,
                    Role           = job.JobCreate.Role,
                    Salary         = job.JobCreate.Salary,
                    ExpierenceYear = job.JobCreate.ExpierenceYear,
                    City           = job.JobCreate.City,
                    Location       = job.JobCreate.Location,
                    JobDescription = job.JobCreate.JobDescription,
                    Category       = job.JobCreate.Category,
                    CreatedAt      = DateTime.Now,
                    IsActive       = true,
                    UserId         = _auth.User.UserId,
                };

                LoggedUser.HasJobSubmit = true;

                _context.Jobs.Add(newJob);
                _context.Entry(LoggedUser).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.SaveChanges();

                return(RedirectToAction("myjob", "job"));
            }
            else
            {
                JobIndexViewModel data = new JobIndexViewModel()
                {
                    JobCreate = job.JobCreate
                };

                return(View("~/Views/Job/Index.cshtml"));
            }
        }