Ejemplo n.º 1
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"));
            }
        }
Ejemplo n.º 2
0
        public IActionResult Profile(AccountProfileModel profile)
        {
            if (ModelState.IsValid)
            {
                string FileName   = null;
                User   LoggedUser = _context.Users.Find(_auth.User.UserId);

                if (profile.Photo != null)
                {
                    if (profile.Photo.Length > 100000)
                    {
                        ModelState.AddModelError("", "Volume must be low than 1 mb");
                        ViewBag.PhotoName = profile.Photo.FileName;
                        return(View());
                    }
                    string UploadsFolder = Path.Combine(_hosting.WebRootPath, "images", "users");
                    FileName = Guid.NewGuid() + "_" + profile.Photo.FileName;
                    string FilePath = Path.Combine(UploadsFolder, FileName);
                    profile.Photo.CopyTo(new FileStream(FilePath, FileMode.Create));
                    LoggedUser.Image = FileName;
                }

                LoggedUser.FirstName = profile.FirstName;
                if (LoggedUser.IsCompany != true)
                {
                    LoggedUser.LastName = profile.LastName;
                }
                LoggedUser.Country  = profile.Country;
                LoggedUser.City     = profile.City;
                LoggedUser.Adress   = profile.Adress;
                LoggedUser.ZipCode  = profile.ZipCode;
                LoggedUser.Phone    = profile.Phone;
                LoggedUser.Facebook = profile.Facebook;
                LoggedUser.Google   = profile.Google;
                LoggedUser.AboutMe  = profile.AboutMe;

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

                if (LoggedUser.IsCompany == true)
                {
                    if (LoggedUser.HasJobSubmit != true)
                    {
                        return(RedirectToAction("create", "job", new { id = LoggedUser.UserId }));
                    }
                }
                else
                {
                    if (LoggedUser.HasResume != true)
                    {
                        return(RedirectToAction("index", "resume", new { id = LoggedUser.UserId }));
                    }
                }

                return(RedirectToAction("index", "home"));
            }
            else
            {
                AccountIndexViewModel data = new AccountIndexViewModel
                {
                    Profile = profile
                };

                return(View("~/Views/Account/Profile.cshtml"));
            }
        }