Exemplo n.º 1
0
        public async Task<ActionResult> Create(UsuarioViewModel collection)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = collection.UserName, Email = collection.UserName };
                var result = await UserManager.CreateAsync(user, "GlobalPanama01!");
                if (result.Succeeded)
                {
                    return RedirectToAction("Index");
                }
                ViewBag.result = result;
            }

            // If we got this far, something failed, redisplay form
            return View(collection);
        }
Exemplo n.º 2
0
        // GET: Usuarios/Edit/5
        public ActionResult Edit(string id)
        {
            if (id.Equals(string.Empty))
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            var user = identity.Users.Find(id);

            if (user == null)
            {
                return HttpNotFound();
            }

            UsuarioViewModel usuario = new UsuarioViewModel() { Id = user.Id, UserName = user.UserName };
            return View(usuario);
        }
Exemplo n.º 3
0
        public ActionResult Edit(UsuarioViewModel collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add update logic here
                    var usuario = identity.Users.Find(collection.Id);
                    usuario.UserName = collection.UserName;
                    usuario.Email = collection.UserName;
                    identity.SaveChanges();
                    return RedirectToAction("Index");
                }
                catch
                {
                    return View(collection);
                }
            }

            return View(collection);
            
        }