Example #1
0
        public object Put(string id, [FromBody] UpdateHotelPwdModel model)
        {
            var res = hostelContext.Accouts.FirstOrDefault(d => d.GUID == id);

            if (res == null)
            {
                return(new { state = false, message = "没有找到该账户信息" });
            }
            var oldPwd = DESHelper.MD5Decrypt(res.Pwd, DESHelper.GetKey());

            if (oldPwd != model.oldPassword)
            {
                return(new { state = false, message = "原密码不正确" });
            }
            try
            {
                var newPassword = DESHelper.MD5Encrypt(model.newPassword, DESHelper.GetKey());
                res.Pwd = newPassword;
                hostelContext.Messages.Add(new HostelModel.MessageModel()
                {
                    Context = "用户通过APP修改密码",
                    From    = "System",
                    To      = id,
                    Type    = "系统消息"
                });
                hostelContext.SaveChanges();
                return(new { state = true, message = "密码修改成功" });
            }
            catch (Exception)
            {
                return(new { state = false, message = "系统错误,请稍后重试" });
            }
        }
Example #2
0
        public object Post([FromBody] LoginHotelModel login)
        {
            var pwd   = DESHelper.MD5Encrypt(login.password, DESHelper.GetKey());
            var model = hostelContext.Accouts.FirstOrDefault(d => d.LoginName == login.username && d.Pwd == pwd);

            if (model == null)
            {
                return(new { state = false, message = "账号密码错误!" });
            }
            try
            {
                var hotelModel = hostelContext.Hotels.Include(d => d.Area).FirstOrDefault(d => d.Id == model.HotelId);
                return(new { state = true, message = "登录成功", token = Guid.NewGuid().ToString("N"), data = hotelModel, AccoutGUID = model.GUID });
            }
            catch (Exception)
            {
                return(new { state = false, message = "系统错误,未找到该账户管理的酒店信息,请联系管理员处理" });
            }
        }
Example #3
0
        public ActionResult md5(string txtkey)
        {
            ViewBag.txt    = txtkey;
            ViewBag.md5_16 = MD5Helper.MD5_16(txtkey);
            ViewBag.md5_32 = MD5Helper.MD5_32(txtkey);

            string des = DESHelper.DESEncrypt(txtkey, DESHelper.GetKey());

            ViewBag.des_E = des;
            ViewBag.des_D = DESHelper.DESDecrypt(des, DESHelper.GetKey());

            //LoginLog one = new LoginLog();
            //one.belong_to_company = "ecobio";
            //one.login_time = DateTime.Now;
            //one.login_user_alias = txtkey;
            //string xml = XmlSerializerHelper.SaveXmlFromObj<LoginLog>(one);


            string mdc = Image64Base.GetImageStr("d:\\a.jpg");

            ViewBag.xml = mdc;
            return(View());
        }