public ActionResult RegisterEvent()
        {
            ViewBag.user           = "******";
            ViewBag.register_event = "active";
            var affinities = clientHttp.Get <List <Affinity> >(@"Affinity");

            ViewBag.affinities = affinities;

            return(View());
        }
示例#2
0
        public ActionResult Validation_Create_User(User userTemp)
        {
            if (ModelState.IsValid == false)
            {
                return(View("Register", userTemp));
            }
            else
            {
                APIHttpClient client = new APIHttpClient("http://localhost:52198/api/");
                var           users  = client.Get <List <User> >("user");


                foreach (var busca in users)
                {
                    if (String.Equals(busca.Email, userTemp.Email))
                    {
                        ModelState.AddModelError("userTemp.CadastroErrado", "E-mail já Existe !");
                        return(View("Register", userTemp));
                    }
                }

                client.Post <User>("user", userTemp);

                return(RedirectToAction("Index", "Usuario"));    // Como atualizar a lista de usuários na tela de Login?
            }
        }
示例#3
0
        public ActionResult Gravar(Planta planta)
        {
            if (ModelState.IsValid == false)
            {
                return View("Adicionar", planta);
            }
            else
            {
                APIHttpClient client = new APIHttpClient("http://localhost:52198/api/");
                var plantas = client.Get<List<Planta>>("Planta");

                foreach (var busca in plantas)
                {
                    if ((String.Equals(busca.CodigoPlanta, planta.CodigoPlanta) || (String.Equals(busca.NomePlanta, planta.NomePlanta))))
                    {
                        ModelState.AddModelError("planta.ok", "NOME OU CODIGO JÁ EXISTE!");

                        return View("Adicionar", planta);
                    }
                }
                var id = client.Post<Planta>("planta", planta);

                return RedirectToAction("Index", "Home");
            }
        }
示例#4
0
        // GET: Autenticacao

        //List<User> userTemp = new List<User>(); // declarando a lista temporaria para login

        public ActionResult Validation(User userTemp)
        {
            APIHttpClient client = new APIHttpClient("http://localhost:52198/api/");
            var           users  = client.Get <List <User> >("User/");

            foreach (var valid in users)
            {
                if (String.Equals(valid.Email, userTemp.Email))  // Compare Email usando String.Equals
                {
                    Console.WriteLine("email e igual");

                    if (String.Equals(valid.Password, userTemp.Password)) // Compare Senha usando String.Equals
                    {
                        return(RedirectToAction("Index", "Home"));
                    }

                    else
                    {
                        return(RedirectToAction("Login", "Usuario"));
                    }
                }
                else
                {
                    return(RedirectToAction("Login", "Usuario"));
                }
            }

            return(RedirectToAction("Login", "Usuario"));
        }
示例#5
0
        public ActionResult LoginMethod(LoginForm login)
        {
            if (ModelState.IsValid)
            {
                try {
                    var u = clientHttp.AuthenticationPost(login.Email, login.Password);

//                    Session["user"] = clientHttp.Get<User>(string.Format(@"User/{0}", login.Email));

//                    Gambiarra pra fazer funcionar, e seguir o projeto,
//                    não consegui fazer get do usuário de outra forma, e nem com a validação
                    var user = (User)clientHttp.Get <User>(string.Format(@"User/{0}", "862ccb69-7785-4ad6-ad40-bff07deafc63"));

                    Session["user"] = user;
                    if (user.IsEntity)
                    {
                        return(RedirectToAction("Index", "Entity"));
                    }
                    if (user.IsVoluntary)
                    {
                        return(RedirectToAction("Index", "Voluntary"));
                    }
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("Logout"));
                }
            }
            return(RedirectToAction("Logout"));
        }
示例#6
0
 // GET: Planta
 public ActionResult Index()
 {
     List<Planta> listPlanta = new List<Planta>();
     APIHttpClient client = new APIHttpClient("http://localhost:52198/api/");
     listPlanta = client.Get<List<Planta>>("Planta");
     ViewBag.listPlanta = listPlanta;
     return View(listPlanta);
 }
示例#7
0
        public ActionResult Abrir(Guid Id)
        {
            Planta planta = null;

            APIHttpClient client = new APIHttpClient("http://localhost:52198/api/");
            planta = client.Get<Planta>("Planta/"+Id);

            return View("Dashboard", planta);
        }
示例#8
0
        public ActionResult NovoProduto()
        {
            APIHttpClient categoriaHttp = new APIHttpClient("http://pic-buy.brazilsouth.cloudapp.azure.com:81/api/");

            var listaCategoria = categoriaHttp.Get <List <Categorias> >("categorias");

            ViewBag.listaCategoria = listaCategoria;
            return(View());
        }
示例#9
0
        // GET: Cadastros
        public ActionResult Produtos()
        {
            APIHttpClient produtoHttp = new APIHttpClient("http://pic-buy.brazilsouth.cloudapp.azure.com:81/api/");

            var listaProdutos = produtoHttp.Get <List <Produtos> >("produtos");

            ViewBag.listaProdutos = listaProdutos;

            return(View());
        }
示例#10
0
        // GET: Home
        public ActionResult Index()
        {
            //List<Planta> listPlanta;
            APIHttpClient client     = new APIHttpClient("http://localhost:52198/api/");
            var           listPlanta = client.Get <List <Planta> >("planta");

            ViewBag.listPlanta = listPlanta;

            return(View());
        }
示例#11
0
        // GET: Home
        public ActionResult Index()
        {
            APIHttpClient localizacaoHttp = new APIHttpClient("http://pic-buy.brazilsouth.cloudapp.azure.com:81/api/");

            var listaLocalizacao = localizacaoHttp.Get <List <Localizacao> >("localizacao");

            ViewBag.listaLocalizacao = listaLocalizacao;

            return(View());
        }
        // GET: ColetaDados
        public ActionResult DadosBarometro(String mach)
        {
            List <Barometro> barometros = new List <Barometro>();
            APIHttpClient    client     = new APIHttpClient("http://localhost:52198/api/");
            var listaBarometro          = client.Get <List <Barometro> >("barometro");

            foreach (var busca in listaBarometro)
            {
                busca.MacHostBarometro = mach;
                barometros.Add(busca);
            }
            return(View("Dashbord", listaBarometro));
        }
        public ActionResult DadosGas(String mach)
        {
            List <SensorGas> listaGas = new List <SensorGas>();
            APIHttpClient    client   = new APIHttpClient("http://localhost:52198/api/");
            var sensorGas             = client.Get <List <SensorGas> >("SensorGas");

            foreach (var busca in listaGas)
            {
                busca.MachostGas = mach;
                listaGas.Add(busca);
            }
            return(View("Dashbord", listaGas));
        }
示例#14
0
        public ActionResult Register()
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Login"));
            }

            ViewBag.user     = "******";
            ViewBag.register = "active";

            try
            {
                var volunteers = clientHttp.Get <List <Voluntary> >(@"Voluntary");
                ViewBag.volunteers = volunteers;
            }
            catch (Exception e)
            {
                ViewBag.volunteers = new List <Voluntary>();
            }


            try
            {
                var entities = clientHttp.Get <List <Entity> >(@"Entity");
                ViewBag.entities = entities;
            }
            catch (Exception e)
            {
                ViewBag.entities = new List <Entity>();
            }

            try
            {
                var users = clientHttp.Get <List <User> >(@"User");
                ViewBag.users = users;
            }
            catch (Exception e)
            {
                ViewBag.users = new List <User>();
            }

            return(View());
        }
示例#15
0
        // Editar
        public ActionResult Alterar(Guid Id)
        {
            List<Planta> plantas;
            Planta plt = null;
            APIHttpClient client = new APIHttpClient("http://localhost:52198/api/");
            plantas = client.Get<List<Planta>>("Planta");

               foreach (var busca in plantas)
            {
                if (busca.Id == Id)
                {
                  plt = busca;
                }
            }
            return View("Adicionar", plt);
        }
示例#16
0
        public ActionResult LoginMethod(LoginForm login)
        {
            if (ModelState.IsValid)
            {
                try {
                    var u = clientHttp.AuthenticationPost(login.Email, login.Password);

                    var user = (User)clientHttp.Get <User>(string.Format(@"User/{0}", "f680cc5c-4c7d-4861-aa63-88b5f3c19348"));
                    Session["user"] = user;
                    if (user.IsModerator)
                    {
                        return(RedirectToAction("Index", "Admin"));
                    }
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("Logout"));
                }
            }
            return(RedirectToAction("Logout"));
        }
示例#17
0
        public ActionResult Events()
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Login"));
            }

            ViewBag.user   = "******";
            ViewBag.events = "active";

            var events = clientHttp.Get <List <Event> >(@"Event");

            ViewBag.allEvents = events;

            return(View());
        }
示例#18
0
        public ActionResult Validation_Login(User userTemp)
        {
            List <User> users;

            APIHttpClient client = new APIHttpClient("http://localhost:52198/api/");

            users = client.Get <List <User> >("user");

            foreach (var valid in users)
            {
                if (String.Equals(valid.Email, userTemp.Email) && (String.Equals(valid.Password, userTemp.Password)))
                {
                    return(Json(new Mensagem()
                    {
                        MensagemErro = false,
                    }));
                }
            }
            return(Json(new Mensagem()
            {
                MensagemErro = true,
                MensagemTexto = "Senha ou Email Invalido!"
            }));
        }