Ejemplo n.º 1
0
        public PersonRNPMovilModule(ISerializeJsonRequest serializerJson, Func <string, IEncrytRequestProvider> encryptRequestProvider,
                                    ITokenizer tokenizer, IPersonRNPRepositoryReadOnly repository)
        {
            Post["/movil/enterprise/Person/id={id}"] = parameters =>
            {
                var movilRequest = this.Bind <MovilRequest>();
                try
                {
                    var userId = tokenizer.Detokenize(movilRequest.token, Context);
                    if (userId == null)
                    {
                        return(new Response().WithStatusCode(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    return(new Response().WithStatusCode(HttpStatusCode.Unauthorized));
                }

                var token = movilRequest.token;

                string id = parameters.id;
                if (!string.IsNullOrEmpty(id))
                {
                    var result             = repository.get(id);
                    var personaString      = serializerJson.toJson(result);
                    var respestaEncriptada = encryptRequestProvider(token).encryptString(personaString);

                    return(respestaEncriptada);
                }
                return(new Response()
                       .WithStatusCode(HttpStatusCode.BadRequest));
            };
        }
Ejemplo n.º 2
0
 public PersonRNPModule(IPersonRNPRepositoryReadOnly repository)
 {
     Get["/enterprise/Person/id={id}"] = parameters =>
     {
         string id = parameters.id;
         if (!string.IsNullOrEmpty(id))
         {
             var result = repository.get(id);
             return(Response.AsJson(result)
                    .WithStatusCode(HttpStatusCode.OK));
         }
         return(new Response()
                .WithStatusCode(HttpStatusCode.BadRequest));
     };
 }