public IHttpActionResult Index(string id, string ddd, string numero) { try { if (_usuarioService.ObterPorId(new Guid(id)) == null) { return(Ok("Usuário Inválido")); } var novotelefone = new Telefone { UsuarioId = new Guid(id), Ddd = ddd, Numero = numero, TelefoneId = new Guid() }; _uokOfWork.BeginTransaction(); _telefoneService.Adicionar(novotelefone); _uokOfWork.Commit(); return(Ok("Dados salvos com sucesso")); } catch (Exception ex) { return(Ok(false)); } }
public bool Adicionar(TelefoneViewModel telefoneViewModel) { var Telefone = Mapper.Map <TelefoneViewModel, Telefone>(telefoneViewModel); BeginTransaction(); _telefoneService.Adicionar(Telefone); Commit(); return(true); }
public ActionResult Create(FormCollection telefone) { var novotelefone = new Telefone(); int idpessoa = Convert.ToInt32(telefone["IdPessoa.IdPessoa"].ToString()); novotelefone.IdPessoa = _service.ObterPorPessoa(idpessoa); novotelefone.Numero = telefone["Numero"]; novotelefone.Tipo = telefone["Tipo"]; if (ModelState.IsValid) { _service.Adicionar(novotelefone); return(RedirectToAction("Index", "Pessoa")); } return(View(telefone)); }
public Telefone Adicionar(Telefone obj) { return(_telefoneService.Adicionar(obj)); }