Пример #1
0
        public async Task <ActionResult> Save(int id, JobOfferDetailsViewModel model)
        {
            var toUpdate = context.JobOffer
                           .Include(x => x.Responsibility)
                           .ThenInclude(x => x.User)
                           .FirstOrDefault(jobOffer => jobOffer.IdJobOffer == id);

            if (toUpdate != null && User.CanManageJobOffer(toUpdate))
            {
                toUpdate.JobTitle    = model.JobOfferModel.JobTitle;
                toUpdate.Description = model.JobOfferModel.Description;
                await context.SaveChangesAsync();
            }

            return(RedirectToAction("Details", new { id = id, isEditing = true }));
        }
Пример #2
0
        public IActionResult Details(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("List"));
            }

            JobOfferDetailsViewModel model = jobOffersService.GetByIdWithUserApplications(id.Value, HttpContext.Session.GetInt32("loggedUserId").Value);

            if (model == null)
            {
                return(RedirectToAction("List"));
            }

            return(View(model));
        }
Пример #3
0
        public IActionResult Details(int id, bool isEditing)
        {
            var baseModel = jobOffers.Where(offer => offer.Id == id).FirstOrDefault();

            if (baseModel.Description == null)
            {
                baseModel.GetJobOfferDetails(context);
            }

            var model = new JobOfferDetailsViewModel
            {
                JobOfferModel = baseModel,
                IsEditing     = isEditing && User.CanManageJobOffer(baseModel)
            };

            return(View(model));
        }
Пример #4
0
        //Details
        public async Task <IActionResult> Details(int id)
        {
            bool isIngroup = await CheckIfUserIsAnAdmin();

            if (isIngroup)
            {
                User.Identities.First().AddClaim(new Claim(ClaimTypes.Role, "Admins"));
            }
            var offer = _context.JobOffers.First(x => x.Id == id);

            if (offer == null)
            {
                return(new StatusCodeResult((int)HttpStatusCode.NotFound));
            }
            _context.Entry(offer).Reference(f => f.Company).Load();
            JobOfferDetailsViewModel model = new JobOfferDetailsViewModel {
                Offer = offer
            };

            model.Applications = _context.JobApplications.Where(x => x.OfferId == id).ToList();
            return(View(model));
        }
Пример #5
0
        public IActionResult Apply(int?jobOfferId)
        {
            if (!jobOfferId.HasValue)
            {
                return(RedirectToAction("List", "UserJobOffers"));
            }

            UserDetailsViewModel user = usersService.GetDetails(HttpContext.Session.GetInt32("loggedUserId").Value);

            JobOfferDetailsViewModel jobOffer = jobOffersService.GetDetails(jobOfferId.Value, user.Id);

            if (jobOffer == null)
            {
                return(RedirectToAction("List", "UserJobOffers"));
            }

            UserApplicationEditViewModel model = new UserApplicationEditViewModel
            {
                UserId     = user.Id,     // AuthenticationService.LoggedUser.Id,
                JobOfferId = jobOffer.Id, // jobOfferId.Value
                Status     = ApplicationStatusEnum.Pending
            };

            userApplicationsService.Insert(model);

            // Send email
            emailService.SendAsync(new EmailViewModel
            {
                UserName  = jobOffer.User.FullName,
                UserEmail = jobOffer.User.Email,
                Subject   = "New Application",
                Body      = $"{user.FullName} applied for job {jobOffer.Title}"
            });

            return(RedirectToAction("Details", "UserJobOffers", new { id = jobOfferId }));
        }
Пример #6
0
 public static void CreateJobOfferDetailsViewModel()
 {
     if (_jobOfferDetailsViewModel == null)
     {
         _jobOfferDetailsViewModel = new JobOfferDetailsViewModel();
     }
 }
Пример #7
0
 public static void ClearJobOfferDetailsViewModel()
 {
     _jobOfferDetailsViewModel.Cleanup();
     _jobOfferDetailsViewModel = null;
 }