eCommerce Website Part 17 Login Page

eCommerce Website  Part 17 Login Page

Hi, Dear's here we learn how to implement eCommerce Website in Visual Studio using C# ASP.NET MVC. Ilyasoft software company provide full project step by step training on our YouTube Channel ilyasoft software company so now subscribe, share and like for more project base tutorials



In this video we are going to implement Login Page for more details click here: watch vedio

In UserController we are going to add Login method show in below code:

 > Login Action Code : 

public ActionResult Login()
        {
            return View();
        }
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Login(string username, string password)
        {
            string message = string.Empty;
            var user = DB.UserTables.Where(u => (u.UserName == username.Trim() || u.EmailAddress == username.Trim()) && u.Password == password.Trim()).FirstOrDefault();
            if (user != null)
            {
                if (user.UserStatusID == 1)
                {
                    ModelState.AddModelError("","Your Account Pending");
                }
                else if (user.UserStatusID == 2)
                {
                    Session["UserID"] = user.UserID;
                    return RedirectToAction("Index","Home");
                }
                else if (user.UserStatusID == 3)
                {
                    ModelState.AddModelError("", "Your Account Rejected");
                }
                else if (user.UserStatusID == 4)
                {
                    ModelState.AddModelError("", "Your Account Suspended");
                }
                else if (user.UserStatusID == 5)
                {
                    ModelState.AddModelError("", "Your Account Processing");
                }
            }
            else
            {
                ModelState.AddModelError("", "Incorrect User Credentials");
            }
            return View();
        }

 > Login View Code : 
@{
    ViewBag.Title = "Login";
}
<div class="breadcrumbs mt-15">
    <div class="container">
        <ul class="list-unstyled d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
            <li><a href="@Url.Content("~/Home/Index")">Home</a></li>
            <li><span>Account</span></li>
        </ul>
    </div>
</div>
<div class="login mb-60">
    <div class="container">
        <div id="CustomerLoginForm">
            <h1 class="h3 mt-30 mb-40 text-center">Login</h1>
                @using (Html.BeginForm("Login", "User"))
                {
                    @Html.AntiForgeryToken()
                    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                    <input type="hidden" name="form_type" value="customer_login" />
                    <input type="hidden" name="utf8" value="✓" />
                    <label for="CustomerEmail" class="label-required">EMAIL/USERNAME</label>
                    <input type="text"
                           name="username"
                           id="username"
                           class=""
                           placeholder="Enter your email or username"
                           spellcheck="false"
                           autocomplete="off"
                           autocapitalize="off"
                           required="required"
                           autofocus><label for="CustomerPassword" class="label-required">PASSWORD</label>
                    <input type="password"
                           name="password"
                           id="password"
                           class=""
                           placeholder="Enter your password"
                           required="required">
                    <div class="text-center">
                        <input type="submit" class="btn btn--full btn--secondary" value="LOGIN">
                        <div>
                            <a href="@Url.Content("~/Home/Index")" class="h6 btn-link mt-20 mb-0">
                                RETURN TO
                                STORE
                            </a>
                        </div>
                        <div>
                            <a href="#recover" class="btn-link mt-15 js-button-block-visibility"
                               data-block-link="#recover">Forgot Your Password?</a>
                        </div>
                    </div>
                }
        </div>
        <form method="post" action="#" accept-charset="UTF-8">
            <input type="hidden" name="form_type"
                   value="recover_customer_password" /><input type="hidden" name="utf8" value="✓" />
            <div id="RecoverPasswordForm" class="pt-35 mt-35 border-top d-none-important"
                 data-block-visibility="#recover">
                <h2 class="h3 text-center">Reset your password</h2>
                <p>We will send you an email to reset your password.</p><label for="RecoverEmail"
                                                                               class="label-required">EMAIL</label>
                <input type="email"
                       name="email"
                       id="RecoverEmail"
                       placeholder="Enter your email"
                       spellcheck="false"
                       autocomplete="off"
                       autocapitalize="off"
                       required="required"
                       data-block-visibility-focus>

                <input type="submit" class="btn btn--full" value="Submit">
                <div class="mt-15 text-center">
                    <span class="btn-link js-button-block-visibility" data-action="close"
                          data-block-link="#recover">Close</span>
                </div>
            </div>
        </form>
        <div class="pt-35 mt-35 border-top">
            <h2 class="h3 text-center">Sign Up</h2>
            <div class="mb-35">
                <p class="h6 mb-15">Enjoy The Benefits Of Registering:</p>
                <ul class="mb-0">
                    <li>Order: view Order History, track and manage purchases and returns.</li>
                    <li>
                        Address Book and Card Wallet: safely store delivery and payment details for faster
                        checkout
                    </li>
                    <li>Saved for later: wish list your preferred items and track their availability</li>
                </ul>
            </div>
            <a href="@Url.Content("~/User/CustomerRegister")" class="btn btn--full">SIGN UP NOW!</a>
        </div>
    </div>
</div>

Comments