Exemplo n.º 1
0
 public ActionResult Register(UserInfo _user)
 {
     if (ModelState.IsValid)
     {
         var check = _db.UserInfoes.FirstOrDefault(s => s.username == _user.username);
         if (check == null)
         {
             if (_user.passw == "")
             {
                 ViewBag.error = "Please enter password";
                 return(View());
             }
             else
             {
                 //_user.Password = GetMD5(_user.Password);
                 _db.Configuration.ValidateOnSaveEnabled = false;
                 _db.UserInfoes.Add(_user);
                 _db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             ViewBag.error = "User already exists";
             return(View());
         }
     }
     return(View());
 }
 public virtual void Update(T entity)
 {
     dbSet.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
     dataContext.SaveChanges();
 }