public ActionResult RegisterEvent() { ViewBag.user = "******"; ViewBag.register_event = "active"; var affinities = clientHttp.Get <List <Affinity> >(@"Affinity"); ViewBag.affinities = affinities; return(View()); }
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? } }
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"); } }
// 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")); }
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")); }
// 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); }
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); }
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()); }
// 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()); }
// 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()); }
// 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)); }
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()); }
// 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); }
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")); }
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()); }
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!" })); }