Пример #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));
        }
Пример #2
0
 public ActionResult Denunciar(DenunciaViewModel d)
 {
     if (ModelState.IsValid)
     {
         us.DenunciarPropuesta(d, (int)Session["ID"]);
         return(Redirect("/Propuestas/VerDetalles/" + d.Id));
     }
     return(View(d));
 }
Пример #3
0
        public ActionResult Denunciar(int id)
        {
            Boolean b = us.VerificarExistenciaDeDenunciaDelUsuario((int)Session["ID"], id);

            if (b)
            {
                TempData["Mensaje" + id] = "Ya ha emitido una denuncia para esta propuesta.";
                return(Redirect("/Propuestas/VerDetalles/" + id));
            }
            else
            {
                DenunciaViewModel d = new DenunciaViewModel
                {
                    Id = id
                };
                return(View(d));
            }
        }
Пример #4
0
        public void DenunciarPropuesta(DenunciaViewModel dvm, int idUser)
        {
            MotivoDenuncia motivo   = context.MotivoDenuncia.Single(m => m.IdMotivoDenuncia == dvm.Id);
            Denuncias      denuncia = new Denuncias
            {
                IdMotivo      = motivo.IdMotivoDenuncia,
                IdUsuario     = idUser,
                IdPropuesta   = dvm.Id,
                Comentarios   = dvm.Comentarios,
                FechaCreacion = DateTime.Now,
                Estado        = 1
            };

            if (dvm.Comentarios == null)
            {
                denuncia.Comentarios = "Sin comentario";
            }
            context.Denuncias.Add(denuncia);
            context.SaveChanges();
            AdminService AS = new AdminService();

            AS.VerificarLasCincoDenunciasDIferentes(dvm.Id);
        }
Пример #5
0
        public ActionResult Denunciar(Denuncias denuncia)
        {
            denuncia.FechaCreacion = DateTime.Now;
            denuncia.IdUsuario     = SessionHelper.Usuario.IdUsuario;
            denuncia.Estado        = (int)DenunciaEstado.EnRevision;
            if (DenunciasService.Denuncie(denuncia.IdPropuesta))
            {
                ModelState.AddModelError("", "Ya existe una denuncia de esta persona para esta propuesta");
            }
            if (!ModelState.IsValid)
            {
                var motivos = MotivoDenunciaService.GetAll().Select(m => new SelectListItem
                {
                    Text  = m.Descripcion,
                    Value = m.IdMotivoDenuncia.ToString()
                }).ToList();
                motivos = motivos.Prepend(new SelectListItem
                {
                    Value    = "0",
                    Text     = "Seleccione un motivo",
                    Disabled = true,
                    Selected = true
                }).ToList();
                var viewModel = new DenunciaViewModel
                {
                    IdPropuesta     = denuncia.IdPropuesta,
                    MotivoDenuncia  = motivos,
                    NombrePropuesta = PropuestaService.GetById(denuncia.IdPropuesta).Nombre
                };
                return(View(viewModel));
            }

            DenunciasService.Crear(denuncia);
            PropuestaService.Instance.PonerPropuestaEnRevision(denuncia.IdPropuesta);
            return(RedirectToAction("Inicio", "Inicio"));
        }
Пример #6
0
        public ActionResult Denunciar(int id)
        {
            var motivos = MotivoDenunciaService.GetAll().Select(m => new SelectListItem
            {
                Text  = m.Descripcion,
                Value = m.IdMotivoDenuncia.ToString()
            }).ToList();

            motivos = motivos.Prepend(new SelectListItem
            {
                Value    = "0",
                Text     = "Seleccione un motivo",
                Disabled = true,
                Selected = true
            }).ToList();
            var viewModel = new DenunciaViewModel
            {
                IdPropuesta     = id,
                MotivoDenuncia  = motivos,
                NombrePropuesta = PropuestaService.GetById(id).Nombre
            };

            return(View(viewModel));
        }