Manage a list of items with images

0

Good morning

My query is the following one I would like to know how I can do to move by a list, object by object showing me the information registry by registry. I mean, I have my first actionResult that receives the information to generate the list.

    [HttpPost]
    public ActionResult Index(VariablesEntrada datos)
    {

        DateTime fecha = datos.fecha;
        string fechaformateada = fecha.ToString(); 
        short NumProceso = datos.numEntrega;

        return RedirectToAction("Trabajo", new RouteValueDictionary(
              new { controller = "ControlCalidadFir", action = "Trabajo", Id = 0 , fechaProceso = fechaformateada, NumProceso = NumProceso }));// RedirectToAction es para pasar valores entre acciones del mismos controlador
    }

By passing it the date and process parameters it goes and fills the entire list. and then I take an object from that list and I can see it.

   public ActionResult Trabajo(int Id, string fechaProceso, short NumProceso )
    {
        List<ControlCalidadFir> listadoOut = new List<ControlCalidadFir>();
        ConexionBDReplicaSOS Listadoin = new ConexionBDReplicaSOS();
        listadoOut = Listadoin.ConsultaCalidadFIR(fechaProceso, NumProceso);

        foreach (var item in listadoOut)
        {
            //listadofinal = listado;
           int posicion = Id;
           int posicionac = BottonSiguiente(Id);
            if (posicion < 0)
            {
                posicion = 0;
                Id = 0;
            }

            // posicion = 1;
            var numero = listadoOut[posicion];// objeto en la posicion 0
            string nuevaImagen = "convirtio";

            //conviterte tiff a png

            //     Image imageFile = Image.FromFile(numero.Url);
            Bitmap.FromFile(numero.Url)
            .Save(@"C:\Windows\Temp\" + nuevaImagen + ".png", System.Drawing.Imaging.ImageFormat.Png);

            //cierra
            string imagenpng = @"C:\Windows\Temp\convirtio.png";
            byte[] imageByteData = System.IO.File.ReadAllBytes(imagenpng);
            string imageBase64Data = Convert.ToBase64String(imageByteData);
            //    string imageDataURL = string.Format(imageBase64Data);


            ViewBag.ImageData = imageBase64Data;

            //Llama la ayuda de tipos de afiliacion

            cargaCombos();

            ViewBag.contador = posicion;
            return View(numero);
        }

        return View();

    }

but I need to move one by one of the registers with a next button and one back, so that the user can move through the list. The problem I have is the position in which the list is, as an example: if the user gives the next has to go to the next record, but I do not know how to weigh that position to the action because if I send it to the same action of work I will always want to load the list and that would be very bad for the database. Also, as the action needs two parameters, these will be lost and generate a null error. Then I need to keep the list full and move through the records at the mercy of where the user wants to go.

Thanks

    
asked by usernovell 01.11.2016 в 22:44
source

1 answer

0

Let's start from the basis that this type of design would not recommend it, you are designing winform style when you are on the web, which is bad. The correct thing is that you list the user the results in a grid and this selection that entity wants to edit, it is more you could provide filters on the list and paged if there are many items.

In your case there are several ways to keep the position so that you can scroll when you select next

  • You could assign this to the Session object, with which the data would remain on the server, the next action would take that value and return the next entity
  • If you assign the position in the ViewBag and use it in the Html.Hidden () in this way when done in the next post you would take the value as parameter of the action.

I understand that in your case it would be the ViewBag.contador what you should assign to the hidden but this something strange, because after you never receive it in the next post, you should assign it to the hidden to have it in the action and get the following

@Html.Hidden("Id", ViewBag.contador)
    
answered by 02.11.2016 / 04:08
source