예제 #1
0
        public ActionResult Edit(int userid)
        {
            var result = new UserRepository().Get(userid);
            var user   = APIFunctions.GetData <UserInformation>(JsonConvert.SerializeObject(result));

            return(View(user));
        }
예제 #2
0
        public ActionResult Index(int userid)
        {
            var result  = (new UserRepository()).Get(userid);
            var usuario = APIFunctions.GetData <UserInformation>(JsonConvert.SerializeObject(result));

            return(View(APIFunctions.UserToUsuario(usuario)));
        }
예제 #3
0
        public ActionResult LogIn(string user, string password)
        {
            var result  = (new UserRepository()).LogIn(user, password);
            var usuario = APIFunctions.GetData <UserInformation>(JsonConvert.SerializeObject(result));

            if (usuario == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", new { userid = usuario.UserID }));
        }
예제 #4
0
        public ActionResult Register(string userdata)
        {
            var    user        = JsonConvert.DeserializeObject <UserInformation>(userdata);
            var    result      = (new UserRepository()).Add(user);
            var    usuarioID   = APIFunctions.GetData <int>(JsonConvert.SerializeObject(result));
            string redirecturl = new UrlHelper(Request.RequestContext).Action("Index", new { userid = usuarioID });

            if (usuarioID == default(int))
            {
                redirecturl = new UrlHelper(Request.RequestContext).Action("Register");
            }
            return(Json(new { Url = redirecturl }));
        }
예제 #5
0
        public ActionResult Update(int userid, string userdata)
        {
            var user = JsonConvert.DeserializeObject <UserInformation>(userdata);

            user.UserID = userid;
            var    result      = new UserRepository().Update(user);
            var    data        = APIFunctions.GetData <int>(JsonConvert.SerializeObject(result));
            string redirecturl = new UrlHelper(Request.RequestContext).Action("Index", new { userid = data });

            if (data == default(int))
            {
                redirecturl = new UrlHelper(Request.RequestContext).Action("Edit", new { userid = userid });
            }
            return(Json(new { Url = redirecturl }));
        }