private static void BuildIPBlock(ref Utf8JsonReader reader, ref RouteDetail routeDetail) { var ipBlock = new IPBlock(); while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { break; } if (reader.TokenType != JsonTokenType.PropertyName) { continue; } var index = reader.ValueSpan[0]; reader.Read(); switch (index) { case (byte)'t': ipBlock.Type = reader.GetString(); break; case (byte)'s': ipBlock.Size = reader.GetString(); break; } } routeDetail.IPBlock = ipBlock; }
public string BlockIP(int id = 0, string reason = "") { string error = ""; try { user u = Users.GetUser(Convert.ToInt32(Session["userID"])); CurtDevDataContext db = new CurtDevDataContext(); ForumPost p = db.ForumPosts.Where(x => x.postID == id).First<ForumPost>(); p.active = false; p.flag = true; p.approved = false; IPBlock ipb = new IPBlock { IPAddress = p.IPAddress, createdDate = DateTime.Now, reason = reason, userID = u.userID }; db.IPBlocks.InsertOnSubmit(ipb); db.SubmitChanges(); } catch (Exception e) { error = e.Message; } return error; }