public ActionResult Catalogo(object sender, EventArgs e) { try { // TODO: Add insert logic here CatalogoDTO catalogo = new CatalogoDTO(); catalogo.imagen = new List <CatalogoImagenDTO>(); for (int i = 0; i < Request.Files.Count; i++) { CatalogoImagenDTO image = new CatalogoImagenDTO(); HttpPostedFileBase file = (Request.Files[i]); var binaryReader = new BinaryReader(file.InputStream); var imagen = binaryReader.ReadBytes(Request.Files[i].ContentLength); image.imagen = imagen; catalogo.imagen.Add(image); } var anuncioId = Request.Form["anuncioId"]; catalogo.anuncioId = Int32.Parse(anuncioId); string user = User.Identity.GetUserName(); anunciosDAO.GuardarCatalogo(catalogo); } catch (Exception ex) { throw ex; } return(RedirectToAction("Index")); }
public CatalogoDTO GetCatalogo(Catalogo catalogo) { CatalogoDTO response = new CatalogoDTO(); response.id = catalogo.id; catalogo.imagen.ForEach(x => { CatalogoImagenDTO model = new CatalogoImagenDTO(); var path = imageHelper.GetImageFromByteArray(x.imagen); model.imagen = x.imagen; response.imagen.Add(model); response.paths.Add(path); }); return(response); }