// Edicíón de tipos documento
        // GET
        public async Task<ActionResult> EditarTipoDocumento(int? ID)
        {

            if (ID == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            //set _entity
            var _enitity = await _context.TIPOSDOCUMENTO.FindAsync(ID);
            

            // si es nulo
            if (_enitity == null)
            {
                return HttpNotFound();
            }

            // set model
            var _model = new TIPOSDOCUMENTOMODEL
            {
                ID = _enitity.ID,
                NOMBRETIPO = _enitity.NOMBRETIPO,
                DESCRIPCION = _enitity.DESCRIPCION
            };

            // to view
            return View(_model);
        }
        public async Task<ActionResult> EditarTipoDocumento(TIPOSDOCUMENTOMODEL _model)
        {
            if (ModelState.IsValid)
            {
                // veriifcar el nombre no se repita
                if (_context.TIPOSDOCUMENTO.SingleOrDefault(d => d.NOMBRETIPO == _model.NOMBRETIPO && d.ID != _model.ID) != null)
                {
                    ModelState.AddModelError("", "El nombre de este tipo de documento ya existe, por favor elija otro ");
                    return View(_model);
                }
                else
                {
                    try
                    {

                        // get entity
                        var _entity = new TIPOSDOCUMENTO();
                        _entity = await _context.TIPOSDOCUMENTO.FindAsync(_model.ID);                        
                            _entity.NOMBRETIPO = _model.NOMBRETIPO;
                            _entity.DESCRIPCION = _model.DESCRIPCION;
                        
                        // guardar el registro
                            _context.Entry(_entity).State = EntityState.Modified;
                            await _context.SaveChangesAsync();

                        // redireccionar al índice
                        return RedirectToAction("TiposDocumentos", "Configuraciones");

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }

            }
            return View(_model);
        }
 // nuevo tipo documento
 // GET
 public ActionResult NuevoTipoDucumento()
 {
     // set model
     var _model = new TIPOSDOCUMENTOMODEL();
     return View(_model);
 }