public async Task Update(EstudiosMercado Obj)// UpdateSolicitud
                                                           {
                                                               try
                                                               {
                                                                   var result = await _ctx.EstudiosMercado.FirstOrDefaultAsync(e => e.EstudiosMercadoId == Obj.EstudiosMercadoId);

                                                                   if (result != null)
                                                                   {
                                                                       _ctx.Entry(result).CurrentValues.SetValues(Obj);
                                                                       await _ctx.SaveChangesAsync();

                                                                       var listaArchivosViejos = await _ctx.AdjuntosEstudiosMercado.Where(e => e.EstudiosMercadoId == Obj.EstudiosMercadoId).ToListAsync();

                                                                       if (listaArchivosViejos.Count() > 0)
                                                                       {
                                                                           var adjuntos = listaArchivosViejos.Select(x => x.AdjuntoId).ToList();

                                                                           _ctx.AdjuntosEstudiosMercado.RemoveRange(listaArchivosViejos);
                                                                           await _ctx.SaveChangesAsync();


                                                                           foreach (var c in adjuntos)
                                                                           {
                                                                               await new AdjuntoRepository().Delete(c);
                                                                           }
                                                                       }


                                                                       AdjuntoRepository adjuntorepo = new AdjuntoRepository();
                                                                       if (Obj.listaAdjuntos != null)
                                                                       {
                                                                           foreach (var c in Obj.listaAdjuntos)
                                                                           {
                                                                               await adjuntorepo.Create(c);

                                                                               AdjuntosEstudiosMercado nuevoAdjunto = new AdjuntosEstudiosMercado();
                                                                               nuevoAdjunto.EstudiosMercadoId = Obj.EstudiosMercadoId;
                                                                               nuevoAdjunto.AdjuntoId         = c.AdjuntoId;

                                                                               _ctx.AdjuntosEstudiosMercado.Add(nuevoAdjunto);
                                                                               await _ctx.SaveChangesAsync();
                                                                           }
                                                                       }
                                                                   }
                                                               }
                                                               catch (Exception e)
                                                               {
                                                                   throw new Exception(e.Message, e);
                                                               }
                                                           }
                                                           public async Task <int> Create(EstudiosMercado Obj)
                                                           {
                                                               try
                                                               {
                                                                   _ctx.EstudiosMercado.Add(Obj);
                                                                   await _ctx.SaveChangesAsync();

                                                                   if (Obj.listaAdjuntos != null)
                                                                   {
                                                                       AdjuntoRepository adjuntorepo = new AdjuntoRepository();
                                                                       foreach (var archivo in Obj.listaAdjuntos)
                                                                       {
                                                                           await adjuntorepo.Create(archivo);

                                                                           AdjuntosEstudiosMercado nuevoAdjunto = new AdjuntosEstudiosMercado();
                                                                           nuevoAdjunto.AdjuntoId         = archivo.AdjuntoId;
                                                                           nuevoAdjunto.EstudiosMercadoId = Obj.EstudiosMercadoId;
                                                                           _ctx.AdjuntosEstudiosMercado.Add(nuevoAdjunto);
                                                                           await _ctx.SaveChangesAsync();
                                                                       }
                                                                   }
                                                                   return(Obj.EstudiosMercadoId);
                                                               }
                                                               catch (Exception e)
                                                               {
                                                                   throw new Exception(e.Message, e);
                                                               }
                                                           }