public SupervisorLugaresVisitaModuleQuery(ISerializeJsonRequest serializerJson, Func <string, IEncrytRequestProvider> encryptRequestProvider, ITokenizer tokenizer, IVisitaRepositoryReadOnly repository) { Post["/movil/supervisor/lugaresVisita/"] = _ => { var movilRequest = this.Bind <MovilRequest>(); var userId = tokenizer.Detokenize(movilRequest.token, Context); if (userId == null) { return(new Response().WithStatusCode(HttpStatusCode.Unauthorized)); } var actualUser = userId.UserName; var user = new User(actualUser, "", "", "", "", new RolNull()); var supervisor = repository.getAgendaSupervisor(user); if (supervisor == null) { return(new Response().WithStatusCode(HttpStatusCode.NotFound)); } var agenda = getSupervisorRequest(supervisor); var agendaString = serializerJson.toJson(agenda); var respuestaEncryptada = encryptRequestProvider(movilRequest.token).encryptString(agendaString); return(respuestaEncryptada); }; }
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)); }; }
public AuthModule(IUserManagementApiClient client, ITokenizer tokenizer) { Get["/login"] = parameters => { return View["Index"]; }; Get["/logout"] = parameters => { return this.Logout("/"); }; Post["/login"] = parameters => { var model = this.Bind<AuthModel>(); var token = client.Post("", "/login", null, null, new[] { new KeyValuePair<string, string>("Username", model.Username), new KeyValuePair<string, string>("Password", model.Password) }); var userIdentity = tokenizer.Detokenize(token, Context, new DefaultUserIdentityResolver()); Context.CurrentUser = userIdentity; return token; }; Get["/forgotPassword/{username}"] = _ => { ViewBag.Message = client.Put("", UserManagementApiRoute.User.RequestResetPassword, new[] { new KeyValuePair<string, string>("username", _.username + "") }, null, null); return View["Login"]; }; }
public NotaDespidoModuleInsert(ISerializeJsonRequest serializerJson, Func <string, IEncrytRequestProvider> encryptRequestProvider, ITokenizer tokenizer, ICommandInsertNotaDespido command, IFileGetter fileGetter) { Post["/movil/notaDespido"] = parameters => { var movilRequest = this.Bind <MovilRequest>(); var userId = tokenizer.Detokenize(movilRequest.token, Context); if (userId == null) { return(new Response().WithStatusCode(HttpStatusCode.Unauthorized)); } string notaDespidoString; NotaDespidoRequest notaDespidoRequest; try { var desencrypter = encryptRequestProvider(movilRequest.token); notaDespidoString = desencrypter.decryptString(movilRequest.data); notaDespidoRequest = serializerJson.fromJson <NotaDespidoRequest>(notaDespidoString); } catch (Exception e) { return(new Response().WithStatusCode(HttpStatusCode.BadRequest)); } if (notaDespidoRequest.isValidPost()) { var archivoNotaDespido = notaDespidoRequest.imagenNotaDespido.ToString(); if (fileGetter.existsFile(directorioImagenes, archivoNotaDespido, extensionImagenes)) { var notaDespido = getNotaDespido(notaDespidoRequest); if (command.isExecutable(notaDespidoRequest.empleoId, notaDespido)) { var dataImage = fileGetter.getFile(directorioImagenes, archivoNotaDespido, extensionImagenes); var imageFile = new ContentFile(dataImage); notaDespido.DocumentoDespido = imageFile; command.execute(notaDespidoRequest.empleoId, notaDespido); fileGetter.deleteFile(directorioImagenes, archivoNotaDespido, extensionImagenes); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public FichaEmpleoSupervisionModuleInsert(ISerializeJsonRequest serializerJson, Func <string, IEncrytRequestProvider> encryptRequestProvider, ITokenizer tokenizer, ICommandInsertFichaDeSupervision command, IFileGetter fileGetter) { Post["/movil/fichaSupervision/"] = parameters => { var movilRequest = this.Bind <MovilRequest>(); var userId = tokenizer.Detokenize(movilRequest.token, Context); if (userId == null) { return(new Response().WithStatusCode(HttpStatusCode.Unauthorized)); } string fichaString; FichaSupervisionEmpleoRequest fichaRequest; try { var desencrypter = encryptRequestProvider(movilRequest.token); fichaString = desencrypter.decryptString(movilRequest.data); fichaRequest = serializerJson.fromJson <FichaSupervisionEmpleoRequest>(fichaString); } catch (Exception e) { return(new Response().WithStatusCode(HttpStatusCode.BadRequest)); } if (fichaRequest.isValidPost()) { var archivoImagen = fichaRequest.fotografiaBeneficiario.ToString(); if (fileGetter.existsFile(directorioImagenes, archivoImagen, extensionImagenes)) { var dataImage = fileGetter.getFile(directorioImagenes, archivoImagen, extensionImagenes); var imageFile = new ContentFile(dataImage); var beneficiario = new BeneficiarioMap().getBeneficiario(fichaRequest.beneficiarioRequest); var ficha = getFichaSupervisionEmpleo(fichaRequest, imageFile); if (command.isExecutable(ficha, beneficiario, fichaRequest.empleoId)) { beneficiario.FotografiaBeneficiario = imageFile; command.execute(ficha, beneficiario, fichaRequest.empleoId); fileGetter.deleteFile(directorioImagenes, archivoImagen, extensionImagenes); return(new Response().WithStatusCode(HttpStatusCode.OK)); } } } return(new Response().WithStatusCode(HttpStatusCode.BadRequest)); }; }
public MotivoDespidoModuleQueryMovil(ISerializeJsonRequest serializerJson, Func <string, IEncrytRequestProvider> encryptRequestProvider, ITokenizer tokenizer, IMotivoDespidoRepositoryReadOnly readOnlyRepository) { Post["/movil/motivosDespido"] = parameters => { var movilRequest = this.Bind <MovilRequest>(); var userId = tokenizer.Detokenize(movilRequest.token, Context); if (userId == null) { return(new Response().WithStatusCode(HttpStatusCode.Unauthorized)); } var motivos = readOnlyRepository.getAll(); var motivosString = serializerJson.toJson(motivos); var respuestaEncryptada = encryptRequestProvider(movilRequest.token).encryptString(motivosString); return(respuestaEncryptada); }; }
public ImagesPostMovilModule(ITokenizer tokenizer, IFilePersister filePersister) { Post["/movil/imagenes"] = 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 file = Request.Files.FirstOrDefault(); return(FileProcessor(filePersister, file, @"/ImagenesMoviles", ".jpeg")); }; }
public EmpleoModuleQueryMovil(ISerializeJsonRequest serializerJson, Func <string, IEncrytRequestProvider> encryptRequestProvider, ITokenizer tokenizer, IEmpleoRepositoryReadOnly repositoryRead) { Post["/movil/empleo/id={identidad}/rtn={rtn}/sucursal={sucursal}"] = 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 identidadFromClient = parameters.identidad; var identidadRequest = new IdentidadRequest() { identidad = identidadFromClient }; if (identidadRequest.isValidPost()) { string rtnFromClient = parameters.rtn; var rtnRequest = new RTNRequest() { RTN = rtnFromClient }; if (rtnRequest.isValidPost()) { Guid idSucursal; if (Guid.TryParse(parameters.sucursal, out idSucursal)) { if (idSucursal != Guid.Empty) { var identidad = new Identidad(identidadRequest.identidad); var empleo = repositoryRead.getEmpleoMasRecienteBeneficiario(identidad); if (empleo.Empresa.Id.Rtn == rtnRequest.RTN) { if (empleo.Sucursal.Id == idSucursal) { var fichaEmpleo = getEmpleoRequest(empleo); var fichaEmpleoString = serializerJson.toJson(fichaEmpleo); var respestaEncriptada = encryptRequestProvider(token).encryptString(fichaEmpleoString); return(respestaEncriptada); } } } } } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }