コード例 #1
0
        public async Task <JsonResult> CreateAlbum(Foto foto)
        {
            string photoName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpeg";
            string photoPath = "wwwroot/images/" + photoName;
            bool   exito     = false;

            if (foto.Img != null && foto.Descripcion != null)
            {
                using (var stream = new FileStream(photoPath, FileMode.Create))
                {
                    foto.Img.CopyTo(stream);
                }

                string photoPathBd = "/images/" + photoName;
                foto.Ruta = photoPathBd;

                //exito = dao.FotoUploader(foto);
                await _fotoRepository.FotoUploader(foto);

                return(Json(photoPathBd));
            }

            return(Json(exito));
        }