public UserModuleCommandInsert(IUserRepositoryReadOnly repository, ICommandInsertIdentity <User> commandInsert) { Post["/user"] = parameters => { var _userRequest = this.Bind <UserRequest>(); if (_userRequest.isValidPost()) { if (!repository.exists(_userRequest.Id)) { var _userRol = new Rol(_userRequest.userRol.name, _userRequest.userRol.description); _userRol.Id = _userRequest.userRol.idGuid; var user = new User(_userRequest.Id, _userRequest.firstName, _userRequest.secondName, _userRequest.password, _userRequest.mail, _userRol); var auditoriaRequest = _userRequest.auditoriaRequest; user.Auditoria = new Auditoria(auditoriaRequest.usuarioCreo, auditoriaRequest.fechaCreo, auditoriaRequest.usuarioModifico, auditoriaRequest.fechaModifico); commandInsert.execute(user); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.NotAcceptable)); }; }
public GremioModuleInsert(ICommandInsertIdentity <Gremio> commandInsert) { _gremioMap = new GremioMap(); Post["enterprise/gremio"] = paramaters => { var request = this.Bind <GremioRequest>(); try { if (request.isValidPost()) { var gremio = _gremioMap.getGremioForPost(request); if (commandInsert.isExecutable(gremio)) { commandInsert.execute(gremio); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } } catch (ArgumentException e) { return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public VisitaModuleInsert(ICommandInsertIdentity <Visita> command) { _visitaMapping = new VisitaMapping(); Post["/visita"] = parameters => { var visitaRequest = this.Bind <VisitaRequest>(); if (visitaRequest.isValidPost()) { var visita = _visitaMapping.getVisita(visitaRequest); command.execute(visita); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public EmpleoModuleInsert(ICommandInsertIdentity <Empleo> command, IFileGetter fileGetter) { _fileGetter = fileGetter; _empleoMapping = new EmpleoMapping(); Post["/enterprise/empleos"] = parameters => { var request = this.Bind <EmpleoRequest>(); if (request.isValidPost()) { if (contratoNotEmpty(request)) { var contrato = request.contrato; if (!_fileGetter.existsFile(DirectorioArchivosContratos, contrato, Extension)) { return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); } request.contentFile = fileGetter.getFile(@"/EmpleoContratos", contrato, ".pdf"); } if (someFileVoucherNotEmpty(request)) { if (!existsFilesVoucher(request)) { return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); } setFileContentRequest(request); } var empleo = _empleoMapping.getEmpleoForPost(request); if (command.isExecutable(empleo)) { command.execute(empleo); deleteFiles(request); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public ParentescoModuleInsert(ICommandInsertIdentity <Parentesco> command) { _parentescoMapping = new ParentescoMapping(); Post["/enterprise/beneficiarios/parentescos"] = parameters => { var request = this.Bind <ParentescoRequest>(); if (request.isValidPost()) { var motivoDespido = _parentescoMapping.getParentescoForPost(request); command.execute(motivoDespido); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public MotivoDespidoModuleInsert(ICommandInsertIdentity <MotivoDespido> command) { _motivoDespidoMapping = new MotivoDespidoMapping(); Post["/enterprise/motivoDespido"] = parameters => { var request = this.Bind <MotivoDespidoRequest>(); if (request.isValidPost()) { var motivoDespido = _motivoDespidoMapping.getMotivoDespidoForPost(request); command.execute(motivoDespido); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public TipoEmpleoModuleInsert(ICommandInsertIdentity <TipoEmpleo> command) { _tipoEmpleoMapping = new TipoEmpleoMapping(); Post["/enterprise/tipoEmpleo"] = parameters => { var request = this.Bind <TipoEmpleoRequest>(); if (request.isValidPost()) { var tipoEmpleo = _tipoEmpleoMapping.getTipoEmpleoForPost(request); command.execute(tipoEmpleo); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public ActividadEconomicaModuleInsert(ICommandInsertIdentity <ActividadEconomica> command) { _actividadEconomicaMapping = new ActividadEconomicaMapping(); Post["/enterprise/actividades"] = parameters => { var request = this.Bind <ActividadEconomicaRequest>(); if (request.isValidPost()) { var actividad = _actividadEconomicaMapping.getActividadEconomicaForPost(request); command.execute(actividad); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public BeneficiarioModuleInsert(ICommandInsertIdentity <Beneficiario> command) { Post["/enterprise/beneficiarios"] = parameters => { var request = this.Bind <BeneficiarioRequest>(); if (request.isValidPost()) { var beneficiarioMap = new BeneficiarioMap(); var beneficiario = beneficiarioMap.getBeneficiario(request); if (command.isExecutable(beneficiario)) { command.execute(beneficiario); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public EmpresaModuleInsert(ICommandInsertIdentity <Empresa> _commandInsert, IFileGetter fileGetter) { Post["enterprise/"] = parameters => { var request = this.Bind <EmpresaRequest>(); if (request.isValidPost()) { var empresaMap = new EmpresaMap(); var file = request.contentFile; var empresa = empresaMap.getEmpresa(request); if (_commandInsert.isExecutable(empresa)) { if (!string.IsNullOrEmpty(file)) { if (!fileGetter.existsFile(@"/EmpresasContratos", file, ".pdf")) { return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); } var fileContrato = fileGetter.getFile(@"/EmpresasContratos", file, ".pdf"); empresa.Contrato = new ContentFile(fileContrato); } _commandInsert.execute(empresa); fileGetter.deleteFile(@"/EmpresasContratos", file, ".pdf"); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public RolModuleCommandInsert(ICommandInsertIdentity <Rol> command) { Post["/rol"] = parameters => { var _rolRequest = this.Bind <RolRequest>(); if (string.IsNullOrEmpty(_rolRequest.name) || string.IsNullOrEmpty(_rolRequest.description)) { return new Response() { } } .WithStatusCode(HttpStatusCode.BadRequest); var _rol = new Rol(_rolRequest.name, _rolRequest.description); var auditoriaRequest = _rolRequest.auditoriaRequest; _rol.Auditoria = new Auditoria(auditoriaRequest.usuarioCreo, auditoriaRequest.fechaCreo, auditoriaRequest.usuarioModifico, auditoriaRequest.fechaModifico); _rol.Nivel = _rolRequest.nivel; command.execute(_rol); return(new Response() { } .WithStatusCode(HttpStatusCode.OK)); };