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

            return View(user);
        }
Ejemplo n.º 2
0
 //
 // GET: /Public/
 public ActionResult Login(User u)
 {
     ModelState.Clear();
     if (u != null)
     {
         var context = new MobilniPortalNovicContext12();
         if (context.Users.Where(x => x.Password == u.Password && x.Username == u.Username).FirstOrDefault() != null)
         {
             Session["username"] = u.Username;
             return RedirectToAction("Index");
         }
         ModelState.AddModelError("Error", "Username of parssword is invalid");
         return View(u);
     }
     return View();
 }
Ejemplo n.º 3
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(user);
 }
Ejemplo n.º 4
0
 public String Register(String username, String password)
 {
     try
     {
         var user = new User { Username = username, Password = password, AccessToken = Guid.NewGuid() };
         context.Users.Add(user);
         context.SaveChanges();
         return "Account succesffuly created";
     }
     catch (Exception)
     {
         return "Registration failed";
     }
 }
 private NewsRequest(User u, Coordinates l)
 {
     TargetTime = DateTime.Now;
     Location = l;
     RadiusInKm = 10;
     User = u;
 }