コード例 #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsuarioExists(Usuario.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
コード例 #2
0
        public async Task <int> CrearNuevoAsync(Categoria categoria)
        {
            _context.Categoria.Add(categoria);
            int result = await _context.SaveChangesAsync();

            return(result);
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Usuario.Add(Usuario);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Evento.Add(Evento);
            await _context.SaveChangesAsync();

            //Image being saved
            string webRoothPath = _hostingEnvironment.WebRootPath;
            var    files        = HttpContext.Request.Form.Files;

            var eventoFromDb = _context.Evento.Find(Evento.Id);

            if (files[0] != null && files[0].Length > 0)
            {
                var uploads   = Path.Combine(webRoothPath, "images");
                var extension = files[0].FileName.Substring(files[0].FileName.LastIndexOf("."), files[0].FileName.Length - files[0].FileName.LastIndexOf("."));

                using (var fileStream = new FileStream(Path.Combine(uploads, Evento.Id + extension), FileMode.Create))
                {
                    files[0].CopyTo(fileStream);
                }
                eventoFromDb.Imagen = @"\images\" + Evento.Id + extension;
            }
            else
            {
                var uploads = Path.Combine(webRoothPath, @"\images\" + SD.DefaultEventImage);
                System.IO.File.Copy(uploads, webRoothPath + @"\images\" + Evento.Id + ".jpg");
                eventoFromDb.Imagen = @"\images\" + Evento.Id + ".jpg";
            }
            await _context.SaveChangesAsync();



            return(RedirectToPage("./Index"));
        }
コード例 #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
コード例 #6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
コード例 #7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            //  Boletos = Boletos - 1;
            //_context.Evento.Find(Id).NumBoletos = Boletos;
            _context.ListaInteresado.Add(ListaInteresado);

            var Evento = _context.Evento.FirstOrDefault(m => m.Id == ListaInteresado.EventoId);

            Evento.NumBoletos -= 1;

            await _context.SaveChangesAsync();

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