Esempio n. 1
0
        public ActionResult Edit([Bind(Include = "ServerId,ServerName,ServerImage")] Server server,
                                 HttpPostedFileBase imageUpload)
        {
            if (imageUpload != null && ValidateFile(imageUpload))
            {
                SaveServerImage(server, imageUpload);
            }

            if (ModelState.IsValid)
            {
                db.Entry(server).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(server));
        }
Esempio n. 2
0
        public ActionResult Edit([Bind(Include = "UserId,FirstName,LastName,UserName,Email,ProfilePicture")] User user)
        {
            var userId       = HttpContext.User.Identity.GetUserId();
            var userManager  = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var loggedInUser = userManager.FindById(userId);

            if (FindUserByUserName(user.UserName) != null)
            {
                ModelState.AddModelError("username", "Username already matches an existing user.");
            }

            if (ModelState.IsValid)
            {
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(user));
        }