Beispiel #1
0
        public async Task <Documento> NuevaImagen(HttpPostedFileBase archivo, string nombre = "")
        {
            if (string.IsNullOrEmpty(nombre))
            {
                nombre = archivo.FileName;
            }

            var doc = new Documento()
            {
                Tipo   = DocumentoTipo.Imagen,
                Nombre = nombre,
                Mime   = archivo.GetMime(),
                Fecha  = DateTime.Now,
                Tamano = archivo.ContentLength,
            };

            doc.Ruta = await GuardarArchivoAsync(archivo, nombre);

            GuardarThumbnail(doc.Ruta, doc.Ruta);

            IDocumentosServicio srv = servicios.DocumentosServicio();

            srv.Insert(doc);
            await srv.ApplyChangesAsync();

            return(doc);
        }