public ActionResult AddUser(UserDTO user) { user.Lang = "en-us"; List<string> msgs = new List<string>(); if (userManager.UserValidation(user, msgs)) { if (!userManager.IfUserNameExists(user.UserName) && !userManager.IfEmailExists(user.Email)) { userManager.InsertUser(user); return RedirectToAction("UsersMenu", "Settings"); } else { ModelState.Clear(); ModelState.AddModelError("", Resources.Resource.LoginEmailExist); return View(); } } else { ModelState.Clear(); foreach (string msg in msgs) { ModelState.AddModelError("", msg); } return View(); } }
public ActionResult AddUser() { //var user = mainContext.Users.; UserDTO user = new UserDTO(); return View(user); }
public void UploudImage(PersonDTO person, FormCollection formCollection, UserDTO currentUser) { var profileAvatar = "item_0_profile.jpg"; person.ImageName = personManager.GetPersonByUserId(currentUser.Id).ImageName; foreach (string item in Request.Files) { HttpPostedFileBase file = Request.Files[item] as HttpPostedFileBase; if (file.ContentLength == 0) continue; if (file.ContentLength > 0) { // width + height will force size, care for distortion //Exmaple: ImageUpload imageUpload = new ImageUpload { Width = 800, Height = 700 }; // height will increase the width proportionally //Example: ImageUpload imageUpload = new ImageUpload { Height= 600 }; // width will increase the height proportionally ImageUpload imageUpload = new ImageUpload { Width = 200 }; string mapImage = Server.MapPath(@"~\Images\") + person.ImageName; //delete last image if (file.FileName != person.ImageName) imageUpload.DeleteFile(person.ImageName, profileAvatar, mapImage); // rename, resize, and upload //return object that contains {bool Success,string ErrorMessage,string ImageName} ImageResult imageResult = imageUpload.RenameUploadFile(file); if (imageResult.Success) { //TODO: write the filename to the db person.ImageName = imageResult.ImageName; } else { // use imageResult.ErrorMessage to show the error ViewBag.Error = imageResult.ErrorMessage; } } } }
public ActionResult AddUser() { UserDTO user = new UserDTO(); return View(user); }
private void logOutButton_Click(object sender, EventArgs e) { User = null; User = FormManager.ShowForm<LoginForm, UserDTO>(new LoginForm()); }