public IActionResult EnrollmentAssign(AssignEnrollemntViewModel model)
        {
            var loggedUser = this._userManager.Users.Where(r => r.UserName == User.Identity.Name).FirstOrDefault();

            if (model != null && ModelState.IsValid)
            {
                try
                {
                    this._candidateService.AssignEnrollment(Convert.ToInt32(model.EnrollmentId), Convert.ToInt32(model.HRUser), User.Identity.Name);

                    return(this.Json(
                               new
                    {
                        Success = true,
                        Message = "Saved Successfully."
                    }));
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("HRUser", e.Message);
                }

                return(this.Json(
                           new
                {
                    Success = true,
                    Message = string.Empty,
                    Html = this.RenderPartialViewToString("_Assign", model)
                }));
            }
            else
            {
                return(this.GetJsonResult(false, "Validation failed", this.ModelErrors()));
            }
        }
        public IActionResult PrepareEnrollmentAssign(string enrollmentId)
        {
            AssignEnrollemntViewModel model = new AssignEnrollemntViewModel();
            var loggedUser = this._userManager.Users.Where(r => r.UserName == User.Identity.Name).FirstOrDefault();

            model.EnrollmentId = enrollmentId;
            model.HRUsers      = this._userService.GetHRUsers(loggedUser.ProductOwnerId);

            return(this.Json(
                       new
            {
                Success = true,
                Message = string.Empty,
                Html = this.RenderPartialViewToString("_Assign", model)
            }));
        }
        public IActionResult EnrollmentAccept(string enrollmentId)
        {
            var loggedUser = this._userManager.Users.Where(r => r.UserName == User.Identity.Name).FirstOrDefault();

            if (!string.IsNullOrEmpty(enrollmentId))
            {
                try
                {
                    this._candidateService.AssignEnrollment(Convert.ToInt32(enrollmentId), loggedUser.Id, User.Identity.Name);
                    //this.SendAssignmentAcceptedEmail(loggedUser.Email ,enrollmentId);
                    // Update Grid
                    IList <CandidateViewModel> pendingCandidates = this._candidateService.GetPendingCandidates(loggedUser.ProductOwnerId);
                    //mygrid
                    IList <CandidateViewModel> assignedCandidates = this._candidateService.GetMyCandidates(loggedUser.Id, loggedUser.ProductOwnerId);
                    return(this.Json(
                               new
                    {
                        Success = true,
                        Message = "Saved Successfully.",
                        Html = this.RenderPartialViewToString("_PendingCandidates", pendingCandidates),
                        Count = pendingCandidates.Count.ToString(),
                        MyHtml = this.RenderPartialViewToString("_AssignedCandidates", assignedCandidates),
                        MyCount = assignedCandidates.Count.ToString()
                    }));
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("HRUser", e.Message);
                }

                AssignEnrollemntViewModel model = new AssignEnrollemntViewModel();

                return(this.Json(
                           new
                {
                    Success = true,
                    Message = string.Empty,
                    Html = this.RenderPartialViewToString("_Assign", model)
                }));
            }
            else
            {
                return(this.GetJsonResult(false, "Validation failed", this.ModelErrors()));
            }
        }
        public IActionResult PrepareEnrollmentAssign(string enrollmentId)
        {
            AssignEnrollemntViewModel model = new AssignEnrollemntViewModel();
            var loggedUser = this._userManager.Users.Where(r => r.UserName == User.Identity.Name).FirstOrDefault();

            model.EnrollmentId = enrollmentId;
            model.HRUsers      = this._userService.GetHRUsers(loggedUser.ProductOwnerId);

            foreach (var theUser in model.HRUsers)
            {
                var user = this._userManager.Users.Where(r => r.Id == Convert.ToInt32(theUser.Value)).FirstOrDefault();

                theUser.Text = user.FirstName + " " + user.LastName;
            }

            return(this.Json(
                       new
            {
                Success = true,
                Message = string.Empty,
                Html = this.RenderPartialViewToString("_Assign", model)
            }));
        }