Esempio n. 1
0
        private ResponseService UpdateMunicipios(List <MunicipioRegion> list, int idRegion)
        {
            bool check = false;

            foreach (MunicipioRegion item in list)
            {
                if (item.EliminaAgrega.Equals("0"))
                {
                    _unitOfWork.RegionMunicipioRepository.Delete(X => X.IdMunicipio.Equals(item.IdMunicipio) && X.Idregion.Equals(idRegion));
                    _unitOfWork.Save();
                }
                else
                {
                    var a = _unitOfWork.MunicipioRepository.GetByID(item.IdMunicipio);
                    _unitOfWork.Save();
                    if (a != null && a.Estado)
                    {
                        _unitOfWork.RegionMunicipioRepository.Insert(CreateRelation(item.IdMunicipio, idRegion));
                        _unitOfWork.Save();
                    }
                    else
                    {
                        check = true;
                    }
                }
            }

            return(CreateResponseService.execute(Constant.CODIGO_EXITO, check ? Constant.MUNICIPIO_iNACTIVO: Constant.TRANSACCION_EXITOSA, new RegionDto()));
        }
 public ResponseService execute(int id)
 {
     _unitOfWork.RegionMunicipioRepository.Delete(x => x.IdMunicipio.Equals(id));
     _unitOfWork.Save();
     _unitOfWork.MunicipioRepository.Delete(id);
     _unitOfWork.Save();
     return(CreateResponseService.execute(Constant.CODIGO_EXITO, Constant.TRANSACCION_EXITOSA, null));
 }
Esempio n. 3
0
        public ResponseService execute(string request)
        {
            TblRegion region = new TblRegion()
            {
                NombreRegion = request
            };

            _unitOfWork.RegionRepository.Insert(region);
            _unitOfWork.Save();

            return(CreateResponseService.execute(Constant.CODIGO_EXITO, Constant.TRANSACCION_EXITOSA, null));
        }
Esempio n. 4
0
        public ResponseService execute(RegionDetails regionDto)
        {
            _unitOfWork.RegionRepository.Update(createEntity(regionDto));
            _unitOfWork.Save();

            if (regionDto.Municipios != null && regionDto.Municipios.Count >= 0)
            {
                return(UpdateMunicipios(regionDto.Municipios, regionDto.IdRegion));
            }
            else
            {
                return(CreateResponseService.execute(Constant.CODIGO_EXITO, Constant.TRANSACCION_EXITOSA, null));
            }
        }
Esempio n. 5
0
 public IActionResult GetAll()
 {
     try
     {
         var _resultado = _searchRegionAplication.GetAll();
         return(StatusCode(StatusCodes.Status200OK, _resultado));
     }
     catch (TecnicalException ex)
     {
         return(StatusCode(StatusCodes.Status200OK, CreateResponseService.execute(StatusCodes.Status500InternalServerError.ToString(), ex.Message.ToString(), string.Empty)));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
        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 Delete([Required] int id)
        {
            try
            {
                var _resultado = _deleteMunicipioAplication.execute(id);
                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));
            }
        }
Esempio n. 8
0
        public IActionResult NewRegion([FromBody] RegionDto Request)
        {
            try
            {
                var _resultado = _newRegionAplication.execute(Request.NombreRegion);
                return(StatusCode(StatusCodes.Status200OK, _resultado));
            }
            catch (TecnicalException ex)
            {
                return(StatusCode(StatusCodes.Status204NoContent, CreateResponseService.execute(StatusCodes.Status500InternalServerError.ToString(), ex.Message.ToString(), string.Empty)));
            }

            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
 public ResponseService execute(MunicipioDto municipioDto)
 {
     _unitOfWork.MunicipioRepository.Insert(createEntity(municipioDto));
     _unitOfWork.Save();
     return(CreateResponseService.execute(Constant.CODIGO_EXITO, Constant.TRANSACCION_EXITOSA, null));
 }