private void AsignarDatosSocio(SocioDTO socio) { // asignacion de datos this.txtTelefono.Text = socio.Telefono; this.txtApyNom.Text = socio.ApyNombre; this.txtDomicilio.Text = socio.Domicilio; this.socioId = socio.Id; }
public ActionResult Editar(int?id, int?idEntrevista) { try { SocioDTO socioDTO; if (!id.HasValue || id == 0 && idEntrevista.HasValue) { socioDTO = new SocioDTO { EntrevistaId = idEntrevista.Value }; } else { socioDTO = _socioService.FindSocio(id.Value); } return(View(socioDTO)); } catch (Exception ex) { return(View("Error", ex)); } }
public ActionResult POSTEditar(SocioDTO socioDTO) { try { if (socioDTO.Id == 0) { socioDTO = _socioService.AddSocio(socioDTO); } else { _socioService.UpdateSocio(socioDTO); } return(JavaScript( "MensagemSucesso('O sócio foi salvo com sucesso.');" + "carregarPaginaAjax('" + Url.Action("Index", "Socio") + "');")); } catch (Exception ex) { TratamentoErro.Tratamento(this, ex); return(View("Editar", socioDTO)); } }
public SocioDTO AddSocio(SocioDTO socioDTO) { try { if (socioDTO == null) { throw new ArgumentNullException("socioDTO"); } if (socioDTO.Cpf != null) { socioDTO.Cpf = socioDTO.Cpf.Replace("-", "").Replace(".", "").Replace("_", "").Trim(); } if (socioDTO.Telefone != null) { socioDTO.Telefone = socioDTO.Telefone.Replace("_", "").Replace("-", "").Trim(); } if (socioDTO.Celular != null) { socioDTO.Celular = socioDTO.Celular.Replace("_", "").Replace("-", "").Trim(); } var Socio = SocioFactory.CreateSocio( socioDTO.Nome, socioDTO.Administrador, socioDTO.DataNascimento, socioDTO.Rg, socioDTO.OrgaoRG, socioDTO.Cpf, socioDTO.NomeMae, socioDTO.NomePai, socioDTO.Cnh, socioDTO.Nacionalidade, socioDTO.Naturalidade, socioDTO.Sexo, socioDTO.EstadoCivil, socioDTO.Telefone, socioDTO.Celular, socioDTO.Email, socioDTO.Participacao, socioDTO.Assina, socioDTO.Rua, socioDTO.Numero, socioDTO.Complemento, socioDTO.Bairro, socioDTO.Cidade, socioDTO.Cep, socioDTO.Referencia, socioDTO.Estado, socioDTO.EntrevistaId ); SalvarSocio(Socio); var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <Socio, SocioDTO>(Socio)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }
public SocioDTO UpdateSocio(SocioDTO socioDTO) { try { if (socioDTO == null) { throw new ArgumentNullException("SocioDTO"); } if (socioDTO.Cpf != null) { socioDTO.Cpf = socioDTO.Cpf.Replace("-", "").Replace(".", "").Replace("_", "").Trim(); } if (socioDTO.Telefone != null) { socioDTO.Telefone = socioDTO.Telefone.Replace("_", "").Replace("-", "").Trim(); } if (socioDTO.Celular != null) { socioDTO.Celular = socioDTO.Celular.Replace("_", "").Replace("-", "").Trim(); } var persistido = _socioRepository.Get(socioDTO.Id); if (persistido == null) { throw new Exception("Sócio não encontrado."); } var corrente = SocioFactory.CreateSocio( socioDTO.Nome, socioDTO.Administrador, socioDTO.DataNascimento, socioDTO.Rg, socioDTO.OrgaoRG, socioDTO.Cpf, socioDTO.NomeMae, socioDTO.NomePai, socioDTO.Cnh, socioDTO.Nacionalidade, socioDTO.Naturalidade, socioDTO.Sexo, socioDTO.EstadoCivil, socioDTO.Telefone, socioDTO.Celular, socioDTO.Email, socioDTO.Participacao, socioDTO.Assina, socioDTO.Rua, socioDTO.Numero, socioDTO.Complemento, socioDTO.Bairro, socioDTO.Cidade, socioDTO.Cep, socioDTO.Referencia, socioDTO.Estado, persistido.EntrevistaId ); corrente.Id = persistido.Id; AlterarSocio(persistido, corrente); var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <Socio, SocioDTO>(corrente)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }