public ActionResult MyOffice([Bind(Include = "UserId,UserAge,UserName,UserEmail,UserMobileNumber,Password")] User user)
 {
     if (ModelState.IsValid)
     {
         using (ShoppingStoreContext db = new ShoppingStoreContext())
         {
             if (user.UserEmail != User.Identity.Name)
             {
                 User userCheck = null;
                 userCheck = db.Users.FirstOrDefault(u => u.UserEmail == user.UserEmail);
                 if (userCheck != null)
                 {
                     ModelState.AddModelError("", "Пользователь с таким логином уже существует");
                     return(View(user));
                 }
             }
             db.Entry(user).State = EntityState.Modified;
             db.SaveChanges();
             if (user != null)
             {
                 FormsAuthentication.SetAuthCookie(user.UserEmail, true);
             }
             return(RedirectToAction("MyOffice"));
         }
     }
     return(View(user));
 }
示例#2
0
 public ActionResult Edit([Bind(Include = "ItemId,CategoryId,ProducerName,Title,Price,ItemArtUrl")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", item.CategoryId);
     return(View(item));
 }