public IHttpActionResult Login([FromBody]LoginModel model) { var message = string.Empty; var member = new Zs_Member(); var identity = new ClaimsIdentity(); var dicError = new { result = "", message = "" }; var dicSucess = new { result = "", message = new Zs_Member() }; member = bMember.MemberLogin(model.Account); if (member == null) { message = string.Format("账号 {0} 不存在", model.Account); dicError = new { result = "0", message = message }; return Ok(dicError); } else if (!member.DelStatus) { message = string.Format("账号 {0} 已删除", model.Account); dicError = new { result = "0", message = message }; return Ok(dicError); } else if (member.Pwd != StringUtil.EncodeString(model.Password, StringUtil.GetPwdKey(member.MChar.ToString()))) { message = string.Format("密码输入错误"); dicError = new { result = "0", message = message }; return Ok(dicError); } //identity = bMember.CreateIdentity(member, DefaultAuthenticationTypes.ApplicationCookie); //AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); //AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = true }, identity); dicSucess = new { result = "1", message = member }; return Ok(dicSucess); }
public IHttpActionResult LoginByQQ([FromBody]LoginByQQModel model) { var message = string.Empty; var member = new Zs_Member(); var identity = new ClaimsIdentity(); if (bMember.Exist(f => f.QQOpenID == model.QQOpenID)) { member = bMember.Find(f => f.QQOpenID == model.QQOpenID); return Ok(member); } member.MChar = StringUtil.GetGUID(); member.QQOpenID = model.QQOpenID; member.NickName = model.NickName; member.MStatus = 1; member = bMember.Add(member); if (member.MID > 0) { return Ok(member); } else { message = "注册失败"; return Ok(message); } }
public IHttpActionResult GetMemberInfo([FromUri]string para, int type) { var member = new Zs_Member(); var dic = new Dictionary<string, string>(); switch (type) { case 1: member = bMember.Find(f => f.MCode == para); break; case 2: member = bMember.Find(f => f.NickName == para); break; } if (member == null) { dic.Add("result", "没有搜索到用户"); return Ok(dic); } return Ok(member); }
public async Task<IHttpActionResult> UpdateMember() { long id = 0; var updateResult = false; var member = new Zs_Member(); var hashTable = new Hashtable(); var formData = new Dictionary<string, string>(); var fileData = new List<FileDataInfo>(); var dicError = new { result = "", message = "" }; var dicSucess = new { result = "", message = new Zs_Member() }; //获取表单数据 hashTable = await sysFun.GetFormData(Request); formData = hashTable["FormData"] as Dictionary<string, string>; fileData = hashTable["FileData"] as List<FileDataInfo>; //初始化实体 if (formData.ContainsKey("MID")) id = long.Parse(formData["MID"]); member = bMember.Find(id); member = sysFun.InitialEntity<Zs_Member>(member, formData); member.UpdateDate = DateTime.Now; if (fileData.Count != 0) { member.IconUrl = fileData[0].AttUrl; sysFun.DeleteFile(fileData[0].AttType, fileData[0].AttUrl); } updateResult = bMember.Update(member); //更新会员信息 if (!updateResult) { dicError = new { result = "0", message = "更新失败" }; return Ok(dicError); } dicSucess = new { result = "1", message = member }; return Ok(dicSucess); }
public IHttpActionResult RegisterByEmail([FromBody]RegisterEmailModel model) { var message = string.Empty; var member = new Zs_Member(); var identity = new ClaimsIdentity(); if (!ModelState.IsValid) return BadRequest(ModelState); if (bMember.Exist(f => f.Mobile == model.Email)) { message = string.Format("邮箱 {0} 已注册", model.Email); return BadRequest(message); } member.Mobile = model.Email; member.Pwd = model.Password; member.NickName = model.UserName; member.MStatus = 1; member.CreateDate = DateTime.Now; member = bMember.Add(member); if (member.MID > 0) { identity = bMember.CreateIdentity(member, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignIn(identity); } else { message = "注册失败"; return BadRequest(message); } return Ok(member); }
public IHttpActionResult RegisterByMobile([FromBody]RegisterMobileModel model) { var message = string.Empty; var member = new Zs_Member(); var identity = new ClaimsIdentity(); var dicError = new { result = "", message = "" }; var dicSucess = new { result = "", message = new Zs_Member() }; if (bMember.Exist(f => f.Mobile == model.Mobile)) { message = string.Format("手机号 {0} 已注册", model.Mobile); dicError = new { result = "0", message = message }; return Ok(dicError); } member.MChar = StringUtil.GetGUID(); member.MCode = model.Mobile; member.NickName = model.NickName; member.Pwd = StringUtil.EncodeString(model.Pwd, StringUtil.GetPwdKey(member.MChar.ToString())); member.Mobile = model.Mobile; member = bMember.Add(member); if (member.MID > 0) { //identity = bMember.CreateIdentity(member, DefaultAuthenticationTypes.ApplicationCookie); //AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); //AuthenticationManager.SignIn(identity); dicSucess = new { result = "1", message = member }; return Ok(dicSucess); } else { dicError = new { result = "0", message = "注册失败" }; return Ok(dicError); } }
public string Create(MemberCreate model) { string msg; if (ModelState.IsValid) { Zs_Member item = new Zs_Member(); item = sysFun.InitialEntity<MemberCreate, Zs_Member>(model, item); item.MChar = StringUtil.GetGUID(); item.Pwd = StringUtil.EncodeString(model.Pwd, StringUtil.GetPwdKey(item.MChar.ToString())); bMember.Add(item); msg = "添加成功"; } else { msg = "Validation data not successfull"; } return msg; }