// GET: /USER/Create
 public ActionResult Registration(int id = 0)
 {
     if (id == 0)
     {
         return(View(new USERVM()));
     }
     else
     {
         USERVM model = user.GetUserById(id);
         return(View(model));
     }
 }
示例#2
0
        public int login(USERVM model)
        {
            var res = context.TBL_USER.SingleOrDefault(s => s.username == model.username && s.password == model.password);

            if (res != null)
            {
                return(res.user_id);
            }
            else
            {
                return(0);
            }
        }
        public ActionResult login(USERVM model)
        {
            int check = user.login(model);

            if (check != 0)
            {
                //    TempData["id"] = model.user_id;
                return(RedirectToAction("Index", "BOOK", new { id = check }));
            }
            else
            {
                return(RedirectToAction("login"));
            }
        }
示例#4
0
        public bool ValidateModel(USERVM model)
        {
            if (string.IsNullOrEmpty(model.username))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(model.password))
            {
                return(false);
            }
            if (model.username.Length > 40)
            {
                return(false);
            }
            if (model.password.Length > 50)
            {
                return(false);
            }


            return(true);
        }
示例#5
0
        public void registration(USERVM model)
        {
            bool Isvalid = ValidateModel(model);

            if (Isvalid)
            {
                if (model.user_id == 0)
                {
                    TBL_USER User = new TBL_USER();
                    User.username = model.username;
                    User.password = model.password;

                    context.TBL_USER.Add(User);
                }
                else
                {
                    var res = context.TBL_USER.SingleOrDefault(s => s.user_id == model.user_id);
                    res.username = model.username;
                    res.password = model.password;
                }
                context.SaveChanges();
            }
        }
 public ActionResult Registration(USERVM model)
 {
     user.registration(model);
     return(RedirectToAction("Index", "Home"));
 }