예제 #1
0
        public ActionResult Create(PJModel model)
        {
            try
            {
                PJ pjData = new PJ();
                int idPJ = pjData.Inserir(model);

                List<EmailModel> listaEmail = new List<EmailModel>();
                if (Session["EmailPJ"] != null)
                    listaEmail = (List<EmailModel>)Session["EmailPJ"];

                List<TelefoneModel> listaTelefone = new List<TelefoneModel>();
                if (Session["TelefonePJ"] != null)
                    listaTelefone = (List<TelefoneModel>)Session["TelefonePJ"];

                List<EnderecoModel> listaEndereco = new List<EnderecoModel>();
                if (Session["EnderecoPJ"] != null)
                    listaEndereco = (List<EnderecoModel>)Session["EnderecoPJ"];

                List<InternetModel> listaInternet = new List<InternetModel>();
                if (Session["InternetPJ"] != null)
                    listaInternet = (List<InternetModel>)Session["InternetPJ"];

                Email _dataEmail = new Email();
                foreach (EmailModel item in listaEmail)
                {
                    item.IdPessoa = idPJ;
                    _dataEmail.Inserir(item);
                }

                Telefone _dataTel = new Telefone();
                foreach (TelefoneModel item in listaTelefone)
                {
                    item.IdPessoa = idPJ;
                    _dataTel.Inserir(item);
                }

                Endereco _dataEndereco = new Endereco();
                foreach (EnderecoModel item in listaEndereco)
                {
                    item.IdPessoa = idPJ;
                    _dataEndereco.Inserir(item);
                }

                Internet _dataInternet = new Internet();
                foreach (InternetModel item in listaInternet)
                {
                    item.IdPessoa = idPJ;
                    _dataInternet.Inserir(item);
                }

                Session["EnderecoPJ"] = null;
                Session["TelefonePJ"] = null;
                Session["EmailPJ"] = null;

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
예제 #2
0
        public ActionResult InserirInternet(string endereco, int idTipo, int IdPJ)
        {
            Internet _dataInternet = new Internet();
            InternetModel internetModel = new InternetModel() { Nome = endereco, IdPessoa = IdPJ, TipoInternet = new TipoInternetModel { Id = idTipo } };

            if (internetModel.Nome.Length < 100)
            {
                _dataInternet.Inserir(internetModel);
                return PartialView("_Internet", _dataInternet.Lista(IdPJ));
            }

            else throw new Exception("Erro;");
        }