public void Edit(User item, string userId) { var old = FindById(userId); old.LastName = item.LastName; old.FirstName = item.FirstName; old.PhoneNumber = item.PhoneNumber; if (item.ImageBytes != null) { old.ImageBytes = item.ImageBytes; old.ImgMimeType = item.ImgMimeType; } //item.Id = userId; //_userManager.Update(item); _db.Entry(old).State = EntityState.Modified; _db.SaveChanges(); //_userManager. }
public ActionResult Edit(User user, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null && file.ContentType.StartsWith("image")) { user.ImgMimeType = file.ContentType; user.ImageBytes = new byte[file.ContentLength]; file.InputStream.Read(user.ImageBytes, 0, file.ContentLength); } _factory.GetUserRepository(UserManager).Edit(user, User.Identity.GetUserId()); TempData["SuccessMessage"] = "Данные успешно сохранены"; return RedirectToAction("Details"); } return View(user); }
public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new User { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, }; var result = UserManager.Create(user, model.Password); UserManager.AddToRole(user.Id, "User"); if (result.Succeeded) { SignInManager.SignIn(user, isPersistent: false, rememberBrowser: false); UserService.LockUser(UserManager, user.Id, false); return RedirectToAction("Index", "Home"); } AddErrors(result); } return View(model); }
public void Edit(User item) { throw new NotImplementedException(); }
public void Edit(User item) { _userManager.Update(item); }
public void Add(User item, string password, string role = "User") { _userManager.Create(item, password); _userManager.AddToRole(item.Id, role); }
public void Add(User item) { _userManager.Create(item); }