public ActionResult EditUser(string Username, string Name, string Email, string Telephone, string Website, string AddressField1, string AddressField2, string City, string Country, HttpPostedFileBase AvatarPath) { UserBl user = new UserBl(); string avatarPath = ""; if (AvatarPath != null) { string ogFilePath = System.IO.Path.Combine(Server.MapPath(ImageFiles.SaveFilePath(RueEngine.Entities.User.FolderPath))); AvatarPath.SaveAs(ogFilePath); avatarPath = ImageFiles.Crop(100, 100, ogFilePath, RueEngine.Entities.User.FolderPath); //delete og file path when done in case its too big System.IO.File.Delete(ogFilePath); } //check email if ((UserBl.GetUserByEmail(Email) != null && UserBl.GetUserByEmail(Email).Id > 0) && Email != Assets.CurrentUser.Email) { TempData["Error"] = string.Format("Email address {0} is already registered.", Email); return View(); } if ((UserBl.GetUserByUserName(Username) != null && UserBl.GetUserByUserName(Username).Id > 0) && Username != Assets.CurrentUser.Username) { TempData["Error"] = string.Format("Username {0} is already registered.", Username); return View(); } User _user = user.Save(Assets.CurrentUser.Id, Username, Name, "", Email, Telephone, "", Website, true, DateTime.Now, AddressField1, AddressField2, City, Country, avatarPath); TempData["Success"] = "Account profile successfully updated"; return RedirectToAction("index", "dashboard"); }
public ActionResult QuickReg(int? id, string Username, string Name, string Email, string Password, string Captcha) { //validate captcha if (Session["Captcha"] == null || Session["Captcha"].ToString() != Captcha) { TempData["Error"] = string.Format("Your answer for the sum was incorrect."); //dispay error and generate a new captcha return View("register"); } UserBl user = new UserBl(); int _id = id != null ? int.Parse(id.ToString()) : 0; User __user = UserBl.GetUserByEmail(Email); //check if username is one word Regex regex = new Regex("^[A-Za-z]+$"); if (!regex.IsMatch(Username)) { TempData["Error"] = string.Format("{0} is not a valid username.", Username); return View("register"); } //check email if(UserBl.GetUserByEmail(Email) != null && UserBl.GetUserByEmail(Email).Id > 0) { TempData["Error"] = string.Format("Email address {0} is already registered.", Email); return View("register"); } if (UserBl.GetUserByUserName(Username) != null && UserBl.GetUserByUserName(Username).Id > 0) { TempData["Error"] = string.Format("Username {0} is already registered.", Username); return View("register"); } User _user = user.Save(_id, Username, Name, "", Email, "", Password, "", true, DateTime.Now, "", "", "", "", ""); if(_user.Id > 0) { if (_user != null && _user.Id > 0) { string EmailBody = Messaging.EmailTemplate(_user.Name); Messaging.SendEmail(EmailBody, _user.Email, "Thank you for registering with Ndiringe."); } if (MembershipService.ValidateUser(_user.Username, Password)) { SetupFormsAuthTicket(_user.Username, false); TempData["Success"] = string.Format("We have sent an email to {0} . Remember to check your spam folder and add [email protected] to your address book.", _user.Email); TempData["Info"] = MvcHtmlString.Create("Your account profile is still incomplete, you can <a href='\\account\\edituser\\'>update</a> it with more information."); } } return RedirectToAction("index", "dashboard"); }
public ActionResult EditUser(int? id, string Username, string Name, string Surname, string Email, string Telephone, string Password, bool Active, string Website, DateTime DateJoined, string AddressField1, string AddressField2, string City, string Country, HttpPostedFileBase AvatarPath) { UserBl user = new UserBl(); int _id = id != null ? int.Parse(id.ToString()) : 0; string avatarPath = ""; if (AvatarPath != null) { string ogFilePath = System.IO.Path.Combine(Server.MapPath(ImageFiles.SaveFilePath(RueEngine.Entities.User.FolderPath))); AvatarPath.SaveAs(ogFilePath); avatarPath = ImageFiles.Crop(100, 100, ogFilePath, RueEngine.Entities.User.FolderPath); //delete og file path when done in case its too big System.IO.File.Delete(ogFilePath); } User _user = user.Save(_id, Username, Name, Surname, Email, Telephone, Password, Website, Active, DateJoined, AddressField1, AddressField2, City, Country, avatarPath); return RedirectToAction("edituser", "account", new { id = _user.Id }); }
public ActionResult Delete(int? id) { UserBl user = new UserBl(); if (id != null) { user.Delete(int.Parse(id.ToString())); } return RedirectToAction("users"); }
public HttpStatusCodeResult RemoveUserRole(int? Id) { UserBl role = new UserBl(); role.DeleteUserRole(int.Parse(Id.ToString())); return new HttpStatusCodeResult(HttpStatusCode.OK); }
public HttpStatusCodeResult AddUserRole(int? userId, int RoleId) { UserBl role = new UserBl(); role.AddUserRole(int.Parse(userId.ToString()), int.Parse(RoleId.ToString())); return new HttpStatusCodeResult(HttpStatusCode.OK); }
public ActionResult DeleteRole(int? id) { UserBl role = new UserBl(); if (id != null) { role.DeleteRole(int.Parse(id.ToString())); } return RedirectToAction("roles"); }
public ActionResult EditRole(int? id, string Name) { UserBl role = new UserBl(); int _id = id != null ? int.Parse(id.ToString()) : 0; role.SaveRole(_id, Name); return RedirectToAction("roles"); }