public UserModuleCommandUpdate(IUserRepositoryReadOnly repository, ICommandUpdateIdentity <User> commandUpdate) { Put["/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); user.Auditoria = new Auditoria(_userRequest.auditoriaRequest.usuarioCreo, _userRequest.auditoriaRequest.fechaCreo, _userRequest.auditoriaRequest.usuarioModifico, _userRequest.auditoriaRequest.fechaModifico); commandUpdate.execute(user); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.NotAcceptable)); }; }
public EmpleoModuleUpdate(ICommandUpdateIdentity <Empleo> commandUpdate, IFileGetter fileGetter) { _fileGetter = fileGetter; _empleoMapping = new EmpleoMapping(); Put["/enterprise/empleos"] = parameters => { var request = this.Bind <EmpleoRequest>(); if (request.isValidPut()) { /* if (request.updateContrato) * { * var contrato = request.contrato; * if (!_fileGetter.existsFile(DirectorioArchivosContratos, contrato, Extension)) * { * return new Response() * .WithStatusCode(HttpStatusCode.BadRequest); * } * request.contentFile = fileGetter.getFile(DirectorioArchivosContratos, contrato, Extension); * * } * else * { * var contrato = request.contrato; * Guid idContrato; * if (!Guid.TryParse(contrato, out idContrato)&&!string.IsNullOrEmpty(contrato)) * { * return new Response() * .WithStatusCode(HttpStatusCode.BadRequest); * } * * }*/ var empleo = _empleoMapping.getEmpleoForPut(request); if (commandUpdate.isExecutable(empleo)) { commandUpdate.execute(empleo); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public ActividadEconomicaModuleUpdate(ICommandUpdateIdentity <ActividadEconomica> command) { Put["enterprise/actividades"] = parameters => { var request = this.Bind <ActividadEconomicaRequest>(); if (request.isValidPut()) { var actividadMap = new ActividadEconomicaMapping(); var actividad = actividadMap.getActividadEconomicaForPut(request); if (command.isExecutable(actividad)) { command.execute(actividad); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public EmpresaModuleUpdate(ICommandUpdateIdentity <Empresa> _commandUpdate, IFileGetter fileGetter) { Put["enterprise/"] = parameters => { var request = this.Bind <EmpresaRequest>(); if (request.isValidPost()) { var empresaMap = new EmpresaMap(); var empresa = empresaMap.getEmpresa(request); if (_commandUpdate.isExecutable(empresa)) { _commandUpdate.execute(empresa); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public VisitaModuleUpdate(ICommandUpdateIdentity <Visita> commandUpdate) { Put["/visita"] = parameters => { var visitaRequest = this.Bind <VisitaRequest>(); if (visitaRequest.isValidPut()) { var visitaMapping = new VisitaMapping(); var visita = visitaMapping.getVisitaForPut(visitaRequest); if (commandUpdate.isExecutable(visita)) { commandUpdate.execute(visita); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public TipoEmpleoModuleUpdate(ICommandUpdateIdentity <TipoEmpleo> command) { Put["/enterprise/tipoEmpleo"] = parameters => { var request = this.Bind <TipoEmpleoRequest>(); if (request.isValidPut()) { var mapTipoEmpleo = new TipoEmpleoMapping(); var tipoEmpleo = mapTipoEmpleo.getTipoEmpleoForPut(request); if (command.isExecutable(tipoEmpleo)) { command.execute(tipoEmpleo); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public BeneficiarioModuleUpdate(ICommandUpdateIdentity <Beneficiario> commandUpdate) { Put["/enterprise/beneficiarios"] = parameters => { var request = this.Bind <BeneficiarioRequest>(); if (request.isValidPost()) { var beneficiarioMap = new BeneficiarioMap(); var beneficiario = beneficiarioMap.getBeneficiario(request); if (commandUpdate.isExecutable(beneficiario)) { commandUpdate.execute(beneficiario); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public ParentescoModuleUpdate(ICommandUpdateIdentity <Parentesco> command) { Put["/enterprise/beneficiarios/parentescos"] = parameters => { var request = this.Bind <ParentescoRequest>(); if (request.isValidPut()) { var mapTipoEmpleo = new ParentescoMapping(); var motivoDespido = mapTipoEmpleo.getParentescoForPut(request); if (command.isExecutable(motivoDespido)) { command.execute(motivoDespido); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } } return(new Response() .WithStatusCode(HttpStatusCode.BadRequest)); }; }
public RolModuleCommandUpdate(IRolRepositoryReadOnly repositoryRead, ICommandUpdateIdentity <Rol> commandUpdate) { Put["/rol"] = parameters => { var _rolRequest = this.Bind <RolRequest>(); if (repositoryRead.exists(_rolRequest.idGuid)) { 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.Id = _rolRequest.idGuid; rol.Nivel = _rolRequest.nivel; commandUpdate.execute(rol); return(new Response() .WithStatusCode(HttpStatusCode.OK)); } return(new Response() .WithStatusCode(HttpStatusCode.NotFound)); }; }