Exemple #1
0
        public string GetUserByEmailandIndustryId(string email, int industry)
        {
            var user = _manageAdminService.GetUserByEmailandIndustryId(email, industry);

            if (user != null)
            {
                return("exists");
            }
            else
            {
                return("not exists");
            }
        }
Exemple #2
0
        public ActionResult SwitchSuperAdminLogin(string UserName, string Password, string IndustryId)
        {
            List <smIndustry> newlist = _manageContentService.GetCategories();

            ViewBag.IndustryName = new SelectList(newlist, "IndustryId", "IndustryName");
            LoginViewModel model = new LoginViewModel();

            model.IndustryId = Convert.ToInt32(IndustryId);
            model.UserName   = UserName;
            model.Password   = Password;
            model.RememberMe = true;
            if (ModelState.IsValid)
            {
                // ServiceLayer.Services.ResetPasswordService _ResetPasswordService = new ServiceLayer.Services.ResetPasswordService();
                Core.Domain.Users list = _manageAdminService.GetUserByEmailandIndustryId(UserName, model.IndustryId);
                if (list != null) //list.Count > 0
                {
                    Core.Domain.Users _objuser = list;
                    var pass = list.Password;
                    Core.Domain.Users user = null;
                    if (_objuser.IsSuperAdmin == true && model.IndustryId == 0)
                    {
                        user = _userService.AuthenticateSuperAdmin(UserName, pass);
                    }

                    else
                    {
                        user = _userService.AuthenticateUser(UserName, model.IndustryId, pass);
                    }

                    if (user != null)
                    {
                        int    cID     = WebSecurity.GetUserId(UserName);
                        string TokenID = _screenPermissionService.GetAuthorizeToken(Convert.ToInt32(cID));
                        Session["TokenID"] = TokenID;
                        if (_objuser.UserTypeId == 1)
                        {
                            ViewBag.ErrMessage = true;
                            return(View());
                        }
                        else
                        {
                            if (Session["TokenID"].ToString() == "")
                            {
                                TokenID            = _screenPermissionService.GetAuthorizeToken(Convert.ToInt32(cID));
                                Session["TokenID"] = TokenID;
                            }
                            //CreateAuthenticateFormsTicket(model);
                            //if (returnUrl != null && returnUrl != "/")
                            //{
                            //    return Redirect(returnUrl);
                            //}
                            var ProfileImage = _objuser.Photo == null ? false : true;
                            //Fill session accordin to the user type.
                            SessionManager.FillAdminSession(_objuser.UserId, _objuser.FirstName, _objuser.LastName, _objuser.Email, Convert.ToInt32(_objuser.UserTypeId), ProfileImage, _objuser.IsSuperAdmin, model.IndustryId);

                            //ViewData.Add("FullName", list[0].FirstName + " " + list[0].LastName);
                            ViewData.Add("FullName", list.FirstName + " " + list.LastName);

                            // Send email to superadmin
                            //string hostName = Dns.GetHostName();
                            //string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString();
                            //CommonFunctions.SendEmail("*****@*****.**", "Superadmin Login Notification", strBody);
                            //return RedirectToRoute("AdminDashboardRoute");
                            return(RedirectToAction("Index", "ManageUser", new { @area = "Admin" }));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", CustomMessages.InvalidUserOrPass);
                        return(View(model));
                    }
                }
                else
                {
                    ModelState.AddModelError("", CustomMessages.InvalidUserOrPass);
                    return(View(model));
                }
            }
            ModelState.AddModelError("", CustomMessages.InvalidUserOrPass);
            return(View(model));
        }