示例#1
0
        //************************************************************************************************************************
        public void Delete(User user)
        {
            var validated = this.context.Users.Where(x => x.Username == user.Username).SingleOrDefault();

            this.context.Users.Remove(validated);

            this.context.SaveChanges();
        }
 public ActionResult Register(User user)
 {
     bool exists = this.userService.Exists(user.Username);
     if (exists)
     {
         this.ModelState.AddModelError("", "Username already exists");
         return View();
     }
     if (user.Username == null || user.Password  == null || user.Email == null)
     {
         this.ModelState.AddModelError("", "Missing user input");
         return View();
     }
     try
     {
         this.userService.Register(user);
     }
     catch (Exception ex)
     {
         this.ModelState.AddModelError("", "An error has occured");
         return View();
     }
     return RedirectToAction("Index", "Home");
 }
示例#3
0
 //***************************************************************************************************************************
 public void ToAdmin(User user)
 {
     user.Admin = true;
     this.context.Users.Remove(user);
     this.context.SaveChanges();
     this.context.Users.Add(user);
     this.context.SaveChanges();
 }