private void PopulaTela(string _idRec)
        {
            int _id;

            Int32.TryParse(_idRec, out _id);
            ReclamacaoViewModel c = r.getReclamacaoId(_id).FirstOrDefault();

            ddlCategoria.SelectedValue = c.CategoriaId.ToString();
            ddlBairro.SelectedValue    = c.BairrosId.ToString();
            ddlStatus.SelectedValue    = c.Status.ToString();
            txtTitulo.Text             = c.Titulo;
            txtEndereco.Text           = c.Endereco;
            txtDescricao.Text          = c.Descricao;
            ddlCategoria.Enabled       = false;
            ddlBairro.Enabled          = false;
            txtTitulo.Enabled          = false;
            txtEndereco.Enabled        = false;
            txtDescricao.Enabled       = false;
            btnLimpar.Visible          = false;
            foto.Visible = false;
            Button1.Text = "Salvar";
            if (c.Status == Status.Encerrada)
            {
                ddlStatus.Enabled = false;
                Button1.Visible   = false;
            }
            else
            {
                ddlStatus.Items.Remove(ddlStatus.Items.FindByText("Encerrada"));
            }
            MostraStatus(true);
        }
Esempio n. 2
0
        private void PopulaReclamacao(int _idReclamcao)
        {
            btnResolver.Visible = false;
            string userId           = User.Identity.GetUserId();
            ApplicationDbContext db = new ApplicationDbContext();
            var role  = (from j in db.Roles where j.Name.Contains("Oficial") select j).FirstOrDefault();
            var users = db.Users.Where(x => x.Roles.Select(y => y.RoleId).Contains(role.Id)).ToList();

            ReclamacaoDal       r = new ReclamacaoDal();
            ReclamacaoViewModel c = r.getReclamacaoId(_idReclamcao).FirstOrDefault();
            var currentUserId     = c.UserId;

            var manager     = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var currentUser = manager.FindById(currentUserId);

            litUsuario.Text          = currentUser.UserName;
            litCategoria.Text        = c.Categoria;
            litBairro.Text           = c.Bairro;
            litDescricao.Text        = c.Descricao;
            litEndereco.Text         = c.Endereco;
            litTituloReclamacao.Text = c.Titulo;
            if (users.Find(x => x.Id == userId) != null)
            {
                if (c.Status == Status.Encerrada)
                {
                    btnResolver.Visible = false;
                }
                else
                {
                    btnResolver.Visible = true;
                }
            }

            litStatus.Text         = Enum.GetName(typeof(Status), c.Status);
            imgReclamacao.ImageUrl = @"~/Images/Reclamacao/" + c.Foto;
        }