예제 #1
0
 public ActionResult MyForm(ClientLoginViewModel c)
 {
     if (ModelState.IsValid)
     {
         TempData["MyFormData"] = c;
         return(RedirectToAction("MyFormResult"));
     }
     return(View());
 }
예제 #2
0
        public ActionResult Create(ClientLoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                TempData["FormModel"] = model;
                return(RedirectToAction("Created"));
            }

            return(View());
        }
예제 #3
0
        public ActionResult SignInPage()
        {
            var client    = new Client();
            var viewModel = new ClientLoginViewModel
            {
                Client = client
            };

            return(View(viewModel));
        }
예제 #4
0
 public ActionResult Login(ClientLoginViewModel login, string ReturnUrl)
 {
     if (ModelState.IsValid)
     {
         if (login.Email == "*****@*****.**" && login.Password == "123")
         {
             FormsAuthentication.RedirectFromLoginPage(login.Email, false);
             return(Redirect(ReturnUrl ?? "/"));
         }
     }
     return(View());
 }
예제 #5
0
        // GET: MV
        public ActionResult Index()
        {
            var b = new ClientLoginViewModel()
            {
                FirstName = "Jerry",
                LastName  = "Shih"
            };

            ViewData["Temp2"] = b;

            return(View());
        }
예제 #6
0
        // GET: MV
        public ActionResult Index()
        {
            ViewData["Temp"] = "XXXXXXXXXXXXXXXXXX";

            var clv = new ClientLoginViewModel()
            {
                FirstName = "Robert",
                LastName  = "Chen"
            };

            ViewData["clv"] = clv;
            return(View());
        }
예제 #7
0
        // GET: MB
        public ActionResult Index()
        {
            ViewData["temp1"] = "暫存資料 Templ";
            var b = new ClientLoginViewModel()
            {
                FirstName   = "Et",
                LastName    = "KK",
                MiddleName  = "DE",
                DateOfBirth = DateTime.Now
            };

            ViewData["ed"] = b;
            return(View());
        }
예제 #8
0
        public ActionResult Index()
        {
            var b = new ClientLoginViewModel()
            {
                FirstName = "Will",
                LastName  = "Huang"
            };

            ViewData["Temp2"] = b;

            ViewBag.Temp3 = b;

            return(View());
        }
예제 #9
0
        // GET: MB
        public ActionResult Index()
        {
            //ViewData["Temp1"] = "暫存資料1";

            var b = new ClientLoginViewModel()
            {
                FirstName = "Allen",
                LastName  = "Chen"
            };

            ViewData["Temp2"] = b;
            ViewBag.Temp3     = b;

            return(View());
        }
예제 #10
0
 public IActionResult ClientLogin(ClientLoginViewModel client)
 {
     if (ModelState.IsValid)
     {
         if (IsClient(client.UserPhone, client.Password))
         {
             var Customer = _context.Members.FirstOrDefault(c => c.Phone == client.UserPhone);
             var data     = new ClientLoginViewModel {
                 UserPhone = Customer.Phone, Password = Customer.Password, UserName = Customer.FullName
             };
             TempData["LoginData"] = JsonConvert.SerializeObject(data);
             return(RedirectToAction(nameof(Index)));
         }
         else
         {
             ModelState.AddModelError("UserPhone", "رقم الهاتف أو كلمة المرور غير صحيحة");
             return(View());
         }
     }
     return(View());
 }
예제 #11
0
        public ActionResult Signup(ClientLoginViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    WebSecurity.CreateUserAndAccount(viewModel.Client.Email, viewModel.RegisterModel.Password, new
                    {
                        Discriminator = "Client",
                        Name          = viewModel.Client.Name
                    });
                    WebSecurity.Login(viewModel.Client.Email, viewModel.RegisterModel.Password);
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", AccountController.ErrorCodeToString(e.StatusCode));
                }

                var cl =
                    from s in _db.Clients
                    where s.Email == viewModel.Client.Email
                    select s;

                var client = cl.First();

                client.Name             = viewModel.Client.Name;
                client.Contact1         = viewModel.Client.Contact1;
                client.Status           = true;
                client.Frequency        = DepositFrequency.NotSet;
                client.AutoPay          = false;
                _db.Entry(client).State = EntityState.Modified;
                _db.SaveChanges();

                return(RedirectToAction("Index", "ClientsView"));
            }

            return(View(viewModel));
        }
예제 #12
0
        public IActionResult ClientRegister(ClientRegisterViewModel client)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var Client = (from c in _context.Members
                                  from r in _context.Roless
                                  from cr in _context.MemberRoles
                                  where cr.RoleId == r.Id && cr.MemberId == c.Id && r.Name == "Customer" && c.Phone == client.UserPhone
                                  select c).FirstOrDefault();

                    if (Client != null)
                    {
                        ModelState.AddModelError("UserPhone", "تم تسجيل هذا الحساب مسبقا");
                        return(View(client));
                    }

                    var Member = new Member();
                    Member.FullName = client.UserName;
                    Member.Phone    = client.UserPhone;
                    Member.Password = RandomURL.GetURL();
                    Member.CityId   = client.CityId;
                    Member.State    = true;


                    _context.Add(Member);
                    var created  = _context.SaveChanges();
                    var Customer = new Member();
                    if (created > 0)
                    {
                        //add Customer to role
                        Customer = _context.Members.ToList().FirstOrDefault(c => c.Phone == client.UserPhone);
                        var role = _context.Roless.FirstOrDefault(r => r.Name == "Customer");
                        if (role != null && Customer != null)
                        {
                            MemberRole CustomerRole = new MemberRole();
                            CustomerRole.MemberId = Customer.Id;
                            CustomerRole.RoleId   = role.Id;
                            _context.MemberRoles.Add(CustomerRole);
                            _context.SaveChanges();
                        }
                    }


                    if (IsClient(Customer.Phone, Customer.Password))
                    {
                        var data = new ClientLoginViewModel {
                            UserPhone = Customer.Phone, Password = Customer.Password, UserName = Customer.FullName
                        };
                        TempData["LoginData"] = JsonConvert.SerializeObject(data);
                        return(RedirectToAction(nameof(Index)));
                    }
                    //else
                    //{
                    //    ModelState.AddModelError("UserPhone", "رقم الهاتف أو كلمة المرور غير صحيحة");
                    //    return View();
                    //}

                    return(RedirectToAction(nameof(Index)));
                }

                ViewData["CityId"] = new SelectList(_context.Cities, "Id", "Name", client.CityId);
                return(View(client));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
예제 #13
0
 public ActionResult Login(ClientLoginViewModel model)
 {
     return(View("LoginResult", model));
 }
예제 #14
0
 public ActionResult Login(ClientLoginViewModel client)
 {
     return(View("LoginResult", client));
 }
예제 #15
0
        public ActionResult ClientLogin(ClientLoginViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (string.Compare(model.CRPUserName, "", false) == 0 && string.Compare(model.CRPPassWord, "", false) == 0)
                    {
                        ModelState.AddModelError("", "Enter User Name and Password");
                    }
                    else if (string.Compare(model.CRPUserName, "", false) == 0 && string.Compare(model.CRPPassWord, "", false) != 0)
                    {
                        ModelState.AddModelError("", "Enter User Name");
                    }
                    else if (!(string.Compare(model.CRPUserName, "", false) != 0 && string.Compare(model.CRPPassWord, "", false) == 0))
                    {
                        DateTime today      = DateTime.Today;
                        string   str        = model.CRPUserName.Trim().ToLower();
                        string   str1       = model.CRPPassWord.Trim().ToLower();
                        string[] strArrays1 = str.Split(' ');
                        string[] strArrays2 = str1.Split(' ');
                        string   str2       = strArrays1[0];
                        string   str3       = strArrays2[0];

                        if (!(string.Compare(str2, "select", false) == 0 || string.Compare(str2, "exec", false) == 0 || string.Compare(str2, "execute", false) == 0 || string.Compare(str2, "drop", false) == 0 || string.Compare(str2, "truncate", false) == 0 || string.Compare(str2, "insert", false) == 0 || string.Compare(str2, "update", false) == 0 || string.Compare(str2, "delete", false) == 0 || string.Compare(str2, "union", false) == 0 || string.Compare(str2, "create", false) == 0)
                            )
                        {
                            if (!(string.Compare(str3, "select", false) == 0 || string.Compare(str3, "exec", false) == 0 || string.Compare(str3, "execute", false) == 0 || string.Compare(str3, "drop", false) == 0 || string.Compare(str3, "truncate", false) == 0 || string.Compare(str3, "insert", false) == 0 || string.Compare(str3, "update", false) == 0 || string.Compare(str3, "delete", false) == 0 || string.Compare(str2, "union", false) == 0 || string.Compare(str2, "create", false) == 0)
                                )
                            {
                                string UserName     = model.CRPUserName.Trim();
                                string UserPassword = model.CRPPassWord.Trim();
                                string encPassword  = clsCommonMethods.PasswordEncrypt(model.CRPPassWord.Trim());

                                ClientUserLoggedViewModel loggedUser = new ClientUserLoggedViewModel();
                                try
                                {
                                    loggedUser = repoAccount.GetClientUserLoggedDetails(UserName, encPassword);
                                }
                                catch (Exception exception1)
                                {
                                    ViewBag.ErrorMsg = exception1.Message;
                                    clsCommonMethods.ErrorLog(Server.MapPath("~\\ErrorLogs\\Logfiles"), exception1.Message, exception1.StackTrace);
                                }

                                if (loggedUser == null)
                                {
                                    var activWebUsers = repoAccount.GetAllActiveClientUsers();
                                    foreach (var webUser in activWebUsers)
                                    {
                                        if (!(webUser.CRPUserName.Trim() == UserName) || !(webUser.CRPPassWord.Trim() != encPassword))
                                        {
                                            continue;
                                        }

                                        Session["Counter"] = Convert.ToInt32(Session["Counter"]) + 1;
                                        break;
                                    }

                                    if (!(Convert.ToInt32(Session["Counter"]) >= 3))
                                    {
                                        ViewBag.ErrorMsg = "Login Failed.Try Again!";
                                        clsCommonMethods.UserLog(Server.MapPath("~\\ErrorLogs\\Unauthorized_UserLog"), UserName, UserPassword, "Client");
                                        return(View());
                                    }
                                    else
                                    {
                                        Session["Counter"] = 0;
                                        UpdateClientUserBlockStatusViewModel userBlocked = new UpdateClientUserBlockStatusViewModel();
                                        userBlocked.UserID      = UserName;
                                        userBlocked.BlockedDate = DateTime.Now;
                                        userBlocked.Status      = 3;

                                        repoAccount.BlockedClientUser(userBlocked);
                                        repoAccount.SaveChanges();

                                        ViewBag.ErrorMsg = "User has been Blocked, Please contact to Administrator!";
                                        Session.Abandon();
                                        return(View());
                                    }
                                }
                                else
                                {
                                    Session["UserName"]           = UserName;
                                    Session["ClientUserRowID"]    = loggedUser.ClientUserRowID;
                                    Session["ClientRowID"]        = loggedUser.ClientRowID;
                                    Session["ClientName"]         = loggedUser.ClientName + " (" + loggedUser.ClientSubGroupName + ")";
                                    Session["ClientSubGroupName"] = loggedUser.ClientSubGroupName;
                                    Session["LocationName"]       = loggedUser.LocationName;
                                    Session["HRApproval"]         = loggedUser.HRApprovalRequired;
                                    Session["Abbreviation"]       = loggedUser.Abbreviation;
                                    Session["CodeGeneration"]     = loggedUser.CodeGeneration;
                                    Session["CSpocName"]          = loggedUser.CSpocName;
                                    Session["CSpocEmailID"]       = loggedUser.CSpocEmailID;
                                    Session["CreatedBy"]          = loggedUser.CreatedBy;
                                    Session["ClientBranch"]       = loggedUser.ClientBranch;
                                    Session["ClientUType"]        = "Client";
                                    Session["Valid"] = 1;

                                    if (Convert.ToInt32(Session["Valid"]) == 1)
                                    {
                                        DateTime dateTime          = DateTime.Today;
                                        TimeSpan TimeSinceCreation = new TimeSpan();

                                        if (loggedUser.ModifiedTime != null)
                                        {
                                            TimeSinceCreation = dateTime.Subtract(loggedUser.ModifiedTime.Value);
                                        }
                                        else
                                        {
                                            TimeSinceCreation = dateTime.Subtract(loggedUser.CreatedTime.Value);
                                        }

                                        if (TimeSinceCreation.Days > 179)
                                        {
                                            ViewBag.ErrorMsg = "Your password has expired. Please contact your Administrator!";
                                            Session.Abandon();
                                            return(View());
                                        }
                                        else if (TimeSinceCreation.Days < 0)
                                        {
                                            clsCommonMethods.UserLog(Server.MapPath("~\\ErrorLogs\\Unauthorized_UserLog"), UserName, UserPassword, "Client");
                                            ViewBag.ErrorMsg = "Invalid login. Please Try again!";
                                            Session.Abandon();
                                            return(View());
                                        }
                                    }

                                    AddUserLoggedInDetailViewModel loggedInDetails = new AddUserLoggedInDetailViewModel();
                                    loggedInDetails.LoginName   = loggedUser.ClientName + "(" + loggedUser.ClientSubGroupName + ")";
                                    loggedInDetails.LoginType   = loggedUser.LocationName;
                                    loggedInDetails.LoginId     = UserName;
                                    loggedInDetails.LoginBy     = "Client";
                                    loggedInDetails.IPDetails   = Request.UserHostAddress;
                                    loggedInDetails.LoginDate   = DateTime.Now;
                                    loggedInDetails.LoginStatus = 1;

                                    Session["LoginDetailRowID"] = repoAccount.AddUserLoggedInDetails(loggedInDetails);
                                }

                                FormsAuthentication.SetAuthCookie(UserName, false);
                                return(RedirectToAction("DashboardClient", "Home", new { area = "ClientArea" }));
                            }
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Enter Password");
                    }
                }
                else
                {
                    var query = from state in ModelState.Values
                                from error in state.Errors
                                select error.ErrorMessage;

                    var    errorList = query.ToList();
                    string strError  = string.Empty;
                    foreach (string str in errorList)
                    {
                        strError += str + "\n";
                    }

                    ModelState.AddModelError("", strError);
                }
            }
            catch (Exception Ex)
            {
                ViewBag.ErrorMsg = Ex.Message;
                clsCommonMethods.ErrorLog(Server.MapPath("~\\ErrorLogs\\Logfiles"), Ex.Message, Ex.StackTrace);
            }

            return(View());
        }
예제 #16
0
        public ActionResult SignIn(ClientLoginViewModel viewModel)
        {
            if (string.IsNullOrEmpty(viewModel.Client.Email) || string.IsNullOrEmpty(viewModel.Client.Password))
            {
                viewModel.OutcomeOfValidatingLogin = "******";
                return(View("SignInPage", viewModel));
            }

            var emailValidator = new EmailAddressAttribute();

            if (!emailValidator.IsValid(viewModel.Client.Email))
            {
                viewModel.OutcomeOfValidatingLogin = "******";
                return(View("SignInPage", viewModel));
            }

            using (var db = new MyDbContext())
            {
                var query = from b in db.ClientsTable
                            orderby b.ClientId
                            select b;
                bool isClient = false;
                foreach (var item in query)
                {
                    if (item.Email == viewModel.Client.Email && item.Password == viewModel.Client.Password)
                    {
                        isClient = true;
                        viewModel.Client.ClientId = item.ClientId;
                        break;
                    }
                }
                if (isClient)
                {
                    /*bool isFirstTime = true;
                     * var queryProfile = from b in db.ClientProfileTable
                     *                                 select b;
                     * ClientProfile profile = null;
                     * foreach(var item in queryProfile)
                     * {
                     *      if (item.Client == viewModel.Client)
                     *      {
                     *              isFirstTime = false;
                     *              profile = item;
                     *      }
                     *
                     * }
                     *
                     * if (isFirstTime == true)
                     * {*/
                    var clientProfile    = new ClientProfile();
                    var profileViewModel = new ProfileManagementViewModel()
                    {
                        ClientProfile = clientProfile,
                        Client        = viewModel.Client
                    };

                    return(View("ProfileManagementPage", profileViewModel));

                    /*}
                     * else
                     * {
                     *      //return Content("Is not first time user");
                     *      var fuelQuote = new FuelQuote
                     *      {
                     *              DeliveryAddress = profile.Address1
                     + " " + profile.Address2 + ", "
                     + profile.City + ", "
                     + profile.State + ", "
                     + profile.Zipcode
                     +      };
                     +      var fuelQuoteViewModel = new FuelQuoteViewModel
                     +      {
                     +              ClientId = viewModel.Client.ClientId,
                     +              FuelQuote = fuelQuote,
                     +      };
                     +      return View("FuelQuoteForm", fuelQuoteViewModel);
                     + }*/
                }
                else
                {
                    viewModel.OutcomeOfValidatingLogin = "******";
                    return(View("SignInPage", viewModel));
                }
            }
        }