public ActionResult Register()
        {
            var res = _UseradminService.GetCustomerList();

            if (TempData["EditUserId"] != null)
            {
                Login_tbl Login_tbl = _UseradminService.EditUser(Convert.ToInt32(TempData["EditUserId"]));
                return(View("Register", new RegistrationVM
                {
                    ID = Login_tbl.ID,
                    FirstName = Login_tbl.FirstName,
                    LastName = Login_tbl.LastName,
                    Email = Login_tbl.UserName,
                    Password = UrlSecurityManager.Decrypt(Login_tbl.Password, ConfigurationManager.AppSettings["SecurityKey"]),
                    ConfirmPassword = UrlSecurityManager.Decrypt(Login_tbl.Password, ConfigurationManager.AppSettings["SecurityKey"]),
                    MobileNo = Login_tbl.MobileNo,
                    CustomerId = Login_tbl.CustomerId,
                    CustomerList = res
                }));
            }
            else
            {
                return(View("Register", new RegistrationVM {
                    CustomerList = res
                }));
            }
        }
        public ActionResult ProductsById(string ProductId)
        {
            ProductViewModel viewModel;

            if (!string.IsNullOrEmpty(ProductId))
            {
                var res = _productService.GetProduct(Convert.ToDecimal(UrlSecurityManager.Decrypt(ProductId, System.Configuration.ConfigurationManager.AppSettings["SecurityKey"])));
                if (res != null)
                {
                    viewModel = AutoMapper.Mapper.Map <ProductEntity, ProductViewModel>(res);
                    if (viewModel.ProductUserGuide == null)
                    {
                        viewModel.ProductUserGuide = new ProductUserGuideViewModel();
                    }
                    if (viewModel.ProductFAQs != null)
                    {
                        foreach (var item in viewModel.ProductFAQs)
                        {
                            var productFaq   = _productService.GetProductFAQ(item.Id);
                            var viewModelFAQ = AutoMapper.Mapper.Map <ProductFAQs, ProductFaqViewModel>(productFaq);
                            if (viewModelFAQ.ProductFAQVideoList == null)
                            {
                                viewModelFAQ.ProductFAQVideoList = new List <ProductFAQVideoViewModel>();
                            }
                            else
                            {
                                var videos = AutoMapper.Mapper.Map <List <ProductFAQVideos>, List <ProductFAQVideoViewModel> >(productFaq.ProductFAQVideos.ToList());
                                viewModelFAQ.ProductFAQVideoList = videos.Where(y => y.IsDeleted != true).ToList();
                            }
                            item.ProductFAQVideoList = viewModelFAQ.ProductFAQVideoList;
                        }
                    }
                }
                else
                {
                    viewModel = new ProductViewModel();
                    return(Redirect("/Home/Index"));
                }
            }
            else
            {
                viewModel = new ProductViewModel();
                return(Redirect("/Home/Index"));
            }

            ViewBag.SubCategoryList = _subCategoryService.GetSubCategoryList();
            //_homeService.AddProductToRecentViewed(new RecentVisitedProduct() { ProductId = ProductId, UserId = Guid.Parse("6A68CDB1-167F-4323-9D90-34602D20E06D") });
            _homeService.AddProductToRecentViewed(new RecentVisitedProduct()
            {
                ProductId = Convert.ToDecimal(UrlSecurityManager.Decrypt(ProductId, "iPsUniversity2020")), UserId = Convert.ToInt32(Session["UserLoginID"])
            });

            return(View(viewModel));
        }
Example #3
0
        public ActionResult Login(Login_tbl login_Tbl)
        {
            login_Tbl.Password = UrlSecurityManager.Encrypt(login_Tbl.Password, ConfigurationManager.AppSettings["SecurityKey"]);
            var Result = _loginService.UserLogin(login_Tbl);

            if (Result == null)
            {
                //TempData["Success"] = "False";
                //TempData["Message"] = "You are not a valid user...Please Register..!!";
                ViewBag.Message = "You are not a valid user...Please Register..!!";
                return(View());
            }
            else if (Result.RoleID == 4)
            {
                FormsAuthentication.SetAuthCookie(Result.UserName, false);
                Session["AdminLoginID"] = Result.ID;
                Session["RoleID"]       = Result.RoleID;
                Session["AdminName"]    = Result.FirstName + " " + Result.LastName;
                var res       = _UseradminService.GetUserList().ToList();
                var viewModel = AutoMapper.Mapper.Map <List <Login_tbl>, List <Login_tbl> >(res);
                Session["UserList"] = viewModel;
                //  Session["UserLoginID"] = viewModel;
                return(RedirectToAction("Index", "Home"));
            }
            else if (Result.RoleID == 5)
            {
                FormsAuthentication.SetAuthCookie(Result.UserName, false);
                Session["UserLoginID"] = Result.ID;
                Session["RoleID"]      = Result.RoleID;
                Session["UserNamee"]   = Result.FirstName + " " + Result.LastName;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Message = "You are not a valid user...Please Register..!!";
                return(View());
            }
            // return View();
        }
 public ActionResult Register(RegistrationVM p_RegistrationVM)
 {
     if (p_RegistrationVM.ID != 0)
     {
         var res = _UseradminService.SaveEditUserDetails(new Login_tbl
         {
             ID          = p_RegistrationVM.ID,
             FirstName   = p_RegistrationVM.FirstName,
             LastName    = p_RegistrationVM.LastName,
             UserName    = p_RegistrationVM.Email,
             Password    = UrlSecurityManager.Encrypt(p_RegistrationVM.Password, ConfigurationManager.AppSettings["SecurityKey"]), //p_RegistrationVM.Password,
             CustomerId  = p_RegistrationVM.CustomerId,
             MobileNo    = p_RegistrationVM.MobileNo,
             RoleID      = 5,
             CreatedDate = DateTime.Now,
             CreatedBy   = Convert.ToDecimal(Session["RoleID"]),
             IsDeleted   = false,
             AdminId     = Convert.ToInt32(Session["AdminLoginID"])
         });
         if (res.Item1 == true)
         {
             //bool success = SendEmail(p_RegistrationVM.Email, p_RegistrationVM.Password, p_RegistrationVM.FirstName);
             //if (success)
             //{
             return(Json(new { result = true, Message = "User Update Successful", url = "/Admin/User" }));
             //}
             //else
             //{
             //    return Json(new { result = true, Message = "User Registration Successful but Email not sent", url = "/Admin/User" });
             //}
         }
         else
         {
             //if (res.Item2 == true)
             //{
             //    return Json(new { result = false, Message = "Email already Exists.", url = "/Admin/User/Register" });
             //}
             //else
             //{
             return(Json(new { result = false, Message = "something went wrong,please try again.", url = "/Admin/User/Register" }));
             //}
         }
     }
     else
     {
         var res = _UseradminService.RegisterUser(new Login_tbl
         {
             FirstName   = p_RegistrationVM.FirstName,
             LastName    = p_RegistrationVM.LastName,
             UserName    = p_RegistrationVM.Email,
             Password    = UrlSecurityManager.Encrypt(p_RegistrationVM.Password, ConfigurationManager.AppSettings["SecurityKey"]), //p_RegistrationVM.Password,
             CustomerId  = p_RegistrationVM.CustomerId,
             MobileNo    = p_RegistrationVM.MobileNo,
             RoleID      = 5,
             CreatedDate = DateTime.Now,
             CreatedBy   = Convert.ToDecimal(Session["RoleID"]),
             IsDeleted   = false,
             AdminId     = Convert.ToInt32(Session["AdminLoginID"])
         });
         if (res.Item1 == true)
         {
             bool success = SendEmail(p_RegistrationVM.Email, p_RegistrationVM.Password, p_RegistrationVM.FirstName);
             if (success)
             {
                 return(Json(new { result = true, Message = "User Registration Successful and Email Sent", url = "/Admin/User" }));
             }
             else
             {
                 return(Json(new { result = true, Message = "User Registration Successful but Email not sent", url = "/Admin/User" }));
             }
         }
         else
         {
             if (res.Item2 == true)
             {
                 return(Json(new { result = false, Message = "Email already Exists.", url = "/Admin/User/Register" }));
             }
             else
             {
                 return(Json(new { result = false, Message = "something went wrong,please try again.", url = "/Admin/User/Register" }));
             }
         }
     }
 }
Example #5
0
 public ActionResult ChangePassword(ChangePasswordVM ChangePasswordVM)
 {
     if (ChangePasswordVM.NewPassword.Equals(ChangePasswordVM.ConfirmPassword))
     {
         var Result = _loginService.ChangePassword(Session["UnEncryptedEmail"].ToString(), UrlSecurityManager.Encrypt(ChangePasswordVM.NewPassword, ConfigurationManager.AppSettings["SecurityKey"]));
         if (Result)
         {
             return(Json(new { Message = "Change Password Successful", url = "/Login/Login" }));
         }
         else
         {
             return(Json(new { Message = "Change Password UnSuccessful", url = "/Login/Login" }));
         }
     }
     else
     {
         return(Json(new { Message = "New Password and Confirm Password do not match.Please try again", url = "/Login/Login" }));
     }
 }
Example #6
0
        public ActionResult ForgotPassword(string Email)
        {
            Login_tbl Login_tbl = _loginService.ForgotPassword(Email);

            if (Login_tbl != null)
            {
                var EmailInfo = _loginService.AddEmailInfo(Login_tbl.ID);
                var smtp      = new SmtpClient
                {
                    Host                  = ConfigurationManager.AppSettings["Host"],
                    Port                  = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(ConfigurationManager.AppSettings["AdminId"], ConfigurationManager.AppSettings["AdminPassword"])
                };
                using (var message = new MailMessage(new MailAddress(ConfigurationManager.AppSettings["AdminId"], "Admin"), new MailAddress(Email, "user"))
                {
                    Subject = "Reset Password",
                    Body = "Hello " + Login_tbl.FirstName + ",<br/><br/>Welcome to Online Training Portal. We received a request to reset your password.Please <a href=" + ConfigurationManager.AppSettings["ChangePasswordUrl"] + "/" + UrlSecurityManager.Encrypt(EmailInfo.ID.ToString(), ConfigurationManager.AppSettings["SecurityKey"]) + ">Click Here</a> to reset Password<br/><br/>This link is only valid for 30 minutes. <br/><br/><br/>Regards,<br/>Admin"
                })
                {
                    message.IsBodyHtml = true;
                    smtp.Send(message);
                }
                TempData["Success"] = "True";
                TempData["Message"] = "please check your email to change password";
                return(RedirectToAction("Login"));
            }
            else
            {
                TempData["Success"] = "False";
                TempData["Message"] = "Email does not exist.Please contact Admin for registration";
                return(RedirectToAction("Login"));
            }
        }