Пример #1
0
        public ActionResult Index(ReshimgathiMatrimony.Models.Login model)
        {
            if (ModelState.IsValid)
            {
                //LoginOperations loginOp = new LoginOperations();

                //use this WSHttpBinding_ILoginService for http protocol communication
                LoginServices.LoginServiceClient client = new LoginServices.LoginServiceClient("WSHttpBinding_ILoginService");

                //in a similar pattern we are creating registration phase 1 service obj
                RegistrationPhaseI.RegistrationPhaseIClient regClient = new RegistrationPhaseI.RegistrationPhaseIClient("NetTcpBinding_IRegistrationPhaseI");
                regClient.IsRegistrationEnabledToday();
                //by the way above 2 lines code no use of it. But we are implemenetd how second service can be updated and invoked.


                //use this NetTcpBinding_ILoginService when we want communication should be carried out through TCP protocol.
                //LoginServices.LoginServiceClient client = new LoginServices.LoginServiceClient("NetTcpBinding_ILoginService");

                bool loginStatus = client.IsLoggedUserPresent(model.UserName, model.Password);
                //bool loginStatus = loginOp.IsLoggedUserPresent(model.UserName, model.Password);

                if (loginStatus)
                {
                    //WCF service call.
                    //bool IsVerified = loginOp.IsLogInUserVerified(model.UserName, model.Password);
                    bool IsVerified = client.IsLogInUserVerified(model.UserName, model.Password);

                    if (IsVerified)
                    {
                        UserType type        = (UserType)client.LoggedUserType(model.UserName, model.Password);
                        var      userDetails = client.GetUserDetails(model.UserName, model.Password);

                        UserLoginId  = userDetails.Id;
                        BaseUserType = userDetails.UserType;
                        SetSession();

                        if (type == UserType.User)
                        {
                            return(RedirectToAction("Index", "Dashboard"));
                        }
                        else
                        {
                            //Admin user goes here.
                            return(RedirectToAction("Index", "Admin"));
                        }
                    }
                    else
                    {
                        //User is not verified. He/she needs to verify account by his/her email address or Phone number.
                        ModelState.AddModelError(string.Empty, "Signing user is not verified either by Email address or Phone number. Please verify the user.");
                    }
                }
                else
                {
                    //default Index Get view with ErrorMessage. Username and password are wrong.
                    ModelState.AddModelError(string.Empty, "Username or password are not correct. Please try again with the correct details.");
                }
            }

            return(View(model));
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoginController"/> class.
 /// </summary>
 public LoginController()
 {
     loginService = new XareuWFClient.LoginServices.LoginServiceClient();
 }