public ActionResult Deletar(int id)
        {
            EstabelecimentoRede estabelecimento = DAL.GetObjeto <EstabelecimentoRede>("id =" + id);

            DAL.Excluir(estabelecimento);
            this.AddNotification("Vínculo com administradora deletado.", NotificationType.Alerta);
            return(RedirectToAction("CadastrarEstabelecimento", new { id = estabelecimento.IdEstabelecimento }));
        }
        public ActionResult DeletarEstabelecimento(int id)
        {
            Estabelecimento estabelecimento = DAL.GetObjeto <Estabelecimento>(string.Format("id_conta={0} and id={1}", UsuarioLogado.IdConta, id));


            EstabelecimentoRede estabelecimento_rede = DAL.GetObjeto <EstabelecimentoRede>(string.Format("id_conta ={0} and  id_estabelecimento={1}", UsuarioLogado.IdConta, id));

            DAL.Excluir(estabelecimento);
            this.AddNotification("Vínculo com administradora deletado.", NotificationType.Alerta);
            return(RedirectToAction("CadastrarEstabelecimento", new { id = estabelecimento.IdEstabelecimento }));
        }
        public Respostas AddEstabelecimentoRede(EstabelecimentoRede estab_rede)
        {
            var request = new RestRequest("api/Estabelecimento/EstabelecimentoRede", Method.POST);

            request.AddJsonBody(estab_rede);
            var a = _client.Execute <Respostas>(request);

            if (a.StatusCode != HttpStatusCode.OK)
            {
                a.Data = new Respostas();
            }
            return(a.Data);
        }
Example #4
0
        public Respostas EstabelecimentoRede([FromBody] EstabelecimentoRede model)
        {
            Respostas response;

            try
            {
                var idBase = DAL.Gravar(model);
                response = new Respostas(true, "Estabelecimento rede incluído!", idBase);
            }
            catch (Exception ex)
            {
                response = new Respostas(true, ex.Message, 0);
            }
            return(response);
        }
        public ActionResult CadastrarEstabelecimentoRede(EstabelecimentoRede EstabelecimentoRede, FormCollection form)
        {
            EstabelecimentoRede.IdEstabelecimento     = Convert.ToInt32(form["IdEstabelecimento"]);
            EstabelecimentoRede.IdEstabelecimentoRede = form["idestabelecimentorede"];
            EstabelecimentoRede.CodigoEstabelecimento = Convert.ToInt32(form["CodigoEstabelecimento"] ?? "0");
            EstabelecimentoRede.NomeEstabelecimento   = form["NomeEstabelecimento"];

            if (EstabelecimentoRede.IdEstabelecimento == 0)
            {
                ModelState.AddModelError("", "Campo \"Identificação\" deve ser preenchido!");
                return(RedirectToAction("CadastrarEstabelecimento", new { id = EstabelecimentoRede.IdEstabelecimento }));
            }
            if (string.IsNullOrEmpty(EstabelecimentoRede.IdEstabelecimentoRede))
            {
                ModelState.AddModelError("", "Campo \"Rede\" deve ser preenchido!");
                return(RedirectToAction("CadastrarEstabelecimento", new { id = EstabelecimentoRede.IdEstabelecimento }));
            }

            ViewBag.Notification = "";

            // if (!ModelState.IsValid)
            //    return RedirectToAction("CadastrarEstabelecimento", EstabelecimentoRede.IdEstabelecimento);

            try
            {
                var resp = _restClient.AddEstabelecimentoRede(EstabelecimentoRede);
            }
            catch (Exception ex)
            {
                AddErrors(ex);
                return(RedirectToAction("CadastrarEstabelecimento", EstabelecimentoRede.IdEstabelecimento));
            }
            if (EstabelecimentoRede.IdEstabelecimento > 0)
            {
                this.AddNotification("Estabelecimento alterado.", NotificationType.Sucesso);
            }
            else
            {
                this.AddNotification("Estabelecimento incluído.", NotificationType.Sucesso);
            }

            return(RedirectToAction("CadastrarEstabelecimento", new { id = EstabelecimentoRede.IdEstabelecimento }));
        }