Ejemplo n.º 1
0
        public static bool HasAccessToApplication(this ClaimsPrincipal user, HR_Project_Database.Models.Application application)
        {
            if (user.IsInRole(UserRole.User))
            {
                return(user.GetExternalId() == application.User.ExternalId);
            }
            else if (user.IsInRole(UserRole.HR))
            {
                return(application.JobOffer.Responsibility.Any(responsibility => responsibility.User.ExternalId == user.GetExternalId()));
            }

            return(false);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Apply(int id)
        {
            var jobOffer       = context.JobOffer.Find(id);
            var newApplication = new HR_Project_Database.Models.Application()
            {
                JobOfferId = jobOffer.IdJobOffer,
                UserId     = User.GetId(context),
                CvId       = null,
                Status     = HR_Project_Database.Models.ApplicationStatus.Draft
            };

            context.Application.Add(newApplication);
            await context.SaveChangesAsync();

            return(RedirectToAction("Details", "Application", new { id = newApplication.IdApplication, isEditing = true }));
        }