public List <MunicipioDto> GetAll() { var ListBd = _unitOfWork.MunicipioRepository.GetAll(); if (ListBd != null) { List <MunicipioDto> list = new List <MunicipioDto>(); foreach (var item in ListBd) { MunicipioDto municipio = new MunicipioDto() { Estado = item.Estado, IdMunicipio = item.IdMunicipio, NombreMunicipio = item.NombreMunicipio }; list.Add(municipio); } return(list); } else { throw new BusinessException(Constant.SIN_INFORMACION); } }
private TblMunicipio createEntity(MunicipioDto municipioDto) { return(new TblMunicipio() { Estado = municipioDto.Estado, NombreMunicipio = municipioDto.NombreMunicipio }); }
public MunicipioDto execute(MunicipioDto municipioDto) { if (!municipioDto.Estado) { _unitOfWork.RegionMunicipioRepository.Delete(x => x.IdMunicipio.Equals(municipioDto.IdMunicipio)); _unitOfWork.Save(); } _unitOfWork.MunicipioRepository.Update(createEntiti(municipioDto)); _unitOfWork.Save(); return(null); //throw new NotImplementedException(); }
public IActionResult Post(MunicipioDto municipio) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } municipioService.Add(municipio); return(Ok(municipio)); } catch (Exception) { throw; } }
public void Edit(MunicipioDto entity) { try { uowService.MunicipioRepository.Edit(mapper.Map <Municipio>(entity)); uowService.Save(); } catch (ExceptionData) { throw; } catch (Exception ex) { throw new ExceptionCore("error al intentar editar el municipio", ex); } }
public void Add(MunicipioDto dto) { try { uowService.MunicipioRepository.Add(mapper.Map <Municipio>(dto)); uowService.Save(); } catch (ExceptionData) { throw; } catch (Exception ex) { throw new ExceptionCore("error al intentar agregar el municipio", ex); } }
public IActionResult Update([FromBody] MunicipioDto Request) { try { var _resultado = _updatemunicipioAplication.execute(Request); return(StatusCode(StatusCodes.Status200OK, _resultado)); } catch (TecnicalException ex) { return(StatusCode(StatusCodes.Status500InternalServerError, CreateResponseService.execute(StatusCodes.Status500InternalServerError.ToString(), ex.Message.ToString(), string.Empty))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public IActionResult Put(int id, MunicipioDto municipio) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = municipioService.Find(id); if (entity == null) { return(NotFound()); } municipioService.Edit(municipio); return(Ok(municipio)); } catch (Exception) { throw; } }
public MunicipioTestes() { IdMunicipio = Guid.NewGuid(); NomeMunicipio = Faker.Address.StreetAddress(); CodigoIBGEMunicipio = Faker.RandomNumber.Next(1, 10000); NomeMunicipioAlterado = Faker.Address.StreetAddress(); CodigoIBGEMunicipioAlterado = Faker.RandomNumber.Next(1, 10000); IdUf = Guid.NewGuid(); for (int i = 0; i < 10; i++) { var dto = new MunicipioDto() { Id = Guid.NewGuid(), Nome = Faker.Address.StreetAddress(), CodIBGE = Faker.RandomNumber.Next(1, 10000), UfId = Guid.NewGuid() }; listaDto.Add(dto); } municipioDto = new MunicipioDto() { Id = IdMunicipio, Nome = NomeMunicipio, CodIBGE = CodigoIBGEMunicipio, UfId = IdUf }; municipioDtoCompleto = new MunicipioDtoCompleto() { Id = IdMunicipio, Nome = NomeMunicipio, CodIBGE = CodigoIBGEMunicipio, UfId = IdUf, Uf = new UfDto() { Id = Guid.NewGuid(), Nome = Faker.Address.UsState(), Sigla = Faker.Address.UsState().Substring(1, 3) } }; municipioDtoCreate = new MunicipioDtoCreate() { Nome = NomeMunicipio, CodIBGE = CodigoIBGEMunicipio, UfId = IdUf }; municipioDtoCreateResult = new MunicipioDtoCreateResult() { Id = IdMunicipio, Nome = NomeMunicipio, CodIBGE = CodigoIBGEMunicipio, UfId = IdUf, CreateAt = DateTime.UtcNow }; municipioDtoUpdate = new MunicipioDtoUpdate() { Id = IdMunicipio, Nome = NomeMunicipioAlterado, CodIBGE = CodigoIBGEMunicipioAlterado, UfId = IdUf }; municipioDtoUpdateResult = new MunicipioDtoUpdateResult() { Id = IdMunicipio, Nome = NomeMunicipioAlterado, CodIBGE = CodigoIBGEMunicipioAlterado, UfId = IdUf, UpdateAt = DateTime.UtcNow }; }
public MunicipioTestes() { IdMunicipio = Guid.NewGuid(); Cidade = Faker.Address.StreetName(); NomeCidadeAlterado = Faker.Address.StreetName(); IdUf = Guid.NewGuid(); for (int i = 0; i < 10; i++) { var dto = new MunicipioDto() { Id = Guid.NewGuid(), Cidade = Faker.Name.FullName(), UfId = Guid.NewGuid() }; listaDto.Add(dto); } municipioDto = new MunicipioDto { Id = IdMunicipio, Cidade = Cidade, UfId = IdUf }; municipioDtoCompleto = new MunicipioDtoCompleto { Id = IdMunicipio, Cidade = Cidade, UfId = IdUf, Uf = new UfDto { Id = Guid.NewGuid(), Estado = Faker.Address.UsState(), Sigla = Faker.Address.UsState().Substring(1, 3) } }; municipioDtoCreate = new MunicipioDtoCreate { Cidade = Cidade, UfId = IdUf }; municipioDtoCreateResult = new MunicipioDtoCreateResult { Id = IdMunicipio, Cidade = Cidade, UfId = IdUf, CreateAt = DateTime.UtcNow }; municipioDtoUpdate = new MunicipioDtoUpdate { Id = IdMunicipio, Cidade = NomeCidadeAlterado, UfId = IdUf }; municipioDtoUpdateResult = new MunicipioDtoUpdateResult { Id = IdMunicipio, Cidade = NomeCidadeAlterado, UfId = IdUf, UpdateAt = DateTime.UtcNow }; }
public RetornoApi <object> Put(int codigo, [FromBody] MunicipioDto dados) { return(Ok <object>(null)); }
public RetornoApi <object> Post([FromBody] MunicipioDto dados) { return(Ok <object>(null)); }
public ResponseService execute(MunicipioDto municipioDto) { _unitOfWork.MunicipioRepository.Insert(createEntity(municipioDto)); _unitOfWork.Save(); return(CreateResponseService.execute(Constant.CODIGO_EXITO, Constant.TRANSACCION_EXITOSA, null)); }
public ResponseService execute(MunicipioDto municipioDto) { return(_newMunicipioDomain.execute(municipioDto)); }
public MunicipioDto execute(MunicipioDto municipioDto) { return(_updateMunicipioDomain.execute(municipioDto)); }