public static string Edit(HttpContext context) { if (string.IsNullOrEmpty(App.UserID)) throw new AuthenticationException("用户未登录"); string id = context.Request.Form["_id"].ToStringExt(); if (string.IsNullOrEmpty(id)) throw new ArgumentNullException("id", "缺少参数_id"); string name = context.Request.Form["name"]; string sex = context.Request.Form["sex"]; string birthday = context.Request.Form["birthday"]; string email = context.Request.Form["email"]; Where @where = new Where(new Where.Item("ID", "=", id)); FreedomDB.Bridge.Update update = new Update(); update.Dic = new Dictionary<string, dynamic>() { {"Email", email}, {"Birthday", birthday.StrToDateTime(DateTime.MaxValue)}, {"Name", name}, {"Sex", sex.ToInt(0)} }; update.WhereCore = where; bool success = Bll.User_Bll.UpdateUser(update); ApiInfo apiInfo = new ApiInfo(SystemCode.Error, "更新失败"); if (success) { apiInfo = new ApiInfo(SystemCode.Success, "更新成功"); } return apiInfo.ToJson(); }
public static string Delete(HttpContext context) { if (string.IsNullOrEmpty(App.UserID)) throw new AuthenticationException("用户未登录"); int uid = context.Request.GetValExt("uid").ToInt(); if (uid < 1) throw new ArgumentNullException("uid", "用户ID不能为空"); Where where=new Where(); where.Add(new Where.Item("ID", "=", uid)); bool success = Bll.User_Bll.DeleteUser(where); ApiInfo apiInfo = new ApiInfo(SystemCode.Error, "删除失败"); if (success) { apiInfo = new ApiInfo(SystemCode.Success, "删除成功"); } return apiInfo.ToJson(); }