public async Task <ActionResult <EmpresaModel> > GetEmpresas(string id) { try { var empresa = await _context.GetItemById(id); var data = mapper.Map <Empresa, EmpresaModel>(empresa); data.Oferta = mapper.Map <ICollection <Oferta>, OfertaModel[]>(empresa.Oferta); if (empresa == null) { return(Ok(new EmpresaModel())); } //int i = 0; //OfertaModel[] listaOfertaModel = new OfertaModel[empresa.Oferta.Count]; //empresa.Oferta.ToList().ForEach(o => //{ // var nuevo = new OfertaModel // { // Alojamiento = o.Alojamiento, // CantidadPersonas = o.CantidadPersonas, // ContinuidadIgualLabor = o.ContinuidadIgualLabor, // ContinuidadOtraLabor = o.ContinuidadOtraLabor, // Descripcion = o.Descripcion, // FechaCaducidad = o.FechaCaducidad, // FechaPublicacion = o.FechaPublicacion, // IdEmpresa = o.IdEmpresa, // IdOferta = o.IdOferta, // JornadaReal = o.JornadaReal // }; // listaOfertaModel[i] = nuevo; // i++; //}); //EmpresaModel result = new EmpresaModel //{ // Actividad = empresa.Actividad, // Cargo = empresa.Cargo, // CodigoPostal = empresa.CodigoPostal, // CorreoElectronico = empresa.CorreoElectronico, // Dirección = empresa.Dirección, // IdEmpresa = empresa.IdEmpresa, // Nifcif = empresa.Nifcif, // NombreContacto = empresa.NombreContacto, // NombreEmpresa = empresa.NombreEmpresa, // Oferta = listaOfertaModel, // Provincia = empresa.Provincia, // Telefono = empresa.Telefono //}; return(Ok(data)); } catch (Exception exc) { Debug.WriteLine(exc.Message); throw; } }
public async Task <ActionResult <Oferta> > GetOfertas(string id) { var oferta = await _dbServices.GetItemById(id); if (oferta == null) { return(Ok(new Oferta())); } return(Ok(oferta)); }
public async Task <ActionResult <Persona> > GetPersonas(string id) { var persona = await _dbServices.GetItemById(id); //var personaModel = this.mapper.Map<Persona, PersonaModel>(persona); //personaModel.Curriculum = this.mapper.Map<ICollection<Curriculum>, Curriculum[]>(persona.Curriculum); //personaModel.RelacionOfertaPersona = this.mapper.Map<ICollection<RelacionOfertaPersona>, RelacionOfertaPersona[]>(persona.RelacionOfertaPersona); //personaModel.Permiso = this.mapper.Map<ICollection<Permiso>, Permiso[]>(persona.Permiso); //personaModel.Nacionalidad = this.mapper.Map<ICollection<Nacionalidad>, Nacionalidad[]>(persona.Nacionalidad); if (persona == null) { return(Ok(new Persona())); } return(Ok(persona)); }