public void HandleRequest(IRequest request)
        {
            var corporationEids = request.Data.GetOrDefault <long[]>(k.eid);
            var result          = CorporationData.GetAnyInfoDictionary(corporationEids);

            Message.Builder.FromRequest(request).WithData(result).Send();
        }
Exemplo n.º 2
0
        public void HandleRequest(IRequest request)
        {
            var pattern = request.Data.GetOrDefault <string>(k.name);

            if (pattern.Equals(string.Empty) || pattern.Length < 2)
            {
                throw new PerpetuumException(ErrorCodes.SearchStringTooShort);
            }

            pattern = $"%{pattern}%";

            var corporationEids = Db.Query().CommandText("select top (32) eid from corporations where ([name] like @pattern or nick like @pattern) and defaultcorp=0")
                                  .SetParameter("@pattern", pattern)
                                  .Execute()
                                  .Select(r => DataRecordExtensions.GetValue <long>(r, 0))
                                  .ToArray();

            if (corporationEids.Any())
            {
                var result = CorporationData.GetAnyInfoDictionary(corporationEids);
                Message.Builder.FromRequest(request).WithData(result).WrapToResult().Send();
            }
            else
            {
                Message.Builder.FromRequest(request).WithEmpty().Send();
            }
        }