public ActionResult AddUserAddress(string address, string name) { var ua = new user_address(); ua.address = address; ua.user_id = UserInfo.id; ua.name = name ?? UserInfo.nickname; ua.add_time = DateTime.Now; ua.del_flag = (int)Del_flag.正常; ua.state = (int)State.可用; var res = User_addressService.AddEntity(ua); if (res.id > 0) { return(Json(SysEnum.成功, "添加地址成功")); } return(Json(SysEnum.失败, "添加地址失败")); }
private int SaveAddress(string address, wx_user userInfo) { int id; var item = User_addressService.LoadEntities(n => n.address.Equals(address)).FirstOrDefault(); if (item != null) { id = item.id; } else { var ad = new user_address(); ad.del_flag = (int)Del_flag.正常; ad.state = (int)State.可用; ad.address = address; ad.user_id = userInfo.id; ad.name = userInfo.nickname; ad.add_time = DateTime.Now; var res = User_addressService.AddEntity(ad); id = res.id; } return(id); }