public ActionResult Login(Login login)
        {
            try
            {
                SbUserService objUserservice = new SbUserService();
                if (!string.IsNullOrEmpty(login.EmailId))
                {
                    Login objLogin = new Login();
                    objLogin.EmailId = login.EmailId;
                    string password = login.Password;
                    objLogin.Password = objUserservice.GetEncryptedValue(password);
                    DataSet ds = objLogin.GetData_Sb_User();

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        Session["username"]       = ds.Tables[0].Rows[0]["EmailId"].ToString();
                        Session["Name"]           = ds.Tables[0].Rows[0]["FirstName"].ToString();
                        Session["ProfilePicture"] = ds.Tables[0].Rows[0]["ProfilePicture"].ToString();
                        return(RedirectToAction("../Seller/Index"));
                    }
                    else
                    {
                        ViewBag.Message = "Wrong Email or Password entered";
                    }
                }
            }
            catch (Exception ee)
            {
                ViewBag.Message = "Error Occurred";
            }
            return(View(login));
        }
        public ActionResult Login(sbAdministrator login)
        {
            try
            {
                SbUserService objUserService = new SbUserService();
                if (!string.IsNullOrEmpty(login.EmailId))
                {
                    sbAdministrator objAdministrator = new sbAdministrator();
                    objAdministrator.EmailId = login.EmailId;
                    string password = login.Password;
                    objAdministrator.Password = objUserService.GetEncryptedValue(password);

                    DataSet ds = objAdministrator.Sb_Login();

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        Session["username"] = ds.Tables[0].Rows[0]["Name"].ToString();
                        return(RedirectToAction("../Administrator/Index"));
                    }
                    else
                    {
                        ViewBag.Message = "Wrong Email or Password entered";
                    }
                }
            }
            catch (Exception ee)
            {
                ViewBag.Message = "Error Occurred";
            }
            return(View(login));
        }
        public ActionResult ChangePassword(sbAdministrator chngPass)
        {
            try
            {
                SbUserService objUserService = new SbUserService();
                if (!string.IsNullOrEmpty(chngPass.EmailId))
                {
                    sbAdministrator objsbsbAdministrator = new sbAdministrator();

                    objsbsbAdministrator.EmailId     = chngPass.EmailId;
                    objsbsbAdministrator.Password    = objUserService.GetEncryptedValue(chngPass.Password);
                    objsbsbAdministrator.NewPassword = objUserService.GetEncryptedValue(chngPass.NewPassword);
                    //objsbsbAdministrator.Name = Session["username"].ToString();
                    bool IsUpdated = false;
                    IsUpdated = objsbsbAdministrator.UpdateSb_User();
                    if (IsUpdated)
                    {
                        ViewBag.Message = "Password changed successfully";
                    }
                    else
                    {
                        ViewBag.Message = "Wrong password entered ";
                    }
                    ModelState.Clear();
                    ModelState.Remove("EmailId");
                    chngPass.EmailId = "";
                    ModelState.Remove("Password");
                    chngPass.Password = "";
                    ModelState.Remove("Password");
                    chngPass.NewPassword = "";
                }
                return(View(chngPass));
            }
            catch (Exception ee)
            {
                ViewBag.Message = "Error Occure";
                return(View());
            }
        }
        public ActionResult ResetPassword(string id, ResetPassword resetPassword)
        {
            try
            {
                SbUserService    objUserService    = new SbUserService();
                ResetPassword    objsbUserService  = new ResetPassword();
                sbForgotPassword objForgotPassword = new sbForgotPassword();
                objForgotPassword.ResetPasswordCode = id;
                DataSet ds = objForgotPassword.GetEmailIdBasedOnResetCode();
                objsbUserService.EmailId         = ds.Tables[0].Rows[0]["EmailId"].ToString();
                objsbUserService.NewPassword     = objUserService.GetEncryptedValue(resetPassword.NewPassword);
                objsbUserService.ConfirmPassword = objUserService.GetEncryptedValue(resetPassword.ConfirmPassword);

                bool IsUpdated = false;
                IsUpdated = objsbUserService.UpdatePasswordSb_User();
                if (IsUpdated)
                {
                    ViewBag.Message = "Password changed successfully";
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception ee)
            {
                ViewBag.Message = "Error occured please try after sometime";
            }
            ModelState.Clear();
            ModelState.Remove("Password");
            resetPassword.NewPassword = "";
            ModelState.Remove("Password");
            resetPassword.ConfirmPassword = "";
            return(View());
            // return RedirectToAction("../Login/Login");
        }
Пример #5
0
        public ActionResult Registration(SbUserService sbUser, HttpPostedFileBase fileUpload)
        {
            try
            {
                SbUserService objsbUserService = new SbUserService();
                if (string.IsNullOrEmpty(sbUser.FirstName))
                {
                    ModelState.AddModelError("FirstName", "First Name is required");
                }
                if (string.IsNullOrEmpty(sbUser.LastName))
                {
                    ModelState.AddModelError("LastName", "Last Name is required");
                }
                if (string.IsNullOrEmpty(sbUser.EmailId))
                {
                    ModelState.AddModelError("EmailId", "Email is required");
                }
                if (string.IsNullOrEmpty(sbUser.Password))
                {
                    ModelState.AddModelError("Password", "Password is required");
                }
                if (string.IsNullOrEmpty(sbUser.MobileNumber))
                {
                    ModelState.AddModelError("MobileNumber", "Mobile Number is required");
                }
                if (fileUpload == null)
                {
                    ModelState.AddModelError("ProfilePicture", "Profile Picture is required");
                }
                if (!string.IsNullOrEmpty(sbUser.EmailId))
                {
                    objsbUserService.EmailId = Convert.ToString(sbUser.EmailId);

                    bool IsExist = false;
                    IsExist = objsbUserService.IsEmailExists();
                    if (IsExist)
                    {
                        ViewBag.Message = "Email already Registered";
                        return(View());
                    }
                }
                if (fileUpload != null)
                {
                    System.Drawing.Image image       = System.Drawing.Image.FromStream(fileUpload.InputStream, true, true);
                    string[]             sAllowedExt = new string[] { ".jpg", ".gif", ".jpeg" };

                    if (!sAllowedExt.Contains(fileUpload.FileName.Substring(fileUpload.FileName.LastIndexOf('.'))))
                    {
                        ModelState.AddModelError("ProfilePicture", "Please upload Your Image of type: " + string.Join(", ", sAllowedExt));
                        return(View());
                    }
                    else if (image.Width != image.Height)
                    {
                        ModelState.AddModelError("ProfilePicture", "Please select image having same height and width");
                        return(View());
                    }
                }

                if (ModelState.IsValid)
                {
                    if (fileUpload != null)
                    {
                        string fileName = Path.GetFileName(fileUpload.FileName);
                        string path     = "/ProfilePicture/" + fileName;
                        fileUpload.SaveAs(Server.MapPath(path));
                        objsbUserService.FirstName    = sbUser.FirstName;
                        objsbUserService.LastName     = sbUser.LastName;
                        objsbUserService.EmailId      = sbUser.EmailId;
                        objsbUserService.Password     = objsbUserService.GetEncryptedValue(sbUser.Password);
                        objsbUserService.MobileNumber = sbUser.MobileNumber;
                        objsbUserService.CompanyURL   = sbUser.CompanyURL;
                        //objsbUserService.IsSeller = sbUser.IsSeller;
                        objsbUserService.ProfilePicture = path;
                        objsbUserService.Status         = sbUser.Status;

                        bool IsInserted = false;
                        IsInserted = objsbUserService.AddSb_User();
                        if (IsInserted)
                        {
                            ViewBag.Message = "Information has been saved successfully";
                        }
                        ModelState.Clear();
                        ModelState.Remove("FirstName");
                        sbUser.FirstName = "";
                        ModelState.Remove("LastName");
                        sbUser.LastName = "";
                        ModelState.Remove("EmailId");
                        sbUser.EmailId = "";
                        ModelState.Remove("Password");
                        sbUser.Password = "";
                        ModelState.Remove("MobileNumber");
                        sbUser.MobileNumber = "";
                        ModelState.Remove("CompanyURL");
                        sbUser.CompanyURL = "";
                        ModelState.Remove("ProfilePicture");
                        sbUser.ProfilePicture = null;
                        //ModelState.Remove("IsSeller");
                        //sbUser.IsSeller = false;
                    }
                }
                return(View(sbUser));
            }
            catch (Exception ee)
            {
                ViewBag.Message = "Error Occurred";
                return(View());
            }
        }
        public ActionResult ChangePassword(Login login)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("../Login/Login"));
            }
            else
            {
                SbUserService objUserService = new SbUserService();
                if (string.IsNullOrEmpty(login.EmailId))
                {
                    ModelState.AddModelError("EmailId", "Please enter Email Id");
                }
                if (string.IsNullOrEmpty(login.OldPassword))
                {
                    ModelState.AddModelError("OldPassword", "Please enter old password");
                }
                if (string.IsNullOrEmpty(login.NewPassword))
                {
                    ModelState.AddModelError("NewPassword", "Please enter new password");
                }
                if (!ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(login.EmailId))
                    {
                        Login objsbLoginService = new Login();

                        objsbLoginService.EmailId     = login.EmailId;
                        objsbLoginService.OldPassword = objUserService.GetEncryptedValue(login.OldPassword);
                        DataSet ds = objsbLoginService.GetEmailId_Sb_User();

                        if (Convert.ToInt32(ds.Tables[0].Rows[0]["Column1"].ToString()) == 1)
                        {
                            objsbLoginService.EmailId     = login.EmailId;
                            objsbLoginService.NewPassword = objUserService.GetEncryptedValue(login.NewPassword);

                            bool IsUpdated = false;
                            IsUpdated = objsbLoginService.UpdateSb_User();
                            if (IsUpdated)
                            {
                                ViewBag.Message = "Password changed successfully";
                            }
                            else
                            {
                                ViewBag.Message = "Error occured please try after sometime";
                            }
                        }
                        if (Convert.ToInt32(ds.Tables[0].Rows[0]["Column1"].ToString()) == 0)
                        {
                            ViewBag.Message = "Invalid EmailId";
                        }
                        if (Convert.ToInt32(ds.Tables[0].Rows[0]["Column1"].ToString()) == -1)
                        {
                            ViewBag.Message = "Invalid EmailId or password";
                        }
                    }
                }
                ModelState.Clear();
                ModelState.Remove("EmailId");
                login.EmailId = "";
                ModelState.Remove("Password");
                login.OldPassword = "";
                ModelState.Remove("Password");
                login.NewPassword = "";
                return(View(login));
            }
        }