Beispiel #1
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(user);
        }
Beispiel #2
0
 public JsonResult Login(string Email, string Password)
 {
     if ((from x in db.Users
          where x.Email.Equals(Email) && x.Password.Equals(Password)
          select new { UserID = x.UserID, Name = x.Name, Surname = x.Surname, NewUser = x.NewUser }).FirstOrDefault() != null)
     {
         return Json((from x in db.Users
                           where x.Email.Equals(Email) && x.Password.Equals(Password)
                           select new { UserID = x.UserID, Name = x.Name, Surname = x.Surname, NewUser = x.NewUser }).FirstOrDefault());
     }
     User data = new User
     {
         UserID = -1
     };
     return Json(data);
 }
Beispiel #3
0
 public JsonResult UsersGetByID(int id = 0)
 {
     if (db.Users.Find(new object[] { id }) != null)
     {
         return Json(db.Users.Find(new object[] { id }), JsonRequestBehavior.AllowGet);
     }
     User data = new User
     {
         UserID = -1
     };
     return Json(data, JsonRequestBehavior.AllowGet);
 }
Beispiel #4
0
 public JsonResult Registration(string Email, string Password)
 {
     User entity = new User
     {
         Email = Email,
         Password = Password,
         NewUser = true
     };
     if ((from o in db.Users
          where o.Email.Equals(Email)
          select o).Count<User>() == 0)
     {
         db.Users.Add(entity);
         db.SaveChanges();
         return Json(entity);
     }
     User data = new User
     {
         UserID = -1
     };
     return Json(data);
 }
Beispiel #5
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(user);
 }