コード例 #1
0
ファイル: UserController.cs プロジェクト: CatMsg/Project
        public HttpResponseMessage Login(user user)
        {
            try
            {
                using (var context = new MyBaseContainer())
                {
                    var table = context.userSet;
                    var model = new user
                    {
                        username = user.username,
                        pwd = user.pwd
                    };
                    var result = table.Where(p => p.username == model.username && p.pwd == model.pwd).ToList();
                    context.SaveChanges();
                    if (result.Count > 0)
                    {
                        //存在
                        return PageHelper.ToJson(new { msg = "ok" });
                    }
                }
            }
            catch (Exception ex)
            {

                return PageHelper.ToJson(new { msg = ex.Source });
            }
            return PageHelper.ToJson(new { msg = "no" });
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: CatMsg/Project
        public HttpResponseMessage Register(user user)
        {
            try
            {
                var ip = GetClientInfo.GetIpAddress;
                var os = GetClientInfo.GetOsVersion();
                var browser = GetClientInfo.GetBrowser();
                using (var context = new MyBaseContainer())
                {
                    var table = context.userSet;
                    var model = new user
                    {
                        username = user.username,
                        pwd = user.pwd,
                        phone = user.phone,
                        role = user.role,
                        ip = ip,
                        os = os,
                        browser = browser
                    };
                    table.Add(model);
                    context.SaveChanges();
                    return PageHelper.ToJson(new { msg = "ok" });
                }
            }
            catch (Exception ex)
            {

                return PageHelper.ToJson(new { msg = ex.Source });
            }
        }