Ejemplo n.º 1
0
        protected virtual IEnumerable <IToolbaritem> GenerarNavegadorRegistros(IGestionService service, TipoOperacion operacion, IModelView model)
        {
            var result     = new List <IToolbaritem>();
            var actionView = operacion == TipoOperacion.Editar && CanModificar ? "Edit" : "Details";

            var firstId = service.FirstRegister();

            result.Add(new ToolbarActionModel()
            {
                Icono               = "fa fa-step-backward",
                Texto               = General.LblPrimero,
                Url                 = string.IsNullOrEmpty(firstId)? string.Empty: Url.Action(actionView, new { id = firstId }),
                Desactivado         = model.GetPrimaryKey() == firstId || string.IsNullOrEmpty(firstId),
                OcultarTextoSiempre = true
            });

            var prevId = operacion == TipoOperacion.Editar || operacion == TipoOperacion.Ver? service.PreviousRegister(model.GetPrimaryKey()): string.Empty;

            result.Add(new ToolbarActionModel()
            {
                Icono               = "fa fa-caret-left",
                Texto               = General.LblAnterior,
                Url                 = Url.Action(actionView, new { id = prevId }),
                Desactivado         = operacion == TipoOperacion.Alta || string.IsNullOrEmpty(prevId),
                OcultarTextoSiempre = true
            });

            var nextId = operacion == TipoOperacion.Editar || operacion == TipoOperacion.Ver ? service.NextRegister(model.GetPrimaryKey()) : string.Empty;

            result.Add(new ToolbarActionModel()
            {
                Icono               = "fa fa-caret-right",
                Texto               = General.LblSiguiente,
                Url                 = Url.Action(actionView, new { id = nextId }),
                Desactivado         = operacion == TipoOperacion.Alta || string.IsNullOrEmpty(nextId),
                OcultarTextoSiempre = true
            });

            var lastId = service.LastRegister();

            result.Add(new ToolbarActionModel()
            {
                Icono               = "fa fa-step-forward",
                Texto               = General.LblUltimo,
                Url                 = string.IsNullOrEmpty(lastId) ? string.Empty : Url.Action(actionView, new { id = lastId }),
                Desactivado         = model.GetPrimaryKey() == lastId || string.IsNullOrEmpty(lastId),
                OcultarTextoSiempre = true
            });

            return(result);
        }