Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }