示例#1
0
        public void testGetAuthUrl()
        {
            Dictionary <String, String> configurationMap = new Dictionary <string, string>();
            string clientId     = "AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd";
            string clientSecret = "EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX";

            configurationMap.Add("mode", "sandbox");

            APIContext apiContext = new APIContext();

            apiContext.Config = configurationMap;
            List <string> scopelist = new List <string>();

            scopelist.Add("openid");
            scopelist.Add("email");
            string redirectURI = "https://devtools-paypal.com";
            string redirectURL = Session.GetRedirectURL(clientId, redirectURI, scopelist, apiContext);

            Console.WriteLine(redirectURL);
            CreateFromAuthorizationCodeParameters param = new CreateFromAuthorizationCodeParameters();

            param.setClientId(clientId);
            param.setClientSecret(clientSecret);
            // code you will get back as part of the url after redirection
            param.setCode("VxirnJHENB8k5slnoqZOdmjQcCMJRvbI-ispixwWHke-gsOh6XJaWQNJuTCTp3n3o6ttQs3VoNX1De3HOVpmH2PLN53PPedZcTujzLqYrlTS-CqKHYb5wb0NT2joumArOdEy51D4HgoCa46dxuPMm79nX40RQXRP8J0OQsgrEbhf_Kna");
            Tokeninfo          info           = Tokeninfo.CreateFromAuthorizationCode(apiContext, param);
            UserinfoParameters userinfoParams = new UserinfoParameters();

            userinfoParams.setAccessToken(info.access_token);
            Userinfo userinfo = Userinfo.GetUserinfo(apiContext, userinfoParams);

            Console.WriteLine("Email" + userinfo.email);
        }
示例#2
0
        /// <summary>
        /// Send a request to the UserInfo API to retrieve the user's information.
        /// </summary>
        /// <param name="credentials">OAuth 2.0 credentials to authorize the request.</param>
        /// <returns>User's information.</returns>
        /// <exception cref="NoUserIdException">An error occurred.</exception>
        static Userinfo GetUserInfo(IAuthorizationState credentials)
        {
            // create base client service initializer
            BaseClientService.Initializer baseClientService = new BaseClientService.Initializer()
            {
                Authenticator = GetAuthenticatorFromState(credentials)
            };

            Oauth2Service userInfoService = new Oauth2Service(baseClientService);
            Userinfo      userInfo        = null;

            try
            {
                userInfo = userInfoService.Userinfo.Get().Fetch();
            }
            catch (GoogleApiRequestException e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
            }
            if (userInfo != null && !String.IsNullOrEmpty(userInfo.Id))
            {
                return(userInfo);
            }
            else
            {
                throw new NoUserIdException();
            }
        }
        /// <summary>
        ///  用户中心  订单详情页面
        /// </summary>
        /// <returns></returns>
        // GET: OrderNumber
        public ActionResult Detail(int?Id, double?sum)
        {
            Userinfo user = Session["user"] as Userinfo;

            if (user == null)
            {
                return(RedirectToAction("Login", "User"));
            }
            else
            {
                ViewBag.user = user;



                ViewBag.cartcount = db.Cart.Where(c => c.UserId == user.Id).Sum(c => c.Number);


                IEnumerable <Orders> orderlist = db.Orders.Where(o => o.Id == Id && o.UserId == user.Id);

                //查询到1条数据,由ID查找
                var order = db.Orders.Where(o => o.Id == Id && o.UserId == user.Id).FirstOrDefault();

                return(View(order));
            }
        }
示例#4
0
        /// <summary>
        /// 登录Wekan
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public IActionResult Login(string code)
        {
            var dingUser = dingWapper.GetUserinfo(code);

            if (dingUser == null)
            {
                return(new ContentResult()
                {
                    Content = "获取钉钉用户信息失败,请关闭,再重新打开"
                });
            }
            //logger.LogInformation(fastJSON.JSON.ToJSON(dingUser));

            var wekanUserinfo = new Userinfo()
            {
                Username = dingUser.Userid,
                Fullname = dingUser.Username,
                Avatar   = dingUser.Avatar,
                Email    = dingUser.Email,
                Password = dingUser.Openid
            };

            var wekanResult = wekanUser.Login(wekanUserinfo);

            ViewData["Result"]    = wekanResult;
            ViewData["WekanRoot"] = configuration["WekanRoot"];
            return(View());
        }
示例#5
0
        /// <summary>
        /// 后台上分,用上事务
        /// </summary>
        /// <param name="u"></param>
        /// <param name="ls"></param>
        public void AdminShangFen(Userinfo u, Liushui ls)
        {
            string        sql1   = "update userinfo set balance=balance+@money where id=@userid";
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [liushui](");
            strSql.Append(" [userid], [username], [beforemoney], [changemoney], [aftermoney], [remark], [type], [xzid], [txid], [czid], [fhdate], [czr]  )");
            strSql.Append(" values (");
            strSql.Append("  @userid, @username, @beforemoney, @changemoney, @aftermoney, @remark, @type, @xzid, @txid, @czid, @fhdate, @czr  ) ;select @@IDENTITY");

            using (var conn = ConnectionFactory.GetOpenConnection(ConnStr))
            {
                IDbTransaction tran = conn.BeginTransaction();
                try
                {
                    conn.Execute(sql1, new { money = ls.changemoney, userid = u.id }, tran);
                    conn.Execute(strSql.ToString(), ls, tran);
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
            }
        }
示例#6
0
        public static List <Userinfo> GetUserinfos()
        {
            List <Userinfo> list = new List <Userinfo>();
            string          sql  = "select UserID,UserTypeID,NickrName,Gender,Phone,AccountNumber,PassWord,RealName,AccountBalance,PayPassWord from tb_user";
            SqlDataReader   dr   = DBHelper.GetRead(sql);

            while (dr.Read())
            {
                Userinfo u = new Userinfo();
                u.UserID         = dr.GetInt32(0);
                u.UserType       = dr.GetInt32(1);
                u.NickName       = dr.GetString(2);
                u.Gender         = dr.GetString(3);
                u.Phone          = dr.GetString(4);
                u.AccountNumber  = dr.GetString(5);
                u.Password       = dr.GetString(6);
                u.RealName       = dr.GetString(7);
                u.AccountBalance = dr.GetDecimal(8);
                u.PayPassWord    = dr.GetInt32(9);
                list.Add(u);
            }
            dr.Close();

            return(list);
        }
示例#7
0
        public static List <Userinfo> chackList()
        {
            string          sql  = "select * from tb_user";
            List <Userinfo> list = new List <Userinfo>();
            SqlDataReader   dr   = DBHelper.GetRead(sql);

            while (dr.Read())
            {
                Userinfo u = new Userinfo();
                u.UserID            = dr.GetInt32(0);
                u.UserType          = dr.GetInt32(1);
                u.NickName          = dr.GetString(2);
                u.Gender            = dr.GetString(3);
                u.Phone             = dr.GetString(4);
                u.AccountNumber     = dr.GetString(5);
                u.Password          = dr.GetString(6);
                u.RealName          = dr.GetString(7);
                u.AccountBalance    = dr.GetDecimal(8);
                u.PayPassWord       = dr.GetInt32(9);
                u.PersonalStatement = dr.GetString(10);
                list.Add(u);
            }
            dr.Close();

            return(list);
        }
示例#8
0
        void RemoveUserFromSelected(string user_id)
        {
            Userinfo user = SelectedUsers.Single(x => x.user_id == user_id);

            SelectedUsers.Remove(user);
            gridControlSelected.RefreshDataSource();
        }
示例#9
0
    private void Del()
    {
        string   str       = "";
        Userinfo condition = new Userinfo();

        condition.State = 0;
        Userinfo        value = new Userinfo();
        List <Userinfo> list  = TableOperate <Userinfo> .Select(value, condition);

        if (list.Count > 0)
        {
            for (int i = 0; i < list.Count; i++)
            {
                str += list[i].ID + ",";
            }
            if (str != "")
            {
                str = str.Trim(',');

                string sql1 = " Delete  UserFaceTime where UserID  in (" + str + ") ";
                TableOperate <UserFaceTime> .Execute(sql1);

                string sql2 = " Delete  Userinfo where State=0 ";
                TableOperate <Userinfo> .Execute(sql2);

                string sql3 = " Delete  Face where UserinfoID in (“+str+”) ";
                TableOperate <Face> .Execute(sql3);

                string url = "http://127.0.0.1:5477/?json=restart";
                HttpHelp.Get(url);
            }
        }
    }
示例#10
0
        public ActionResult List(int?id)
        {
            Userinfo user = Session["user"] as Userinfo;

            if (user == null)
            {
                return(RedirectToAction("Login", "User"));
            }

            //当前用户的购物车的所有物品
            IEnumerable <Cart> clist = db.Cart.Where(c => c.UserId == user.Id).OrderByDescending(c => c.Id);

            ViewBag.cartcount = clist.Sum(c => c.Number);


            //当前用户的收货地址列表
            ViewBag.addresslist = db.Address.Where(a => a.UserId == user.Id).ToList();
            //addrelist;


            //获得当前的省级菜单
            ViewBag.province = db.Area.Where(a => a.ParentId == null).ToList();

            //由编辑按钮传值过来的id查找
            ViewBag.editAddress = db.Address.Find(id);


            //获取当前商品的库存
            // int? amount = db.Goods.Find(goodsid).Amount;
            // ViewBag.amount = amount;
            return(View(clist.ToList()));
        }
示例#11
0
        public async Task <IActionResult> PostUserinfo([FromBody] Userinfo userinfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Userinfo.Add(userinfo);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (UserinfoExists(userinfo.Id))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetUserinfo", new { id = userinfo.Id }, userinfo));
        }
示例#12
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Userinfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update userinfo set ");
            strSql.Append("UserName=@UserName,");
            strSql.Append("Email=@Email,");
            strSql.Append("UserPwd=@UserPwd");
            strSql.Append(" where UserId=@UserId");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@UserName", MySqlDbType.VarChar, 255),
                new MySqlParameter("@Email",    MySqlDbType.VarChar, 255),
                new MySqlParameter("@UserPwd",  MySqlDbType.VarChar, 255),
                new MySqlParameter("@UserId",   MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.Email;
            parameters[2].Value = model.UserPwd;
            parameters[3].Value = model.UserId;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#13
0
        public async Task <IActionResult> PutUserinfo([FromRoute] long id, [FromBody] Userinfo userinfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != userinfo.id)
            {
                return(BadRequest());
            }

            _context.Entry(userinfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserinfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#14
0
    protected void addcart_Click(object sender, ImageClickEventArgs e)
    {
        Userinfo user = new Userinfo();

        if (this.countliteral.Text.Trim() != "缺货")
        {
            cart ocart = new cart();
            if (ocart.isexitproduct(int.Parse(this.Request.QueryString["pid"].ToString())) == false)
            {
                if (ocart.addtocart(int.Parse(this.Request.QueryString["pid"].ToString()), user.getUserID(), 1, false) == 1)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('购物成功')</script>", false);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('购物失败')</script>", false);
                }
            }
            else
            {
                if (ocart.updatecartbyid(int.Parse(this.Request.QueryString["pid"].ToString())) == 1)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('购物成功')</script>", false);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('购物失败')</script>", false);
                }
            }
        }
        else
        {
            this.addcart.Enabled = false;
        }
    }
示例#15
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Userinfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into userinfo(");
            strSql.Append("UserName,UserPwd,Email)");
            strSql.Append(" values (");
            strSql.Append("@UserName,@UserPwd,@Email)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@UserName", MySqlDbType.VarChar, 255),
                new MySqlParameter("@UserPwd",  MySqlDbType.VarChar, 255),
                new MySqlParameter("@Email",    MySqlDbType.VarChar, 255)
            };
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.UserPwd;
            parameters[2].Value = model.Email;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#16
0
        //end
        //Take two parameter username and password and check if user exist and password
        //is correct then create the session for login.
        internal static SigninResult Signin(string username, string password)
        {
            Userinfo user = db.Userinfoes.Find(username);

            if (user != null)
            {
                if (Cryptography.matchHash(user.passwordHash, password))
                {
                    HttpContext.Current.Session["login"] = "******";
                    HttpContext.Current.Session["role"]  = user.role;
                    if (user.role == "student")
                    {
                        Student std = db.Students.Where(s => s.username == user.username).Single();
                        HttpContext.Current.Session["name"] = std.fullName;
                        HttpContext.Current.Session["id"]   = std.rollNo;
                    }
                    else
                    {
                        Teacher tchr = db.Teachers.Where(t => t.username == user.username).Single();
                        HttpContext.Current.Session["name"] = tchr.name;
                        HttpContext.Current.Session["id"]   = tchr.teacherID;
                    }
                    return(SigninResult.OK);
                }
                else
                {
                    return(SigninResult.WrongPassword);
                }
            }
            else
            {
                return(SigninResult.WrongUsername);
            }
        }
示例#17
0
        public void Register(Userinfo user, string code)
        {
            string key   = KEY_PREFIX + user.Phone;
            string value = _cacheClientDB.Get <string>(key);

            if (!code.Equals(value))
            {
                //验证码不匹配
                throw new Exception("验证码不匹配");
            }
            user.Salt = PasswordHelper.MD5EncodingWithoutSalt(user.Username);

            ////生成盐
            //String salt = CodecUtils.generateSalt();
            //user.setSalt(salt);
            ////生成密码
            string md5Pwd = PasswordHelper.MD5Encoding(user.Password, user.Salt);

            user.Password = md5Pwd;
            ////保存到数据库
            //int count = userMapper.insert(user);
            _dbContext.Add(user);
            int count = _dbContext.SaveChanges();

            if (count != 1)
            {
                throw new Exception("用户注册失败");
            }
            ////把验证码从Redis中删除
            //redisTemplate.delete(key);
        }
        public ActionResult GetUserinfo(Userinfo ui)
        {
            ui.Uname = String.IsNullOrWhiteSpace(ui.Uname) ? "" : ui.Uname;
            var userinfolist = userinfoService.GetEntities(u => (u.Delflag == (int)DelflagEnum.Normal && u.Uname != null && u.Uname.Contains(ui.Uname) && u.Type == (int)TypeEnum.Administrator)).OrderBy(u => u.ID).Take(12);

            return(Json(userinfolist));
        }
示例#19
0
        public async Task <ActionResult> Create(StudentViewModel student, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                Student  std  = new Student();
                Userinfo user = new Userinfo();
                if (db.Userinfoes.Find(student.username) != null)
                {
                    ViewBag.userMsg   = "Username already exist.";
                    ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);

                    return(View(student));
                }
                else if (student.password == null)
                {
                    ViewBag.pswMsg    = "Password can not be null";
                    ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);

                    return(View(student));
                }
                else if (student.password != student.confirmPassword)
                {
                    ViewBag.pswMsg    = "Password are not same";
                    ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);

                    return(View(student));
                }
                user.username     = student.username;
                user.passwordHash = Cryptography.getMD5(student.password);
                user.token        = Cryptography.getMD5(student.username) + Cryptography.getMD5(student.password);
                user.role         = "student";
                user.email        = student.email;

                if (upload != null && upload.ContentLength > 0)
                {
                    string path = Path.Combine(Server.MapPath("~/Images"),
                                               Path.GetFileName(student.rollNo + ".jpg"));
                    upload.SaveAs(path);
                    user.imagePath = "~/Images/" + student.rollNo + ".jpg";
                }
                db.Userinfoes.Add(user);
                std.rollNo     = student.rollNo;
                std.fullName   = student.firstName;
                std.username   = student.username;
                std.gender     = student.gender;
                std.fatherName = student.fatherName;
                std.guardianID = student.guardianID;
                std.sessionID  = student.sessionID;
                db.Students.Add(std);

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);
                return(View(student));
            }
        }
示例#20
0
        public IQueryable Post([FromBody] Userinfo obj)
        {
            List <UserInformation> list = new List <UserInformation>();

            list.Add(AccountManager.returnUserInformation(obj.username, obj.passwordHash));
            return(list.AsQueryable());
        }
示例#21
0
        /// <summary>
        /// 添加到购物车
        /// </summary>
        /// <param name="productid"></param>
        /// <returns></returns>
        public ActionResult Add(int?productid)
        {
            Userinfo user = Session["user"] as Userinfo;

            if (user != null)
            {
                Cart cart = new Cart();

                cart.UserId  = user.Id;
                cart.GoodsId = productid;
                //添加到购物车前,要做判断,购物车是否已经存在该物品
                var cartList = db.Cart.Where(c => c.UserId == user.Id && c.GoodsId == productid);
                if (cartList.Count() == 1)
                {
                    //购物车中已经存在该物品
                    Cart nowcart = cartList.FirstOrDefault();
                    nowcart.Number++;
                }
                else
                {
                    //购物车中不存在该物品
                    cart.Number = 1;
                    db.Cart.Add(cart);
                }

                db.SaveChanges();
                return(RedirectToAction("List", "Cart"));
            }
            else
            {
                return(RedirectToAction("Login", "User"));
            }
        }
示例#22
0
        /// <summary>
        /// 购物车页面添加新地址
        /// </summary>
        /// <returns></returns>
        public ActionResult AddAddress(Address address)
        {
            Userinfo user = Session["user"] as Userinfo;

            if (user != null)
            {
                address.UserId = user.Id;

                if (address.Isdefault == true)
                {
                    //默认收货地址只能有1个,如果其他的默认收货地址,要把其他收货地址更改为非默认的
                    var oleaddresslist = db.Address.Where(a => a.UserId == user.Id && a.Isdefault == true).FirstOrDefault();

                    if (oleaddresslist != null)
                    {
                        oleaddresslist.Isdefault = false;
                        address.Isdefault        = true;
                    }
                }
                else
                {
                    address.Isdefault = false;
                }
                db.Address.Add(address);
                db.SaveChanges();



                return(RedirectToAction("List"));
            }
            else
            {
                return(RedirectToAction("Login", "User"));
            }
        }
示例#23
0
 /// <summary>
 /// 修改用户
 /// </summary>
 /// <param name="userinfo"></param>
 /// <returns></returns>
 public int UpdateUser(Userinfo userinfo)
 {
     try
     {
         userRep.GetDbSet.Where(x => x.U_no == userinfo.U_no).Update(x => new Userinfo()
         {
             U_username = userinfo.U_username,
             U_email    = userinfo.U_email,
             U_tel      = userinfo.U_tel,
             U_nick     = userinfo.U_nick,
             U_password = userinfo.U_password,
             UT_no      = userinfo.UT_no,
             RG_no      = userinfo.RG_no,
             U_ji       = userinfo.U_ji,
             U_name     = userinfo.U_name,
             U_sex      = userinfo.U_sex,
             U_birth    = userinfo.U_birth,
             C_no       = userinfo.C_no,
             U_address  = userinfo.U_address,
             U_about    = userinfo.U_about
         });
         return(1);
     }
     catch (Exception) {
         return(0);
     }
 }
        public async Task <IActionResult> Create([Bind("Id,Fname,Lname,Startweight,Currentweight,Desiredweight,Feet,Inches,Sex,Activitylevel,Lastloggedin,Birthday")] UserInfoInput userinfoinput)
        {
            byte     height   = (byte)((userinfoinput.Feet * 12) + userinfoinput.Inches);
            Userinfo userinfo = new Userinfo(userinfoinput.Id, userinfoinput.Fname, userinfoinput.Lname, userinfoinput.Startweight, userinfoinput.Startweight, userinfoinput.Desiredweight, height, userinfoinput.Sex, userinfoinput.Activitylevel, userinfoinput.Birthday);

            userinfo.Lastloggedin = DateTime.Now;
            if (ModelState.IsValid)
            {
                _context.Add(userinfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Profile)));
            }
            ViewBag.userID = userinfoinput.Id;
            return(View(userinfoinput));
            /*Replacing below code*/

            /*
             * if (ModelState.IsValid)
             * {
             *  _context.Add(userinfo);
             *  await _context.SaveChangesAsync();
             *  return RedirectToAction(nameof(Index));
             * }
             * ViewData["Id"] = new SelectList(_context.AspNetUsers, "Id", "Id", userinfo.Id);
             * return View(userinfo);
             */
        }
示例#25
0
        private void bttmoney_Click(object sender, EventArgs e)
        {
            //如果未检测到可用卡,则提示信息
            if (string.IsNullOrEmpty(txtxiaofeiID.Text))
            {
                MessageBox.Show("未检测到可用账户!");
                return;
            }
            else if (UserInfoManage.GetSelectUserinfoByID(txtxiaofeiID.Text) == null)
            {
                MessageBox.Show("此卡还未开通,请开卡或换卡!");
                return;
            }
            else if (string.IsNullOrEmpty(txtxiaofeiMoney.Text))
            {
                MessageBox.Show("请先输入充值金额!");
                return;
            }
            else if (int.Parse(this.txtxiaofeiMoney.Text) <= 0)
            {
                MessageBox.Show("请输入有效的充值金额!");
                return;
            }
            Userinfo userinfo = new Userinfo();

            userinfo.UsercardID = this.txtxiaofeiID.Text;
            userinfo.UserName   = this.txtxiaofeiName.Text;
            userinfo.UserMoney  = decimal.Parse(this.txtxiaofeiMoney.Text);
            if (UserInfoManage.UpdateUserinfo(userinfo))
            {
                MessageBox.Show("充值成功!");
            }
        }
        public ActionResult Edit(Userinfo userinfo)
        {
            //从缓存里面拿到userLoginId信息
            string   userLoginId = Request.Cookies["userLoginId"].Value.ToString();
            Userinfo userInfo    = CacheHelper.GetCache(userLoginId) as Userinfo;


            if (userinfoService.LoginExist(userInfo.ID, userinfo.Login))
            {
                return(View(userinfo));
            }

            userInfo.Login   = userinfo.Login;
            userInfo.Phone   = userinfo.Phone;
            userInfo.Address = userinfo.Address;
            userInfo.Other   = userinfo.Other;

            if (ModelState.IsValid)
            {
                userinfoService.Update(userInfo);
                //更新登陆缓存信息
                CacheHelper.SetCache(userLoginId, userInfo, DateTime.Now.AddMinutes(20));
                return(Json("ok"));
            }


            return(View(userInfo));
        }
示例#27
0
        public async Task <ActionResult> DeleteConfirmed(string id)
        {
            Student student = await db.Students.FindAsync(id);

            //var obj = db.Students.Include(a => a.Classes).SingleOrDefault(a => a.rollNo == id);
            var obj = student.Classes;

            if (obj != null)
            {
                foreach (var item in obj.ToList())
                {
                    obj.Remove(item);
                }
            }
            List <Attendance> list = db.Attendances.Where(a => a.rollNo == id).ToList <Attendance>();

            foreach (Attendance item in list)
            {
                db.Attendances.Remove(item);
            }
            Userinfo user = db.Userinfoes.Find(student.username);

            if (user != null)
            {
                db.Userinfoes.Remove(user);
            }
            db.Students.Remove(student);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
示例#28
0
        public bool CheckData(string data, int type)
        {
            Userinfo user = new Userinfo();

            //判断校验数据的类型
            switch (type)
            {
            case 1:
                user.Username = data;
                break;

            case 2:
                user.Phone = data;
                break;

            default:
                throw new Exception("参数不合法,校验未通过");
            }
            var list = _dbContext.Userinfos.AsQueryable();

            if (!string.IsNullOrWhiteSpace(user.Username))
            {
                list = list.Where(m => m.Username == user.Username);
            }
            if (!string.IsNullOrWhiteSpace(user.Phone))
            {
                list = list.Where(m => m.Username == user.Phone);
            }
            return(list.Count() == 0);
        }
示例#29
0
        //get token on successfull login
        internal static UserInformation returnUserInformation(string username, string password)
        {
            Userinfo        user = db.Userinfoes.Find(username);
            UserInformation obj  = new UserInformation();

            if (user != null)
            {
                if (user.passwordHash == password)
                {
                    obj.status = "OK";
                    obj.token  = user.token;
                    obj.role   = user.role;
                    if (obj.role == "admin" || obj.role == "teacher")
                    {
                        obj.name = db.Teachers.Where(o => o.username == user.username).First().name;
                    }
                    else
                    {
                        obj.name = db.Students.Where(o => o.username == user.username).First().fullName;
                    }
                }
                else
                {
                    obj.status = "wrong pw";
                }
            }
            else
            {
                obj.status = "wrong un";
            }
            return(obj);
        }
示例#30
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Userinfo DataRowToModel(DataRow row)
        {
            Userinfo model = new Userinfo();

            if (row != null)
            {
                if (row["UserId"] != null && row["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(row["UserId"].ToString());
                }
                if (row["UserName"] != null)
                {
                    model.UserName = row["UserName"].ToString();
                }
                if (row["UserPwd"] != null)
                {
                    model.UserPwd = row["UserPwd"].ToString();
                }
                if (row["Email"] != null)
                {
                    model.UserPwd = row["Email"].ToString();
                }
            }
            return(model);
        }
        public ActionResult Create(Userinfo userinfo)
        {
            if (ModelState.IsValid)
            {
                db.Userinfoes.Add(userinfo);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(userinfo);
        }
示例#32
0
    //获取当前域名
    //string url = HttpContext.Current.Request.Url.Host;
    // url+"/Images/..."
    //获取修改后的用户基本信息
    private Userinfo GetUserInfo()
    {
        Userinfo minfo = new Userinfo();
        string str ;
        try
        {
            minfo.countid = Convert.ToInt32(Request.Form["countid"]);

            minfo.icon = Request.Form["icon"];

            minfo.nickname = Request.Form["nickname"];

            minfo.industry = Request.Form["industry"];

            minfo.job = Request.Form["job"];

            minfo.school = Request.Form["school"];

            minfo.persign = Request.Form["persign"];

            minfo.borndate = Request.Form["borndate"];

            if (Request.Form["starid"]!=null&&Request.Form["starid"]!="")
            minfo.starid = Convert.ToByte(Request.Form["starid"]);

            if (Request.Form["btypeid"] != null || Request.Form["btypeid"] != "")
            minfo.btypeid = Convert.ToByte(Request.Form["btypeid"]);

            if (Request.Form["sex"] != null || Request.Form["sex"] != "")
            minfo.sex =Convert.ToByte(Request.Form["sex"]);

        }
        catch (Exception e)
        {

        }
        return minfo;
    }
 public ActionResult Edit(Userinfo userinfo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userinfo).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(userinfo);
 }