Exemplo n.º 1
0
        public ActionResult ApproveUser(viewUser user)
        {
            CMSService.ApproveUser(user);
            viewUser getUser = CMSService.GetUser(user.UserId);

            if (user.IsDisApproved != true)
            {
                if (getUser != null)
                {
                    string AMRoleName = CMSService.GetRoles().Where(r => r.Id == getUser.RoleId).FirstOrDefault().Description;


                    CustomRoleProvider crp = new CustomRoleProvider();


                    string appName = ConfigurationManager.AppSettings["ApplicationName"];

                    string un = getUser.UserName;

                    rsac.AddUsersToRoles(appName, un, AMRoleName);
                }


                List <MailAddress> EMails = new List <MailAddress>();

                EMails.Add(new MailAddress(getUser.Email, "to"));

                string Message = "Registration for the user " + getUser.UserName + " has been approved.";

                string Subject = "APS Case Management System Registration: Approved";

                SendEmail(EMails, Message, Subject);
            }
            else
            {
                List <MailAddress> EMails = new List <MailAddress>();

                EMails.Add(new MailAddress(getUser.Email, "to"));

                string Message = "For user:"******". Your access to the Illinois Department on Aging Office (IDoA) of Adult Protective Services Case Management System has been denied for the following reason: " + user.DisApprovalMessage + ". Please contact either your Supervisor or if you are a Supervisor contact your IDoA liaison.";



                string Subject = "APS Case Management System Registration: Denied";

                SendEmail(EMails, Message, Subject);
            }

            return(RedirectToAction("UserAdmin"));
        }