public HttpResponseMessage RegisterEmployer(int employerId)
        {
            var result = _employersManager.GetEmployerById(employerId);

            if (!result.Success)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, result));
            }

            var employer       = new EmployerModelSecured();
            var employerEntity = (EmployerEntity)result.Entity;

            PropertyCopier <EmployerEntity, EmployerModelSecured> .Copy(employerEntity, employer);

            result.Entity = employer;
            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        public HttpResponseMessage GetApplicationById(int id)
        {
            Result result = new Result();

            result = _jobApplicationManager.GetJobApplicationByApplicationId(id);

            //If failed
            if (!result.Success)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, result));
            }
            //If if not found
            if (result.Entity == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, result));
            }

            // Authentication verify block
            object objuser = null;

            Request.Properties.TryGetValue("user", out objuser);
            var user = objuser as UserEntity;

            object objemployer = null;

            Request.Properties.TryGetValue("employer", out objemployer);
            var employer = objemployer as EmployerEntity;

            var application = (JobApplicationEntity)result.Entity;

            var response = new ApplicationWithInfo();

            response.jobApplicationEntity = application;
            if (user != null)
            {
                // User logged in
                if (user.UserId != application.UserId)
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, result));
                }
            }
            else if (employer != null)
            {
                var listing = (JobListingEntity)_jobListingManager.GetListingById(application.JobListingId).Entity;


                if (employer.EmployerId != listing.EmployerId || application.IsDraft)
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized, new Result(false)));
                }
            }



            if (!application.IsDraft && (application.IsShortlisted == true) && (application.IsDeclined != true))
            {
                // get details only if the application is shortlisted;
                var nurseEntity  = (UserEntity)_usersManager.GetSecuredUserDetails(application.UserId).Entity;
                var nurseDetails = new UserModelSecured();
                PropertyCopier <UserEntity, UserModelSecured> .Copy(nurseEntity, nurseDetails);

                var employerEntity  = (EmployerEntity)_employersManager.GetEmployerById(application.EmployerId).Entity;
                var employerDetails = new EmployerModelSecured();
                PropertyCopier <EmployerEntity, EmployerModelSecured> .Copy(employerEntity, employerDetails);

                var quizAnswers = (List <NurseSelfAssessmentAnswersEntity>)_nurseSelfAssessmentAnswersManager.GetAnswersbyUserQuizzId(nurseEntity.defaultQuizId).Entity;
                response.jobApplicationEntity.PreferedQuizz = quizAnswers;
                response.employerInfo = employerDetails;
                response.nurseInfo    = nurseDetails;
            }

            //If it is good

            result.Entity = response;
            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }