Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Id,Fecha,Calle,Numero,EntreCalles1,EntreCalles2,Descripcion,TipoDenunciaId,EstadoDenunciaId,Legajo,IpDenunciante, Foto")] DenunciaViewModel denunciaViewModel)
        {
            if (ModelState.IsValid)
            {
                var denuncia    = _mapper.Map <Denuncia>(denunciaViewModel);
                var nroDenuncia = 0;
                if (_context.Denuncias.Count() > 0)
                {
                    nroDenuncia = _context.Denuncias.Max(x => x.Id);
                }
                nroDenuncia               = nroDenuncia == 0 ? 1 : nroDenuncia + 1;
                denuncia.NroDenuncia      = $"D-{nroDenuncia.ToString().PadLeft(8, '0')}";
                denuncia.Fecha            = DateTime.Now;
                denuncia.EstadoDenunciaId = 1;
                _context.Add(denuncia);
                await _context.SaveChangesAsync();

                if (denunciaViewModel.Foto != null)
                {
                    await UploadFile(denunciaViewModel.Foto, denuncia.NroDenuncia);
                }

                return(RedirectToAction("ThankYou", new { id = denuncia.Id }));
            }
            return(View(denunciaViewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Nombre")] TipoDenuncia tipoDenuncia)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tipoDenuncia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tipoDenuncia));
        }
        public async Task <IActionResult> Create([Bind("Id,Dni,Nombre,Apellido")] Empleado empleado)
        {
            if (ModelState.IsValid)
            {
                _context.Add(empleado);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(empleado));
        }
        public async Task <IActionResult> Create([Bind("Descripcion,DenunciaId,EmpleadoId,EstadoDenunciaId")] Comentario comentario)
        {
            if (ModelState.IsValid)
            {
                var denuncia = await _context.Denuncias.FindAsync(comentario.DenunciaId);

                denuncia.EstadoDenunciaId = comentario.EstadoDenunciaId;
                comentario.FechaCreacion  = DateTime.Now;
                _context.Add(comentario);
                _context.Update(denuncia);
                await _context.SaveChangesAsync();



                return(RedirectToAction("Index", "Denuncias"));
            }
            ViewData["DenunciaId"] = new SelectList(_context.Denuncias, "Id", "Id", comentario.DenunciaId);
            ViewData["EmpleadoId"] = new SelectList(_context.Set <Empleado>(), "Id", "Id", comentario.EmpleadoId);
            return(View(comentario));
        }