Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Pie = await _context.Pie.FindAsync(id);

            if (Pie != null)
            {
                _context.Pie.Remove(Pie);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            using (var stream = new System.IO.MemoryStream())
            {
                file.CopyTo(stream);
                this.Image = stream.ToArray();
            }

            Pie.Image            = this.Image;
            Pie.ImageContentType = "file";
            _context.Pie.Add(Pie);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            _context.Attach(Pie).State = EntityState.Modified;

            try
            {
                using (var stream = new System.IO.MemoryStream())
                {
                    file.CopyTo(stream);
                    this.Image = stream.ToArray();
                }

                Pie.Image            = this.Image;
                Pie.ImageContentType = "file";

                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PieExists(Pie.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }