Example #1
0
    protected void btnEditar_Click(object sender, EventArgs e)
    {
        btnEditar.Visible = false;
        btnGrabar.Visible = true;

        CiudadDTO theCiudadDTO = new CiudadDTO();

        theCiudadDTO.IdCiudad          = decimal.Parse(this.hdnIdCiudad.Value);
        theCiudadDTO.NombreCiudad      = this.txtNombre.Text.ToUpper();
        theCiudadDTO.DescripcionCiudad = this.txtNombre.Text.ToUpper();
        RegionDTO myRegionDTO = new RegionDTO();

        myRegionDTO.IdRegion      = decimal.Parse(this.ddlRegion.SelectedValue);
        theCiudadDTO.TheRegionDTO = myRegionDTO;

        theCiudadDTO.UsuarioModificacion = myUsuario.Rut;

        bool respuesta = YouCom.bll.CiudadBLL.Update(theCiudadDTO);

        if (respuesta)
        {
            cargarCiudad();
            this.txtNombre.Text = string.Empty;
            this.ddlRegion.ClearSelection();

            if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
            {
                string script = "alert('Ciudad editada correctamente.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            }
        }
        else
        {
        }
    }
Example #2
0
        public void EditRegionAsync_ReturnsCorrect()
        {
            // Arrange

            Region reg = new Region()
            {
                ID = 2
            };
            RegionDTO region = new RegionDTO()
            {
                ID = 3, City = "Lviv"
            };

            _repoWrapper
            .Setup(x => x.Region.GetFirstAsync(It.IsAny <Expression <Func <Region, bool> > >(),
                                               It.IsAny <Func <IQueryable <Region>, IIncludableQueryable <Region, object> > >()))
            .ReturnsAsync(reg);

            _repoWrapper
            .Setup(x => x.Region.Update(reg));

            _repoWrapper
            .Setup(x => x.SaveAsync());
            // Act
            var result = _regionService.EditRegionAsync(It.IsAny <int>(), region);

            // Assert
            _repoWrapper.Verify();
            Assert.NotNull(result);
        }
Example #3
0
        public bool Update(RegionDTO oRegionData)
        {
            string          sProcName;
            DatabaseManager oDB;

            try
            {
                oDB       = new DatabaseManager();
                sProcName = "up_Upd_RegionMaster";
                oDB.DbCmd = oDB.GetStoredProcCommand(sProcName);
                oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@iRegionId", DbType.Int32, oRegionData.RegionId);
                oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sRegionName", DbType.String, oRegionData.RegionName);
                oDB.ExecuteNonQuery(oDB.DbCmd);
            }
            catch (Exception exp)
            {
                oDB         = null;
                oRegionData = null;
                GF.LogError("clsRegionMaster.Update", exp.Message);
                return(false);
            }
            finally
            {
                oDB = null;
            }
            return(true);
        }
Example #4
0
        public bool Insert(RegionDTO oRegionData)
        {
            string          sProcName;
            DatabaseManager oDB;

            try
            {
                oDB       = new DatabaseManager();
                sProcName = "up_Ins_RegionMaster";
                oDB.DbCmd = oDB.GetStoredProcCommand(sProcName);
                oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sRegionName", DbType.String, oRegionData.RegionName);
                oDB.ExecuteNonQuery(oDB.DbCmd);
                //oDB.ExecuteNonQuery(oDB.DbCmd);
            }
            catch (Exception exp)
            {
                oDB         = null;
                oRegionData = null;
                throw exp;
            }
            finally
            {
                oDB = null;
            }
            return(true);
        }
Example #5
0
        private RegionDTO[] PopulateDataObject(string Query)
        {
            RegionDTO[] oRegionData;
            DataSet     ds;

            try
            {
                oRegionData = null;
                ds          = GetDataFromDB(Query);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    oRegionData = new RegionDTO[ds.Tables[0].Rows.Count];
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        oRegionData[i]            = new RegionDTO();
                        oRegionData[i].RegionId   = Convert.ToInt32(ds.Tables[0].Rows[i][0]);
                        oRegionData[i].RegionName = Convert.ToString(ds.Tables[0].Rows[i][1]);
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                ds = null;
            }
            return(oRegionData);
        }
        private async Task<ImportValidationResultInfo> MapAndValidate(RegionDTO dto, int index)
        {
            return await Task.Run(() =>
            {
                if (dto == null) return null;
                var entity = _mappingService.Map(dto);
                var exist = _ctx.tblRegion.FirstOrDefault(p => p.Name.ToLower() == dto.Name.ToLower());

                entity.Id = exist == null ? Guid.NewGuid() : exist.id;

                var res = _repository.Validate(entity);
                var vResult = new ImportValidationResultInfo()
                {
                    Results = res.Results,
                    Description =
                        string.Format("Row-{0} name or code=>{1}", index,
                                      entity.Name ?? entity.Description),
                    Entity = entity
                };
                return vResult;

            });


        }
Example #7
0
        public void UpdateRegion(RegionDTO region)
        {
            var regionEF = regionRepository.GetBy(region.IdRegion);

            region.MappingRegion(regionEF);
            regionRepository.Update(regionEF);
        }
Example #8
0
    private void Save()
    {
        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Add))
        {
            return;
        }

        bool      bActionCompleted = false;
        RegionDTO oRegionData      = new RegionDTO();

        oRegionData.RegionName = txtRegionName.Text.ToString();
        RegionMaster oRegionMaster = new RegionMaster();

        bActionCompleted = oRegionMaster.Insert(oRegionData);
        if (bActionCompleted == true)
        {
            base.DisplayAlert("The record has been inserted successfully");
            txtRegionName.Text = "";
            lblStatus.Text     = "Saved";
        }
        else
        {
            lblStatus.Text = "Error Occured while insertion: Please refer to the error log.";
        }

        oRegionData   = null;
        oRegionMaster = null;
    }
Example #9
0
    protected void btnEditar_Click(object sender, EventArgs e)
    {
        btnEditar.Visible = false;
        btnGrabar.Visible = true;

        RegionDTO theRegionDTO = new RegionDTO();

        theRegionDTO.IdRegion = decimal.Parse(HidIdRegion.Value);

        PaisDTO myPaisDTO = new PaisDTO();

        myPaisDTO.IdPais        = decimal.Parse(ddlPais.SelectedValue);
        theRegionDTO.ThePaisDTO = myPaisDTO;

        theRegionDTO.DescripcionRegion = txtRegion.Text.ToUpper();
        theRegionDTO.UsuarioIngreso    = myUsuario.Rut;
        bool respuesta = YouCom.bll.RegionBLL.Update(theRegionDTO);

        if (respuesta)
        {
            cargarRegiones();

            txtRegion.Text = string.Empty;

            if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
            {
                string script = "alert('Region editado correctamente.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            }
        }
        else
        {
        }
    }
Example #10
0
 public void Update(RegionDTO region)
 {
     //var regions = _unitOfWork.Regiones.Get(x => x.Id == region.Id).FirstOrDefault();
     //regions.Email = region.Email;
     _unitOfWork.Regiones.Update(Mapper.Map <Region>(region));
     _unitOfWork.Complete();
 }
Example #11
0
        public void Update(RegionDTO regionDTO)
        {
            Region region = _mapper.Map <Region>(regionDTO);

            _unitOfWork.Regions.Update(region);
            _unitOfWork.Complete();
        }
Example #12
0
    protected void rptRegionInactivo_OnItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Activar")
        {
            HiddenField hdnTipoSistema = new HiddenField();
            hdnTipoSistema = (HiddenField)e.Item.FindControl("HdnTipoSistema");

            HiddenField hdnDescripcion = new HiddenField();
            hdnDescripcion = (HiddenField)e.Item.FindControl("hdnDescripcion");

            RegionDTO theRegionDTO = new RegionDTO();

            theRegionDTO.IdRegion       = decimal.Parse(hdnTipoSistema.Value);
            theRegionDTO.UsuarioIngreso = myUsuario.Rut;

            bool respuesta = YouCom.bll.RegionBLL.ActivaRegion(theRegionDTO);
            if (respuesta)
            {
                cargarRegionInactivo();
                if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                {
                    string script = "alert('Region Activado correctamente.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                }
            }
            else
            {
            }
        }
    }
Example #13
0
        public static bool DeleteRegion(RegionDTO theRegionDTO)
        {
            bool retorno = false;

            YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper();



            wobjSQLHelper.SetParametro("@usuarioIngreso", SqlDbType.VarChar, 20, theRegionDTO.UsuarioIngreso);
            wobjSQLHelper.SetParametro("@IdRegion", SqlDbType.VarChar, 20, theRegionDTO.IdRegion);

            try
            {
                //====================================================================================
                switch (wobjSQLHelper.EjecutarNQ("Delete_Region", "YouCom"))
                {
                case 0:
                    throw new Exception("No se pudo grabar.");

                case -1:
                    throw new Exception("Hubo un error.");

                case -2:
                    throw new Exception("Hubo un error.");
                }
                //====================================================================================
                retorno = true;
            }
            catch (Exception eobjException)
            {
                throw eobjException;
            }
            return(retorno);
        }
Example #14
0
        public static List <YouCom.DTO.RegionDTO> ListadoRegiones()
        {
            DataTable pobjDataTable = new DataTable();

            YouCom.DTO.RegionDTO        theRegionDTO;
            List <YouCom.DTO.RegionDTO> collRegion = new List <RegionDTO>();

            if (YouCom.Comun.DAL.Accesos.Region.ListadoRegiones(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    theRegionDTO                     = new RegionDTO();
                    theRegionDTO.IdRegion            = wobjDataRow["id_reg"] != null ? wobjDataRow["id_reg"].ToString() : string.Empty;
                    theRegionDTO.Descripcion         = wobjDataRow["dsc_reg"] != null ? wobjDataRow["dsc_reg"].ToString() : string.Empty;
                    theRegionDTO.IdPais              = wobjDataRow["idPais"] != null ? wobjDataRow["idPais"].ToString() : string.Empty;
                    theRegionDTO.UsuarioIngreso      = wobjDataRow["usuario_ingreso"] != null ? wobjDataRow["usuario_ingreso"].ToString() : string.Empty;
                    theRegionDTO.FechaIngreso        = wobjDataRow["fecha_ingreso"] != null ? wobjDataRow["fecha_ingreso"].ToString() : string.Empty;
                    theRegionDTO.UsuarioModificacion = wobjDataRow["usuario_modificacion"] != null ? wobjDataRow["usuario_modificacion"].ToString() : string.Empty;
                    theRegionDTO.FechaModificacion   = wobjDataRow["fecha_modificacion"] != null ? wobjDataRow["fecha_modificacion"].ToString() : string.Empty;
                    theRegionDTO.IdCondominio        = !string.IsNullOrEmpty(wobjDataRow["empresa"].ToString()) ? decimal.Parse(wobjDataRow["empresa"].ToString()) : 0;
                    theRegionDTO.Estado              = wobjDataRow["estado"] != null ? wobjDataRow["estado"].ToString() : string.Empty;


                    collRegion.Add(theRegionDTO);
                }
            }
            return(collRegion);
        }
Example #15
0
        public static List <YouCom.DTO.RegionDTO> getListadoRegion()
        {
            DataTable pobjDataTable = new DataTable();

            YouCom.DTO.RegionDTO        theRegionDTO;
            List <YouCom.DTO.RegionDTO> collRegion = new List <RegionDTO>();

            if (YouCom.DAL.RegionDAL.getListadoRegion(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    theRegionDTO          = new RegionDTO();
                    theRegionDTO.IdRegion = wobjDataRow["idRegion"] != null?decimal.Parse(wobjDataRow["idRegion"].ToString()) : 0;

                    theRegionDTO.NombreRegion      = wobjDataRow["nombreRegion"] != null ? wobjDataRow["nombreRegion"].ToString() : string.Empty;
                    theRegionDTO.DescripcionRegion = wobjDataRow["descripcionRegion"] != null ? wobjDataRow["descripcionRegion"].ToString() : string.Empty;

                    PaisDTO myPaisDTO = new PaisDTO();
                    myPaisDTO.IdPais = wobjDataRow["idPais"] != null?decimal.Parse(wobjDataRow["idPais"].ToString()) : 0;

                    myPaisDTO.NombrePais    = wobjDataRow["nombrePais"] != null ? wobjDataRow["nombrePais"].ToString() : string.Empty;
                    theRegionDTO.ThePaisDTO = myPaisDTO;

                    theRegionDTO.UsuarioIngreso      = wobjDataRow["usuario_ingreso"] != null ? wobjDataRow["usuario_ingreso"].ToString() : string.Empty;
                    theRegionDTO.FechaIngreso        = wobjDataRow["fecha_ingreso"] != null ? wobjDataRow["fecha_ingreso"].ToString() : string.Empty;
                    theRegionDTO.UsuarioModificacion = wobjDataRow["usuario_modificacion"] != null ? wobjDataRow["usuario_modificacion"].ToString() : string.Empty;
                    theRegionDTO.FechaModificacion   = wobjDataRow["fecha_modificacion"] != null ? wobjDataRow["fecha_modificacion"].ToString() : string.Empty;
                    theRegionDTO.Estado = wobjDataRow["estado"] != null ? wobjDataRow["estado"].ToString() : string.Empty;


                    collRegion.Add(theRegionDTO);
                }
            }
            return(collRegion);
        }
        private void AddEditProperty_BasePost(Connector connector, PropertyDTO property)
        {
            RegionBLL   regionBLL   = new RegionBLL(connector);
            ProvinceBLL provinceBLL = new ProvinceBLL(connector);
            DistrictBLL districtBLL = new DistrictBLL(connector);
            CountryDTO  country     = property.Country;
            RegionDTO   region      = property.Region;
            ProvinceDTO province    = property.Province;
            DistrictDTO district    = property.District;

            if (country != null)
            {
                country.Regions = regionBLL.ReadByCountry(country.Id);
                if (region != null)
                {
                    region.Country = country;
                }
                if (province != null)
                {
                    province.Country = country;
                }
                if (district != null)
                {
                    district.Country = country;
                }
            }
            if (region != null)
            {
                region.Provinces = provinceBLL.ReadByCountryAndRegion(country.Id, region.Code);
            }
            if (province != null)
            {
                province.Districts = districtBLL.ReadByCountryAndRegionAndProvince(country.Id, region.Code, province.Code);
            }
        }
        /// <summary>
        /// Returns a single country dimension
        /// </summary>
        /// <returns></returns>
        public RegionDTO GetRegionDimension(int ID)
        {
            SQLAzure.DbConnection dbConn = new SQLAzure.DbConnection(_connectionString);
            RegionDTO             region = new RegionDTO();

            try
            {
                dbConn.Open();

                SQLAzure.RetryLogic.DbCommand dbComm = new SQLAzure.RetryLogic.DbCommand(dbConn);
                dbComm.CommandText = "SELECT ID, Region FROM DimRegion WHERE ID = @ID";

                dbComm.Parameters.Add(new SqlParameter("ID", ID));

                System.Data.IDataReader rdr = dbComm.ExecuteReader(System.Data.CommandType.Text);

                while (rdr.Read())
                {
                    region.ID     = Convert.ToInt32(rdr["ID"]);
                    region.Region = rdr["Region"].ToString();
                }
            }
            catch (SqlException)
            {
                throw;
            }
            finally
            {
                dbConn.Close();
            }

            return(region);
        }
Example #18
0
        public List <RegionDTO> GetAllRegiones()
        {
            con.Open();

            SqlCommand    cmd = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "SELECT * FROM REGION";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            reader          = cmd.ExecuteReader();

            List <RegionDTO> retorno = new List <RegionDTO>();

            while (reader.Read())
            {
                RegionDTO item = new RegionDTO();
                item.IdRegion    = (reader["IdRegion"] != DBNull.Value) ? Convert.ToInt32(reader["IdRegion"]) : 0;
                item.Descripcion = (reader["Descripcion"] != DBNull.Value) ? reader["Descripcion"].ToString() : string.Empty;
                item.Estado      = (reader["Estado"] != DBNull.Value) ? Convert.ToInt32(reader["Estado"]) : 0;
                retorno.Add(item);
            }
            reader.Close();
            con.Close();
            return(retorno);
        }
        /// <summary>
        /// Creates a region within the dimension table
        /// </summary>
        /// <param name="region"></param>

        public bool CreateRegionDimension(RegionDTO region)
        {
            bool Success = false;

            SQLAzure.DbConnection dbConn = new SQLAzure.DbConnection(_connectionString);

            try
            {
                string query = @"IF NOT EXISTS (SELECT Region from DimRegion WHERE Region = @Region)
                                    INSERT INTO DimRegion (Region) VALUES (@Region)";

                dbConn.Open();

                SQLAzure.RetryLogic.DbCommand dbComm = new SQLAzure.RetryLogic.DbCommand(dbConn);
                dbComm.CommandText = query;

                dbComm.Parameters.Add(new SqlParameter("Region", region.Region));

                dbComm.ExecuteNonQuery(System.Data.CommandType.Text);

                Success = true;
            }
            catch (SqlException)
            {
                throw;
            }
            finally
            {
                dbConn.Close();
            }

            return(Success);
        }
        /// <summary>
        /// Updates a region record within the dimension table
        /// </summary>
        /// <param name="region"></param>
        public bool UpdateRegionDimension(RegionDTO region)
        {
            bool Success = true;

            SQLAzure.DbConnection dbConn = new SQLAzure.DbConnection(_connectionString);

            try
            {
                string query = @"UPDATE DimRegion SET Region = @Region WHERE ID = @ID";
                dbConn.Open();

                SQLAzure.RetryLogic.DbCommand dbComm = new SQLAzure.RetryLogic.DbCommand(dbConn);
                dbComm.CommandText = query;

                dbComm.Parameters.Add(new SqlParameter("ID", region.ID));
                dbComm.Parameters.Add(new SqlParameter("Region", region.Region));

                dbComm.ExecuteNonQuery(System.Data.CommandType.Text);

                Success = true;
            }
            catch (SqlException)
            {
                throw;
            }
            finally
            {
                dbConn.Close();
            }

            return(Success);
        }
Example #21
0
        public async Task <OutputResponse> Update(RegionDTO region)
        {
            var regionToUpdate = await _context.Regions.FirstOrDefaultAsync(x => x.RegionId.Equals(region.RegionId));

            if (regionToUpdate == null)
            {
                return(new OutputResponse
                {
                    IsErrorOccured = true,
                    Message = "Region specified does not exist, update cancelled"
                });
            }

            //update region details
            regionToUpdate.RegionName   = region.RegionName;
            regionToUpdate.Longitude    = region.Longitude;
            regionToUpdate.Latitude     = region.Latitude;
            regionToUpdate.RowAction    = "U";
            regionToUpdate.ModifiedBy   = region.CreatedBy;
            regionToUpdate.DateModified = DateTime.UtcNow.AddHours(2);

            await _context.SaveChangesAsync();

            return(new OutputResponse
            {
                IsErrorOccured = false,
                Message = MessageHelper.UpdateSuccess
            });
        }
Example #22
0
        public async Task <OutputResponse> Add(RegionDTO region)
        {
            var isFound = await _context.Regions.AnyAsync(x => x.RegionName.ToLower() == region.RegionName.ToLower());

            if (isFound)
            {
                return(new OutputResponse
                {
                    IsErrorOccured = true,
                    Message = "Region name already exist, duplicates not allowed"
                });
            }

            var mappedRegion = new AutoMapperHelper <RegionDTO, Regions>().MapToObject(region);

            mappedRegion.RowAction   = "I";
            mappedRegion.DateCreated = DateTime.UtcNow.AddHours(2);

            await _context.Regions.AddAsync(mappedRegion);

            await _context.SaveChangesAsync();

            return(new OutputResponse
            {
                IsErrorOccured = false,
                Message = MessageHelper.AddNewSuccess
            });
        }
Example #23
0
        public static bool ValidaEliminacionRegion(RegionDTO theRegionDTO, ref DataTable pobjDatable)
        {
            bool retorno = false;

            YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper();



            wobjSQLHelper.SetParametro("@IdRegion", SqlDbType.VarChar, 20, theRegionDTO.IdRegion);

            try
            {
                //====================================================================================
                if (wobjSQLHelper.Ejecutar("validaEliminacionRegion", "YouCom", pobjDatable) <= 0)
                {
                    retorno = true;
                }
                else
                {
                    retorno = false;
                }
                //====================================================================================
            }
            catch (Exception eobjException)
            {
                throw eobjException;
            }
            return(retorno);
        }
Example #24
0
    private void Delete()
    {
        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Delete))
        {
            return;
        }

        if (ValidateValues() == false)
        {
            return;
        }
        bool bActionCompleted = false;
        int  Id = 0;

        int.TryParse(hfId.Value, out Id);
        if (Id == 0)
        {
            lblStatus.Text = "Please click on edit button again.";
            return;
        }

        RegionDTO oRegionData = new RegionDTO();

        oRegionData.RegionId = Id;
        RegionMaster oRegionMaster = new RegionMaster();

        /*
         * ADDED BY VIJAY
         * CHECK IF THE REGION WHICH IS TO BE DELETED HAS ANY ASSOCIATED RECORDS...IF YES, MOVE OUT OF THE FUNCTION ELSE PROCEED
         * IF THE OUTPUT OF sMessage IS "", THEN RECORD CAN BE DELETED, ELSE NOT
         *
         */
        string sMessage = "";

        GF.HasRecords(Convert.ToString(Id), "region", out sMessage);
        if (sMessage != "")
        {
            base.DisplayAlert(sMessage);
            btnDelete.Enabled = true;
        }
        else
        {
            bActionCompleted = oRegionMaster.Delete(oRegionData);

            if (bActionCompleted == true)
            {
                base.DisplayAlert("The record has been deleted successfully");
                txtRegionName.Text = "";
                //lblStatus.Text = "Deleted";
                RefreshGrid();
            }
            else
            {
                base.DisplayAlert("Error Occured while deletion: Please refer to the error log.");
            }
        }
        oRegionData   = null;
        oRegionMaster = null;
    }
Example #25
0
        public void MapFromDomainEntity_NullContent_ReturnNull()
        {
            //Act
            var response = RegionDTO.MapFromDatabaseEntity(null);

            //Assert
            Assert.IsNull(response);
        }
        public async Task <IServiceResponse <bool> > AddRegion(RegionDTO region)
        {
            return(await HandleApiOperationAsync(async() => {
                await _regionService.AddRegion(region);

                return new ServiceResponse <bool>(true);
            }));
        }
Example #27
0
        public async Task AddRegionAsync(RegionDTO region)
        {
            var newRegion = _mapper.Map <RegionDTO, DataAccessCity.Region>(region);

            await _repoWrapper.Region.CreateAsync(newRegion);

            await _repoWrapper.SaveAsync();
        }
        public async Task <IServiceResponse <bool> > UpdateRegion(int id, RegionDTO region)
        {
            return(await HandleApiOperationAsync(async() => {
                await _regionService.UpdateRegion(id, region);

                return new ServiceResponse <bool>(true);
            }));
        }
Example #29
0
        /// <summary>
        /// Returns the corresponding DTO object
        /// </summary>
        /// <returns></returns>
        public RegionDTO GetDTO()
        {
            RegionDTO ad = new RegionDTO();

            ad.Region = Region;
            ad.ID     = ID;

            return(ad);
        }
 public IActionResult Create([Bind("Name,Id")] RegionDTO regionDTO)
 {
     if (ModelState.IsValid)
     {
         _regionApp.Insert(regionDTO);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(regionDTO));
 }
Example #31
0
    protected void rptRegion_OnItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Editar")
        {
            HiddenField hdnTipoSistema = new HiddenField();
            hdnTipoSistema = (HiddenField)e.Item.FindControl("HdnTipoSistema");

            HiddenField hdnDescripcion = new HiddenField();
            hdnDescripcion = (HiddenField)e.Item.FindControl("hdnDescripcion");

            HiddenField hdnPais = new HiddenField();
            hdnPais = (HiddenField)e.Item.FindControl("hdnIdPais");

            ddlPais.SelectedValue = hdnPais.Value;
            HidIdRegion.Value     = hdnTipoSistema.Value;
            txtRegion.Text        = hdnDescripcion.Value;
            btnGrabar.Visible     = false;
            btnEditar.Visible     = true;
        }
        if (e.CommandName == "Eliminar")
        {
            HiddenField hdnTipoSistema = new HiddenField();
            hdnTipoSistema = (HiddenField)e.Item.FindControl("HdnTipoSistema");

            HiddenField hdnDescripcion = new HiddenField();
            hdnDescripcion = (HiddenField)e.Item.FindControl("hdnDescripcion");

            RegionDTO theRegionDTO = new RegionDTO();
            theRegionDTO.IdRegion            = decimal.Parse(hdnTipoSistema.Value);
            theRegionDTO.UsuarioModificacion = myUsuario.Rut;

            bool validacionIntegridad = YouCom.bll.RegionBLL.ValidaEliminacionRegion(theRegionDTO);
            if (validacionIntegridad)
            {
                string script = "alert(' No es posible eliminar una Region con Localidad Asociadas.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                return;
            }
            else
            {
                bool respuesta = YouCom.bll.RegionBLL.Delete(theRegionDTO);
                if (respuesta)
                {
                    cargarRegiones();
                    if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                    {
                        string script = "alert('Region Eliminado correctamente.');";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    }
                }
                else
                {
                }
            }
        }
    }
 private RegionDTO Map(tblRegion tbl)
 {
     var dto = new RegionDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.Name,
                       Description = tbl.Description,
                       CountryMasterId = tbl.Country
                   };
     return dto;
 }
Example #33
0
 public Region Map(RegionDTO dto)
 {
     if (dto == null) return null;
     var region = Mapper.Map<RegionDTO, Region>(dto);
     region.Country = _countryRepository.GetById(dto.CountryMasterId);
     return region;
 }