예제 #1
0
        public override Task <Empty> UpdatePrisoner(PrisonerMessage request, ServerCallContext context)
        {
            Prisoner p = ConversionStuff.MessageToPrisoner(request);

            if (!ValidationUtility.IsPrisonerValid(p))
            {
                return(Task.FromResult(new Empty()));
            }
            unitOfWork.PrisonerRepo.Update(p);
            unitOfWork.Save();
            return(Task.FromResult(new Empty()));
        }
예제 #2
0
 public static Prisoner MessageToPrisoner(PrisonerMessage pm)
 {
     return(new Prisoner
     {
         PrisonerID = pm.Id,
         FName = pm.Fname,
         LName = pm.Lname,
         Age = pm.Age,
         LocationID = pm.LocationId,
         SentenceDate = new DateTime(pm.SentenceDate),
         ReleaseDate = new DateTime(pm.ReleaseDate)
     });
 }
예제 #3
0
 public async Task AddPrisoner(PrisonerMessage prisonerMessage)
 {
     if (client == null || token == "")
     {
         Debug.WriteLine("Null client or token");
         return;
     }
     try
     {
         await client.AddPrisonerAsync(prisonerMessage, headers);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }