terça-feira, 21 de julho de 2015

ViewAplicacao

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Lapuinka.Security.Entities;
using Lapuinka.Security.Utils;
using System.Web.UI;

namespace Lapuinka.Security.Web.ViewController
{
    public class ViewAplicacao : Page
    {
        private String nameSession { get { return "AplicacaoSession"; } }

        public struct DomainView
        {
            public List Lista;
            public Helper.TipoOrdenacao TipoOrdenacao { get; set; }
            public Int32 IDToEdit { get; set; }
            public Boolean IsBack { get; set; }
        }

        public Boolean ViewIsNull
        {
            get
            {
                return Session[nameSession] == null;
            }
        }

        public DomainView GetView()
        {
            Object[] aux = (Object[])Session[nameSession];

            if (aux == null) throw new Exception();

            return new DomainView()
            {
                Lista = (List)aux[0],
                TipoOrdenacao = (Helper.TipoOrdenacao)aux[1],
                IDToEdit = (Int32)aux[2],
                IsBack = (Boolean)aux[3],
            };
        }

        public void SetView(DomainView param)
        {
            Session[nameSession] = null;
            Session[nameSession] = new Object[]
                                  {
                                    param.Lista,
                                    param.TipoOrdenacao,
                                    param.IDToEdit,
                                    param.IsBack
                                  };
        }
    }

}


Postar um comentário