public ResultadoOperacao EnviarDenuncia(Denuncia denuncia) { try { denuncia daoDenuncia = ConvertDenunciaToDaoDenuncia(denuncia); webserviceEntities model = new webserviceEntities(); denuncia addedDenuncia = model.denuncia.Add(daoDenuncia); model.SaveChanges(); ResultadoOperacao resultado = new ResultadoOperacao(); if (addedDenuncia != null) { resultado.bSucesso = true; resultado.iCodigo = addedDenuncia.id; } else { resultado.bSucesso = false; } return(resultado); } catch { ResultadoOperacao resultado = new ResultadoOperacao(); resultado.bSucesso = false; return(resultado); } }
public async Task <IActionResult> PostDenuncia([FromBody] Denuncia denuncia) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Denuncia.Add(denuncia); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (DenunciaExists(denuncia.IdDenuncia)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetDenuncia", new { id = denuncia.IdDenuncia }, denuncia)); }
public List <Historico> ListarHistoricos(Denuncia d) { conexion.SqlConexion sql = new conexion.SqlConexion(); sql.Conectar(estatic.LoginStatic.ReturnConnectionString()); List <SqlParameter> _Parametros = new List <SqlParameter>(); _Parametros.Add(new SqlParameter("@Folio", d.folio)); _Parametros.Add(new SqlParameter("@Categoria", d.categoria)); sql.PrepararProcedimiento("dbo.BuscarDenunciaPorFolio", _Parametros); DataTable dt = sql.EjecutarTable(); List <Historico> historicos = new List <Historico>(); Historico historico; for (int i = 0; i < dt.Rows.Count; i++) { historico = new Historico() { dependiente = dt.Rows[i]["his_dependiente"].ToString(), descripcion = dt.Rows[i]["his_descripcion"].ToString(), fecha = dt.Rows[i]["his_fecha"].ToString() }; historicos.Add(historico); } sql.Desconectar(); sql.Dispose(); return(historicos); }
public static void RemoverDenuncia(int id) { Denuncia denuncia = BuscarById(id); ctx.Denuncias.Remove(denuncia); ctx.SaveChanges(); }
public Denuncia Persistir(Model.Denuncia objDenuncia) { Denuncia TmpDenuncia = null; if (objDenuncia.ID.HasValue) { TmpDenuncia = RepositoryService.Denuncia.ObterPor(objDenuncia.ID.Value); if (TmpDenuncia != null) { RepositoryService.Denuncia.Update(objDenuncia); //Altera Status - Se necessário if (!TmpDenuncia.Status.Equals(objDenuncia.Status) && objDenuncia.Status != null) { this.MudarStatus(TmpDenuncia.ID.Value, objDenuncia.Status.Value); } return(TmpDenuncia); } else { return(null); } } else { objDenuncia.ID = RepositoryService.Denuncia.Create(objDenuncia); return(objDenuncia); } }
public IActionResult OnPost(Denuncia denuncia, string Data) { if (ModelState.IsValid) { var logradouroId = Convert.ToInt32(denuncia.logradouro); Categoria = new Categoria(); var lista = Categoria.Listar().ToList(); var elemen = lista.Where(x => x.Value == "0").ToArray(); denuncia.data = _dbDenuncia.ConverteStringData(Data); denuncia.lat = _dbGeolocalizado.ObterPorIdString(denuncia.logradouro).Latitude; denuncia.lng = _dbGeolocalizado.ObterPorIdString(denuncia.logradouro).Longitude; denuncia.cep = _dbGeolocalizado.ObterPorIdString(denuncia.logradouro).GeolocalizadoId; denuncia.logradouro = _dbLogradouro.ObterPorId(logradouroId).Nome; denuncia.bairro = _dbBairro.ObterPorIdString(denuncia.bairro).Nome; denuncia.categoria = elemen[0].Name.ToString(); denuncia.agente = User.Identity.Name; _dbDenuncia.Adicionar(denuncia); return(RedirectToPage("Index")); } ListaBairro = _dbBairro.ObterTodos().OrderBy(x => x.Nome); Categoria = new Categoria(); ListaCategoria = Categoria.Listar().ToList(); return(Page()); }
protected void ButtonEnviar_Click(object sender, EventArgs e) { if (FileUpload.HasFile) { if (!FileUpload.FileName.EndsWith(".zip", StringComparison.CurrentCultureIgnoreCase)) { AnexoValidator.ErrorMessage = "O anexo deverá estar compactado no formato ZIP"; AnexoValidator.IsValid = false; return; } if (FileUpload.PostedFile.ContentLength > 10485760) { AnexoValidator.ErrorMessage = "O anexo deverá ter no máximo 10 MB."; AnexoValidator.IsValid = false; return; } } String userName = HttpContext.Current.User.Identity.Name; if (userName == null) { Response.Redirect("~/Oops.aspx"); } Denuncia denuncia = new Denuncia(); denuncia.Cnpj = lblCNPJ.InnerText; denuncia.RazaoSocial = lblRazaoSocial.InnerText; denuncia.UsuarioDenuncia = HttpContext.Current.User.Identity.Name; denuncia.Texto = TextBoxDenuncia.Text; if (denuncia.InsereDenuncia()) { if (FileUpload.HasFile) { String dir = Server.MapPath("Denuncias") + "\\" + denuncia.IdDenuncia.ToString("0000"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } DirectoryInfo dirInfo = new DirectoryInfo(dir); Anexos anexo = new Anexos(); anexo.IdDenuncia = denuncia.IdDenuncia; anexo.UserName = HttpContext.Current.User.Identity.Name; anexo.Arquivo = (dirInfo.GetFiles().Length + 1).ToString("00") + "_" + FileUpload.FileName; anexo.InsereAnexo(); FileUpload.SaveAs(dir + "\\" + anexo.Arquivo); } //Response.Write("<script>alert('Denúncia enviada com sucesso.');window.parent.closeTab();</script>"); Response.Redirect(String.Format("~/DenunciaMsg.aspx?Retorno=close&IdDenuncia={0}", denuncia.IdDenuncia.ToString())); } }
/// <summary> /// Registrar denuncia /// </summary> /// <param name="sch"></param> /// <param name="dn"></param> /// <param name="dnt"></param> /// <param name="dno"></param> /// <param name="dnc"></param> /// <returns></returns> public JsonResult json15(string sch, string dn, int dnt, int dno, int dnc) { try { VerificaSessao(sch); var bll = new BLLDenuncia(); var d = new Denuncia(); d.Denuncia1 = dn; d.DenunciaObjeto_ID = dno; d.DenunciaTipo_ID = dnt; d.DenunciaClasse_ID = dnc; d.UsuarioInc_ID = UsuarioLogado_ID; bll.InsertAndSave(d); return(Json(new RetornoJsonPadrao("Denuncia Registrada com Sucesso.", true, null))); } catch (Exception ex) { return(Json(new RetornoJsonPadrao(ex.Message, false, null))); } }
public IActionResult EditarStatus(int id, Denuncia model) { if (id != model.Id) { return(NotFound()); } try { var denuncia = _context.Denuncias.Find(id); denuncia.Status = model.Status; _context.Update(denuncia); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DenunciaExists(model.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Cadastrar(Denuncia model, IFormFile imagem) { if (ModelState.ContainsKey("Status")) { ModelState.Remove("Status"); } if (ModelState.IsValid) { try { Usuario user = await _userManager.GetUserAsync(_httpContextAccessor.HttpContext.User); string nomeUnicoArquivo = UploadedFile(imagem); model.Status = "Pendente"; model.Foto = nomeUnicoArquivo; model.DataRealizada = DateTime.Today; model.UsuarioId = user.Id; _context.Denuncias.Add(model); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } catch (Exception ex) { return(RedirectToAction("Error", "Home")); } } return(View()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Logradouro,Numero,Complemento,Municipio,Estado,Zona,Tipo,Aream3,Responsavel")] Denuncia denuncia) { if (id != denuncia.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(denuncia); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DenunciaExists(denuncia.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(denuncia)); }
public void Save(Denuncia denuncia) { var publicacao = DataModel.Publicacao.Find(denuncia.IdPublicacao); if (denuncia.IdComentario == null) { Denuncia novaDenuncia = new Denuncia(); novaDenuncia.IdConsumidor = denuncia.IdConsumidor; novaDenuncia.IdPublicacao = denuncia.IdPublicacao; novaDenuncia.DataDenuncia = denuncia.DataDenuncia; novaDenuncia.IdComentario = null; novaDenuncia.Mensagem = denuncia.Mensagem; DataModel.Denuncia.Add(novaDenuncia); publicacao.QuantidadeDenuncias++; DataModel.SaveChanges(); } if (denuncia.IdPublicacao == null) { Denuncia novaDenuncia = new Denuncia(); novaDenuncia.IdConsumidor = denuncia.IdConsumidor; novaDenuncia.IdPublicacao = denuncia.IdPublicacao; novaDenuncia.IdPublicacao = null; novaDenuncia.Mensagem = denuncia.Mensagem; DataModel.Denuncia.Add(novaDenuncia); DataModel.SaveChanges(); } }
public bool setDenuncia(int idAlerta, string strMensaje, int idUsuario) { try { Denuncia de = dcTemp.GetTable <Cynomex.cynomys.webservice.Models.Denuncia>().Where(c => (c.idUsuario == idUsuario) && (c.idAlerta == idAlerta)).FirstOrDefault(); if (de != null) { return(false); } Denuncia Den = new Denuncia(); Den.idAlerta = idAlerta; Den.strMensaje = strMensaje; Den.idUsuario = idUsuario; Den.Status = false; dcTemp.GetTable <Cynomex.cynomys.webservice.Models.Denuncia>().InsertOnSubmit(Den); dcTemp.SubmitChanges(); dcTemp.Dispose(); return(true); } catch (Exception e) { return(false); } }
public ActionResult Create([Bind(Include = "Comuna,Id_Comuna,Descripcion")] Denuncia denuncia) { UserManager <ApplicationUser> UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db)); var CurrentUser = UserManager.FindById(User.Identity.GetUserId()); denuncia.CorreoUsuario = CurrentUser.Email; denuncia.Fecha_Cierre = DateTime.Now.AddDays(10); denuncia.Fecha_Ingreso = DateTime.Now; denuncia.Id_Estado = 1; if (ModelState.IsValid) { db.Denuncias.Add(denuncia); db.SaveChanges(); if (User.IsInRole("User")) { return(View("Gracias", denuncia)); } return(RedirectToAction("Index")); } return(View(denuncia)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Fecha,Calle,Numero,EntreCalles1,EntreCalles2,Descripcion,TipoDenunciaId,EstadoDenunciaId,Legajo,IpDenunciante")] Denuncia denuncia) { if (id != denuncia.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(denuncia); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DenunciaExists(denuncia.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EstadoDenunciaId"] = new SelectList(_context.EstadosDenuncia, "Id", "Id", denuncia.EstadoDenunciaId); ViewData["TipoDenunciaId"] = new SelectList(_context.TiposDenuncia, "Id", "Id", denuncia.TipoDenunciaId); return(View(denuncia)); }
public HttpResponseMessage Create(Denuncia denuncia) { try { denuncia.DataDenuncia = DateTime.Now; if (ModelState.IsValid) { DenunciaRepository.Save(denuncia); return(Request.CreateResponse(HttpStatusCode.Created, "Denúncia realiazada.")); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState + "Não foi possível realizar sua denúncia.")); } } catch (DbEntityValidationException ex) { foreach (var eve in ex.EntityValidationErrors) { foreach (var ve in eve.ValidationErrors) { return(Request.CreateResponse(HttpStatusCode.BadRequest + ". Solicitação não atendida. " + ve.ErrorMessage)); } } throw; } }
public async Task <ActionResult <Denuncia> > PostDenuncia(Denuncia denuncia) { _context.Denuncias.Add(denuncia); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDenuncia", new { id = denuncia.Id }, denuncia)); }
public async Task <IActionResult> PutDenuncia(int id, Denuncia denuncia) { if (id != denuncia.Id) { return(BadRequest()); } _context.Entry(denuncia).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DenunciaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static int Insert(Denuncia denuncia) { int retorno = 0; try { IDbConnection objConexao; // Abre a conexao IDbCommand objCommand; // Cria o comando string sql = "INSERT INTO den_denuncias (den_opcao, den_tipo, usu_cpf_cnpj, pro_codigo) VALUES (?den_opcao, ?den_tipo, ?usu_cpf_cnpj, ?pro_codigo)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?den_opcao", denuncia.Den_opcao)); objCommand.Parameters.Add(Mapped.Parameter("?den_tipo", denuncia.Den_tipo)); objCommand.Parameters.Add(Mapped.Parameter("?usu_cpf_cnpj", denuncia.Usuario.Usu_cpf_cnpj)); objCommand.Parameters.Add(Mapped.Parameter("?pro_codigo", denuncia.Produto.Pro_codigo)); //objCommand.Parameters.Add(Mapped.Parameter("?sub_codigo", usuario.Subcategoria.Sub_codigo)); objCommand.ExecuteNonQuery(); objConexao.Close(); objCommand.Dispose(); objConexao.Dispose(); } catch (Exception) { retorno = -2; } return(retorno); }
// GET: ListDenuncias/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Denuncia denuncia = db.Denuncias.Find(id); if (denuncia == null) { return(HttpNotFound()); } var model = new EditDenunciaViewModel() { Id_Comuna = denuncia.Id_Comuna, Id_Estado = denuncia.Id_Estado, Descripcion = denuncia.Descripcion, Fecha_Cierre = denuncia.Fecha_Cierre, Comunas = db.Comunas.ToList(), Estados = db.EstadoDenuncias.ToList() }; return(View(model)); }
public ActionResult DeleteConfirmed(int id) { Denuncia denuncia = db.Denuncias.Find(id); db.Denuncias.Remove(denuncia); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.User.Identity.IsAuthenticated == false) { Response.Redirect("~/Account/Login.aspx"); } if (!IsPostBack) { String cnpj = Request.QueryString["codigo"]; if (cnpj == null || cnpj == "") { Response.Redirect("~/PesquisaInicio.aspx"); } Classes.Fornecedor fornecedor = new Classes.Fornecedor(); fornecedor.CarregaDados(cnpj); fornecedor.MarcaVisitado(System.Web.HttpContext.Current.User.Identity.Name); LabelCNPJ.Text = fornecedor.Cnpj; LabelRazaoSocial.Text = fornecedor.RazaoSocial; ButtonDenunciar.OnClientClick = "Denunciar();return false;"; ButtonListarDeputados.OnClientClick = "window.parent.addTabDocumentos('" + fornecedor.Cnpj + "','" + fornecedor.RazaoSocial + "', 0);return false;"; ButtonListarDocumentos.OnClientClick = "window.parent.addTabDocumentos('" + fornecedor.Cnpj + "','" + fornecedor.RazaoSocial + "', 1);return false;"; ButtonListarDoacoes.Visible = fornecedor.Doador; ButtonListarDoacoes.OnClientClick = "Doacoes();return false;"; StringBuilder url = new StringBuilder(); url.Append("http://www.google.com.br/search?q="); url.Append("\"" + fornecedor.RazaoSocial + "\""); ButtonPesquisa.OnClientClick = "window.open('" + url.ToString() + "');return false;"; Denuncia denuncia = new Denuncia(); denuncia.DenunciasFornecedorResumida(GridViewDenuncias, fornecedor.Cnpj); if (GridViewDenuncias.Rows.Count > 0) { PanelExisteDenuncia.Visible = true; if (GridViewDenuncias.Rows.Count == 1) { dvDenuncias.InnerText = "Este fornecedor possui 1 denúncia. Evite enviar denúncias repetidas caso existam outras recentes."; } else { dvDenuncias.InnerText = "Este fornecedor possui " + GridViewDenuncias.Rows.Count.ToString() + " denúncias. Evite enviar denúncias repetidas caso existam outras recentes."; } } } GridViewDenuncias.PreRender += GridViewDenuncias_PreRender; }
public void AdicionarAnimal(Denuncia d, Animal a) { var denunciaAnimal = new DenunciaAnimal(); denunciaAnimal.Animal = a; denunciaAnimal.Denuncia = d; contexto.DenunciaAnimal.Add(denunciaAnimal); contexto.SaveChanges(); }
private void btnDenuncieDenunciar_Click(object sender, RoutedEventArgs e) { Controller.DenunciaController denunController = new Controller.DenunciaController(); Denuncia denun = new Denuncia(); // fkUsuario receberá o resultado de RetornaID. Caso o usuário esteja cadastrado irá retornar seus respectivo ID. Caso ñ esteja cadastrado irá retornar 0 e será cadastrado como null no BD fkUsuario = denunController.RetornaID(txtDenuncieNome.Text); if (denunController.RetornaID(txtDenuncieNome.Text) == 0) { //Caso o retorno de ResultaID seja 0, fkUsuario será null fkUsuario = null; } denun.NomeCompleto = txtDenuncieNome.Text; denun.Idade = short.Parse(txtDenuncieIdade.Text); denun.Tipo = tip; // Bool com o tipo de ocorrência denun.Sexo = sx; denun.Endereco = txtDenuncieEndereco.Text; denun.Numero = short.Parse(txtDenuncieNumero.Text); denun.CPF = txtDenuncieCPF.Text; denun.Distrito = cbDenuncieBairro.SelectionBoxItem.ToString(); denun.City = cbDenuncieCidade.SelectionBoxItem.ToString(); denun.UF = ("PR"); denun.Data = Convert.ToDateTime(dpDenuncieDataocorrido.SelectedDate.ToString()); //Conversão do DatePicker para DateTime denun.Hora = string.Concat(txtDenuncieHorarioHoras.Text, ":", txtDenuncieHorarioMinutos.Text); // Concatenação das strings de Hora e Minutos denun.BO = bo; //Bool com a resposta do CheckBox B.O. denun.TipoOcorrencia = cbDenuncieTipoOcorrencia.SelectionBoxItem.ToString(); denun.Prejuizo = txtDenunciePrejuizo.Text; denun.Dinheiro = dinheiroBool; //Bool's do CheckBox Objs Roubados denun.Carteira = carteiraBool; denun.Documentos = documentosBool; denun.Celular = celularBool; denun.Notebook = notebookBool; denun.OutrosEletronicos = outEletronicosBool; denun.Motocicleta = motoBool; denun.Veiculo = veiculoBool; denun.Outros = outrosBool; denun.Descricao = txtDenuncieDetalhes.Text; denun.UsuarioIdUsuario = fkUsuario; denun.Latitude = txtDenuncieLatitude.Text; denun.Longitude = txtDenuncieLongitude.Text; // Validações que impedem o cadastro de campos em branco if (string.IsNullOrWhiteSpace(txtDenuncieNome.Text) || (rbDenuncieTestemunha.IsChecked == false && rbDenuncieVitima.IsChecked == false) || string.IsNullOrWhiteSpace(txtDenuncieEndereco.Text) || string.IsNullOrWhiteSpace(txtDenuncieNumero.Text) || string.IsNullOrWhiteSpace(txtDenuncieCPF.Text) || cbDenuncieBairro.SelectionBoxItem.ToString().Equals("") || cbDenuncieCidade.SelectionBoxItem.ToString().Equals("") || dpDenuncieDataocorrido.SelectedDate == null || cbDenuncieTipoOcorrencia.SelectionBoxItem.ToString().Equals("") || string.IsNullOrWhiteSpace(txtDenuncieHorarioHoras.Text) || string.IsNullOrWhiteSpace(txtDenuncieHorarioMinutos.Text)) { MessageBox.Show("Campos obrigatórios não preenchidos. (marcados com *)"); } else { denunController.Insert(denun); MessageBox.Show("Denúncia cadastrada com sucesso."); } }
public async Task <dynamic> CreateDenuncia(DenunciaForm denunciaForm) { var denuncia = new Denuncia(denunciaForm.TextoDenuncia, denunciaForm.PaisId, DateTime.Now, denunciaForm.ContinenteId); await _context.Denuncias.AddAsync(denuncia); _context.SaveChanges(); return(denuncia); }
public void DeleteDenuncia(Denuncia denuncia, int idDenuncia) { var publicacao = DataModel.Publicacao.Find(denuncia.IdPublicacao); DataModel.Denuncia.Remove(denuncia); publicacao.QuantidadeDenuncias--; DataModel.SaveChanges(); }
public ActionResult Edit([Bind(Include = "Id_denuncia,Comuna,Id_Comuna,Estado,Id_Estado,Fecha_Ingreso,Fecha_Cierre,Descripcion,CorreoUsuario")] Denuncia denuncia) { if (ModelState.IsValid) { db.Entry(denuncia).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(denuncia)); }
public async Task <IActionResult> Create([Bind("Id,Logradouro,Numero,Complemento,Municipio,Estado,Zona,Tipo,Aream3,Responsavel")] Denuncia denuncia) { if (ModelState.IsValid) { _context.Add(denuncia); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(denuncia)); }
public async Task <Respuesta> GenerarDenuncia([FromBody] Denuncia denuncia) { _denuncia.Add(denuncia); await _denuncia.SaveChangesAsync(); Respuesta respuesta = new Respuesta(); respuesta.CodigoRespuesta = 0; respuesta.DescripcionRespuesta = "El registro se realizo exitosamente"; return(respuesta); }
public void Delete(int id) { Denuncia denunExcluir = BuscaID(id); if (denunExcluir != null) { BDRadarContainer contexto = new BDRadarContainer(); contexto.DenunciaSet.Remove(denunExcluir); contexto.SaveChanges(); } }