private RegisterParams GetParams() { RegisterParams param = new RegisterParams(); param.name = Request.Form["name"]; param.sex = Request.Form["sex"]; return param; }
public string Register(RegisterParams mparams) { string jsonstr = ""; var model = new Model.hp_minfo(); var countModel = new Model.hp_mcount(); try { model =new Model.hp_minfo(); model.name=mparams.name; model.sex=Convert.ToBoolean(mparams.sex); entity.hp_minfo.Add(model); entity.SaveChanges(); countModel = new Model.hp_mcount(); countModel.pwd = AdminCountManager.UseMD5("123456"); countModel.icon = "icon.png"; countModel.nickname = "nickname"; countModel.infoid = model.id; countModel.persign = "个人签名"; countModel.positionid = 3; entity.hp_mcount.Add(countModel); entity.SaveChanges(); jsonstr = ReturnJson.toJson("100", "成功", countModel.id); } catch (Exception e) { try { entity.hp_minfo.Remove(model); entity.hp_mcount.Remove(countModel); jsonstr = ReturnJson.toJson("101", "失败(1)", -1); } catch (Exception e1) { jsonstr = ReturnJson.toJson("101", "失败(2)", -1); } } return jsonstr; }