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 Details(int id, SbUserService sbUser) { DataSet ds = new DataSet(); ds = sbUser.GetByID_Sb_User(); if (ds.Tables[0].Rows.Count > 0) { sbUser.FirstName = ds.Tables[0].Rows[0]["FirstName"].ToString(); sbUser.LastName = ds.Tables[0].Rows[0]["LastName"].ToString(); sbUser.EmailId = ds.Tables[0].Rows[0]["EmailId"].ToString(); sbUser.Password = ds.Tables[0].Rows[0]["Password"].ToString(); sbUser.MobileNumber = ds.Tables[0].Rows[0]["MobileNumber"].ToString(); sbUser.CompanyURL = ds.Tables[0].Rows[0]["CompanyURL"].ToString(); //sbUser.IsSeller = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsSeller"].ToString()); sbUser.Status = Convert.ToBoolean(ds.Tables[0].Rows[0]["Status"].ToString()); if (Convert.ToString(ds.Tables[0].Rows[0]["ModifiedOn"]) == "") { sbUser.ModifiedOn = ""; } else { sbUser.ModifiedOn = ds.Tables[0].Rows[0]["ModifiedOn"].ToString(); } } return(View(sbUser)); }
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 Delete(int id, SbUserService sbUser) { if (id != 0) { try { SbUserService objsbUserService = new SbUserService(); objsbUserService.ID = id; bool IsDeleted = false; IsDeleted = objsbUserService.DeleteByID_Sb_User(); if (IsDeleted) { ViewBag.Message = "Information has been deleted successfully"; } } catch (Exception ee) { ViewBag.Message = "Error Occurred:" + ee; } } return(RedirectToAction("Index")); }
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"); }
public ActionResult Update(int?id, SbUserService sbUser) { try { DataSet ds = new DataSet(); ds = sbUser.GetByID_Sb_User(); if (ds.Tables[0].Rows.Count > 0) { sbUser.FirstName = ds.Tables[0].Rows[0]["FirstName"].ToString(); sbUser.LastName = ds.Tables[0].Rows[0]["LastName"].ToString(); sbUser.EmailId = ds.Tables[0].Rows[0]["EmailId"].ToString(); sbUser.MobileNumber = ds.Tables[0].Rows[0]["MobileNumber"].ToString(); sbUser.CompanyURL = ds.Tables[0].Rows[0]["CompanyURL"].ToString(); sbUser.ProfilePicture = ds.Tables[0].Rows[0]["ProfilePicture"].ToString(); TempData["PreviousImage"] = sbUser.ProfilePicture; } return(View(sbUser)); } catch (Exception ee) { ViewBag.Message = "Error Occured"; return(ViewBag.Message); } }
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 Update(int id, SbUserService sbUser, HttpPostedFileBase profilepicture) { if (id != 0) { try { SbUserService objsbUserService = new SbUserService(); //System.Drawing.Image image = System.Drawing.Image.FromStream(profilepicture.InputStream, true, true); //string[] sAllowedExt = new string[] { ".jpg", ".gif", ".jpeg" }; //if (!sAllowedExt.Contains(profilepicture.FileName.Substring(profilepicture.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 ratio 1:1"); // return View(); //} 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.MobileNumber)) { ModelState.AddModelError("MobileNumber", "Mobile Number is required"); } if (!string.IsNullOrEmpty(sbUser.FirstName)) { string path = null; if (profilepicture != null) { string fileName = Path.GetFileName(profilepicture.FileName); path = "/ProfilePicture/" + fileName; profilepicture.SaveAs(Server.MapPath(path)); } objsbUserService.ID = id; objsbUserService.FirstName = sbUser.FirstName; objsbUserService.LastName = sbUser.LastName; objsbUserService.EmailId = sbUser.EmailId; objsbUserService.MobileNumber = sbUser.MobileNumber; if (path != null) { objsbUserService.ProfilePicture = path; } else { objsbUserService.ProfilePicture = TempData["PreviousImage"].ToString(); } objsbUserService.CompanyURL = sbUser.CompanyURL; objsbUserService.Status = sbUser.Status; bool IsUpdated = false; IsUpdated = objsbUserService.UpdateSb_User(); if (IsUpdated) { ViewBag.Message = "Information has been updated successfully"; } } } catch (Exception ee) { ViewBag.Message = "Error Occurred"; } } return(View(sbUser)); }
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)); } }