Beispiel #1
0
        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));
            };
        }
Beispiel #2
0
        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));
            };
        }
Beispiel #3
0
        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));
            };
        }
Beispiel #4
0
        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));
            };
        }