Exemplo n.º 1
0
 public void DeleteEndereco(string EnderecoId)
 {
     Models.Endereco end = DBcontext.Endereco.Find(EnderecoId);
     if (end != null)
     {
         DBcontext.Endereco.Remove(end);
         Save();
     }
 }
Exemplo n.º 2
0
 public void InsertEndereco(Models.Endereco Endereco)
 {
     if (string.IsNullOrEmpty(Endereco.Id))
     {
         var guid = Guid.NewGuid(); Endereco.Id = guid.ToString();
     }
     DBcontext.Endereco.Add(Endereco);
     Save();
 }
        public ActionResult Excluir(int idec)
        {
            if (Session["idUsuario"] == null || Session["TipoDePagamento"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            Models.Endereco endereco = new Models.Endereco();

            endereco.DeletaEndereco(idec);

            return(RedirectToAction("Index", "Enderecos"));
        }
        public IActionResult Cadastrar([FromBody] Dictionary <string, string> body)
        {
            string msg      = null;
            bool   operacao = true;
            int    num;

            if (body["email"] == null || body["password"] == null ||
                body["nome"] == null || body["cpf"] == null ||
                body["data"] == null || body["rua"] == null ||
                body["num"] == null || body["cep"] == null ||
                body["data"] == null ||
                !int.TryParse(body["num"], out num))
            {
                msg      = "Verifique os campos, veja se estão preenchidos corretamente!";
                operacao = false;
            }
            else
            {
                Models.Endereco endereco = new Models.Endereco();
                Models.Usuario  usuario  = new Models.Usuario();

                endereco.Rua = body["rua"];
                endereco.Cep = body["cep"].Replace("-", "").Trim();
                endereco.Num = num;

                usuario.Email    = body["email"].Trim();
                usuario.Password = body["password"].Trim();
                usuario.Nome     = body["nome"].Trim();
                usuario.Cpf      = body["cpf"].Replace("-", "").Replace(".", "").Trim();
                usuario.Endereco = endereco;

                try
                {
                    usuario.DataNasc = DateTime.Parse(body["data"]);

                    CamadaNegocio.UsuarioCN usuarioCN = new CamadaNegocio.UsuarioCN();
                    (operacao, msg) = usuarioCN.Inserir(usuario);
                }
                catch (Exception ex)
                {
                    msg      = "Erro interno.";
                    operacao = false;
                }
            }

            return(Json(new {
                operacao,
                msg,
            }));
        }
Exemplo n.º 5
0
        public bool AdicionarCorreio(Models.Endereco end)
        {
            XElement x = new XElement("correios");

            x.Add(new XAttribute("uf", end.UF.ToString()));
            x.Add(new XAttribute("cidade", end.Cidade.ToString()));
            x.Add(new XAttribute("bairro", end.Bairro));
            x.Add(new XAttribute("complemento", end.Complemento));
            x.Add(new XAttribute("descricao", end.Descricao));

            x.Save("C://PROJETOS//02- EFD_REINF//3-CODIGO FONTE//Correio//Clientes.xml");

            return(true);
            //XElement xml = XElement.Load("correio.xml");
            //xml.Add(x);
            //xml.Save("correio.xml");
        }
Exemplo n.º 6
0
 public void UpdateEndereco(Models.Endereco Endereco)
 {
     DBcontext.Entry(Endereco).State = EntityState.Modified;
     Save();
 }
 /// <summary>
 /// Maps a model to an entity.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns></returns>
 public static Entities.Endereco ToEntity(this Models.Endereco model)
 {
     return(Mapper.Map <Entities.Endereco>(model));
 }