public static String ProcessLogin(this Controller controller, UserProfile item, bool fromLine = false)
        {
            if (fromLine)
            {
                if (item.IsLearner())
                {
                    return(controller.Url.Action("LearnerIndex", "CornerKick"));
                }
            }

            if (item.IsAuthorizedSysAdmin())
            {
                //return url.Action("Index", "CoachFacet", new { KeyID = item.UID.EncryptKey() });
                return(VirtualPathUtility.ToAbsolute("~/ConsoleHome/Index"));
            }
            else if (item.UserRoleAuthorization.Any(r => r.RoleID == (int)Naming.RoleID.Coach || r.RoleID == (int)Naming.RoleID.Manager || r.RoleID == (int)Naming.RoleID.ViceManager))
            {
                //return url.Action("Index", "CoachFacet", new { KeyID = item.UID.EncryptKey() });
                return(VirtualPathUtility.ToAbsolute("~/ConsoleHome/Index"));
            }
            else if (item.IsAssistant())
            {
                //return url.Action("Index", "CoachFacet", new { KeyID = item.UID.EncryptKey() });
                return(VirtualPathUtility.ToAbsolute("~/ConsoleHome/Index"));
            }
            else if (item.IsAccounting())
            {
                //return url.Action("TrustIndex", "Accounting");
                return(VirtualPathUtility.ToAbsolute("~/ConsoleHome/Index"));
            }
            else if (item.IsServitor())
            {
                return(VirtualPathUtility.ToAbsolute("~/ConsoleHome/Index"));
                //return url.Action("PaymentIndex", "Payment");
            }


            switch ((Naming.RoleID)item.UserRole.FirstOrDefault()?.RoleID)
            {
            case Naming.RoleID.Administrator:
                return(controller.Url.Action("Index", "CoachFacet"));

            case Naming.RoleID.Learner:
                return(controller.Url.Action("LearnerIndex", "CornerKick"));

            //return fromLine ? controller.Url.Action("LearnerIndex", "CornerKick") : controller.Url.Action("LearnerIndex", "LearnerFacet");

            case Naming.RoleID.Manager:
            case Naming.RoleID.ViceManager:
            case Naming.RoleID.Assistant:
                return(controller.Url.Action("Index", "CoachFacet", new { KeyID = item.UID.EncryptKey() }));

            case Naming.RoleID.Officer:
                if (item.UserRole.Count == 1 && item.UserRoleAuthorization.Any(r => r.RoleID == (int)Naming.RoleID.Officer))
                {
                    return(VirtualPathUtility.ToAbsolute("~/ConsoleHome/Index"));
                }
                else
                {
                    return(controller.Url.Action("Index", "CoachFacet", new { KeyID = item.UID.EncryptKey() }));
                }

            //case Naming.RoleID.Assistant:
            //    return controller.Url.Action("Index", "CoachFacet");

            case Naming.RoleID.Accounting:
                return(controller.Url.Action("TrustIndex", "Accounting"));


            case Naming.RoleID.Servitor:
                return(controller.Url.Action("PaymentIndex", "Payment"));

            case Naming.RoleID.FreeAgent:
                return(controller.Url.Action("FreeAgent", "Account"));
            }

            return(controller.Url.Action("Index", "Account"));;
        }
예제 #2
0
        public static void NotifyResetPassword(this ResetPassword item, String notifyUrl = null)
        {
            ThreadPool.QueueUserWorkItem(t => {
                try
                {
                    //StringBuilder body = new StringBuilder();
                    MailMessage message = new MailMessage();
                    message.ReplyToList.Add(Startup.Properties["WebMaster"]);
                    message.From = new MailAddress(Startup.Properties["WebMaster"]);
                    message.To.Add(item.UserProfile.PID);
                    message.Subject    = "Beyond-fitness會員密碼重設通知";
                    message.IsBodyHtml = true;

                    //body.Append("您好,請由下列連結重設您的密碼,謝謝。<br/>")
                    //    .Append("<a href=").Append(Startup.Properties["HostDomain"]).Append(VirtualPathUtility.ToAbsolute("~/Account/ResetPass"))
                    //    .Append("/").Append(item.ResetID)
                    //    .Append(">會員重設密碼</a>");

                    using (WebClient client = new WebClient())
                    {
                        client.Encoding = Encoding.UTF8;
                        message.Body    = client.DownloadString((notifyUrl ?? Startup.Properties["HostDomain"] + VirtualPathUtility.ToAbsolute("~/Account/NotifyResetPassword")) + "?resetID=" + item.ResetID);
                    }

                    //message.Body = body.ToString();

                    SmtpClient smtpclient = new SmtpClient(Startup.Properties["SmtpServer"]);
                    //smtpclient.Credentials = CredentialCache.DefaultNetworkCredentials;
                    smtpclient.Send(message);
                }
                catch (Exception ex)
                {
                    ApplicationLogging.LoggerFactory.CreateLogger(typeof(ExtensionMethods))
                    .LogError(ex, ex.Message);
                }
            });
        }