public async Task <IActionResult> AddRule(string packetType) { bool ret = PacketType.TryParse(packetType, true, out PacketType inputPacketType); if (ret != true) { return(BadRequest("packetType error.")); } AppRule rule = new AppRule() { PacketType = inputPacketType, }; db.AppRules.Add(rule); await db.SaveChangesAsync(); return(Ok(rule.Id)); }
public async Task <ActionResult <List <NameValuePair> > > GetField(string packetType) { bool ret = PacketType.TryParse(packetType, true, out PacketType inputPacketType); if (ret != true) { return(BadRequest("Can not get the request type.")); } var pairDict = PacketInfo.AllPacketInfos[inputPacketType].AvaliableFields.Select(s => new NameValuePair() { Name = s.ToString(), Value = (int)s }).ToList(); if (pairDict.Count == 0) { return(BadRequest("Can not get the request type.")); } return(pairDict); }