Esempio n. 1
0
        public ActionResult SaveDonation(Donation donation)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Login"));
            }

            donation.UserId = getUserSession().UserId;

            if (ModelState.IsValid)
            {
                dynamic json_affinity = JsonConvert.DeserializeObject(donation.Affinity);
                donation.Affinities = new List <Affinity>();
                foreach (var affinity in json_affinity)
                {
                    donation.Affinities.Add(new Affinity()
                    {
                        AffinityId = Guid.Parse(affinity["value"].ToString()),
                        Name       = affinity["text"]
                    });
                }

                var id = clientHttp.Post <Donation>(@"Donation/", donation);

                return(RedirectToAction("RegisterDonate", "Voluntary"));
            }

            ViewBag.user            = "******";
            ViewBag.register_donate = "active";
            var affinities = clientHttp.Get <List <Affinity> >(@"Affinity");

            ViewBag.affinities = affinities;

            return(View("RegisterDonate", donation));
        }
        public ActionResult SaveEntity(Entity entity)
        {
            if (ModelState.IsValid)
            {
                dynamic json_affinity = JsonConvert.DeserializeObject(entity.Affinities);
                entity.EntityAffinity = new List <Affinity>();
                foreach (var affinity in json_affinity)
                {
                    entity.EntityAffinity.Add(new Affinity()
                    {
                        AffinityId = Guid.Parse(affinity["value"].ToString()),
                        Name       = affinity["text"]
                    });
                }

                var id = clientHttp.Post <Entity>(@"Entity/", entity);

                return(RedirectToAction("Login", "Login"));
            }

            var affinities = clientHttp.Get <List <Affinity> >(@"Affinity");

            ViewBag.affinities = affinities;
            return(View("RegisterEntity", entity));
        }
Esempio n. 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");
            }
        }
Esempio n. 4
0
        public ActionResult SaveModerator(User user)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Login"));
            }

            if (ModelState.IsValid)
            {
                var id = clientHttp.Post <User>(@"User/", user);

                return(RedirectToAction("Register"));
            }

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

            var volunteers = clientHttp.Get <List <Voluntary> >(@"Voluntary");

            ViewBag.volunteers = volunteers;

            var users = clientHttp.Get <List <User> >(@"User");

            ViewBag.users = users;

            return(View("Register", user));
        }
Esempio n. 5
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?
            }
        }
        public ActionResult Login(User user)
        {
            APIHttpClient clientHttp = new APIHttpClient("http://localhost:58441/api/");
            var           loginId    = clientHttp.Post <User>("SignIn", user);

            return(Redirect("/Home/Dashboard"));
        }
Esempio n. 7
0
        public ActionResult GravarCategoria(Categorias categorias)
        {
            Categorias cat = new Categorias()
            {
                Descricao = categorias.Descricao
            };

            APIHttpClient categoriaHttp = new APIHttpClient("http://pic-buy.brazilsouth.cloudapp.azure.com:81/api/");
            var           retorno       = categoriaHttp.Post <Categorias>("categorias", cat);

            return(RedirectToAction("Categorias"));
        }
Esempio n. 8
0
        public ActionResult GravarProduto(Produtos produtos)
        {
            Produtos prod = new Produtos()
            {
                Codigo      = produtos.Codigo,
                Descricao   = produtos.Descricao,
                Imagem      = produtos.Imagem,
                Acessos     = produtos.Acessos,
                Preco       = produtos.Preco,
                IdCategoria = produtos.IdCategoria
            };

            APIHttpClient produtoHttp = new APIHttpClient("http://pic-buy.brazilsouth.cloudapp.azure.com:81/api/");
            var           retorno     = produtoHttp.Post <Produtos>("produtos", prod);

            return(RedirectToAction("Produtos"));
        }