Beispiel #1
0
        public override Task <PrisonerArrayMessage> GetPrisonersByName(SearchParamMessage request, ServerCallContext context)
        {
            PrisonerArrayMessage   pam    = new PrisonerArrayMessage();
            List <Prisoner>        pList  = unitOfWork.PrisonerRepo.Get(p => p.LName.ToLower().Contains(request.Value.ToLower()), null, "").ToList();
            List <PrisonerMessage> pmList = new List <PrisonerMessage>();

            foreach (Prisoner p in pList)
            {
                pmList.Add(ConversionStuff.PrisonerToMessage(p));
            }
            pam.Prisoners.AddRange(pmList);
            return(Task.FromResult(pam));
        }
Beispiel #2
0
        public override Task <PrisonerArrayMessage> GetAllPrisoners(Empty e, ServerCallContext callContext)
        {
            PrisonerArrayMessage   pam    = new PrisonerArrayMessage();
            List <Prisoner>        pList  = unitOfWork.PrisonerRepo.Get(p => true, null, "Location").ToList();
            List <PrisonerMessage> pmList = new List <PrisonerMessage>();

            foreach (Prisoner p in pList)
            {
                Console.WriteLine(p.Location.Name);
                pmList.Add(ConversionStuff.PrisonerToMessage(p));
            }
            pam.Prisoners.AddRange(pmList);
            return(Task.FromResult(pam));
        }
Beispiel #3
0
        public async Task <PrisonerArrayMessage> GetPrisonersByName(SearchParamMessage para)
        {
            if (client == null || token == "")
            {
                Debug.WriteLine("Null client or token");
                return(null);
            }

            PrisonerArrayMessage reply = null;

            try
            {
                reply = await client.GetPrisonersByNameAsync(para, headers);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            return(reply);
        }
Beispiel #4
0
        public async Task <PrisonerArrayMessage> GetAllPrisoners()
        {
            if (client == null || token == "")
            {
                Debug.WriteLine("Null client or token");
                return(null);
            }

            PrisonerArrayMessage reply = null;

            try
            {
                reply = await client.GetAllPrisonersAsync(new Google.Protobuf.WellKnownTypes.Empty(), headers);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            return(reply);
        }