Index: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs	(revision 6165)
+++ branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs	(revision 6170)
@@ -35,4 +35,6 @@
         }
 
+
+
         public ActionResult Filters(CombinedFilter f)
         {
@@ -50,12 +52,10 @@
         /// <returns></returns>
         public ActionResult AddFilterAnd(FormCollection collection)
-        {
-            Response.Write("AddFilterAnd");
-
-            CombinedFilter content = (CombinedFilter)Session["Content"];
-            FilterModel fm = new FilterModel(content);
-
-            
-
+        {       
+            FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]);
+
+
+            // Add Filter
+            
             String idKey = null;
             String parentIdKey = null;
@@ -63,9 +63,9 @@
             foreach (string key in collection.AllKeys)
             {
-                if (key.StartsWith("filtersCombobox"))
+                if (key.StartsWith(FilterModel.ComboboxName))
                 {
                     idKey = key;
                 }
-                if (key.StartsWith("parentId"))
+                if (key.StartsWith(FilterModel.ParentIdName))
                 {
                     parentIdKey = key;
@@ -75,18 +75,6 @@
             Guid parentId = new Guid(collection.Get(parentIdKey));
             string filterTypeName = collection.Get(idKey);
-
-            // get selected filter (combobox)
-            Filter filter = fm.Filters.Where(x => x.FilterTypeName.Equals(filterTypeName)).FirstOrDefault();
-
-
-
-            // find the partent filterr
-            List<Filter> orFilters = content.Filters.ToList<Filter>(); ;
-            CombinedFilter parent = (CombinedFilter)orFilters.Where(e => e.Id.Equals(parentId)).FirstOrDefault();
-
-            // remove
-            orFilters.Remove(parent);
-
-            List<Filter> filterList = parent.Filters.ToList<Filter>();
+            fm.AddFilter(filterTypeName, parentId);
+
 
 
@@ -102,5 +90,5 @@
             {
 
-                if (!key.StartsWith("filtersCombobox") && !key.StartsWith("parentId"))
+                if (!key.StartsWith(FilterModel.ComboboxName) && !key.StartsWith(FilterModel.ParentIdName))
                 {
                     int idx = key.IndexOf(".");
@@ -124,50 +112,10 @@
             }
 
-
-            // Set values for the existing Filters
-            foreach (Filter f in filterList)
-            {
-
-                Dictionary<string, string> dict = postValues.Where(x => x.Key.Equals(f.Id)).FirstOrDefault().Value;
-                if (dict != null)
-                {
-                    foreach (KeyValuePair<string, string> kvp in dict)
-                    {
-                        if ("StringComparisonFilter".Equals(f.GetType().Name))
-                        {
-                            if (kvp.Key.Equals("valueTextbox"))
-                            {
-                                ((StringComparisonFilter)f).Value = kvp.Value;
-                            }
-
-                        }
-                        else
-                        {
-                            // To this for all filters
-                        }
-                    }
-                }
-
-            }
-
-
-            // Add the new filter
-            filterList.Add(filter);
-            Response.Write("addx:" + filter.Id);  
-
-            parent.Filters = filterList.ToArray<Filter>();
-
-            // Add the current filter (AND)
-            orFilters.Add(parent);
-
-            content.Filters = orFilters.ToArray<Filter>();
-
-
-
-            Response.Write("content add:" + content.Filters[0].Id);
+            // Update filters with posted data
+            fm.UpdateWithPostValues(postValues);
 
 
             // Set Content
-            Session["Content"] = content;
+            Session["Content"] = fm.Content;
 
 
@@ -177,21 +125,21 @@
 
 
+
+
+        /// <summary>
+        /// Delete a filter with given id.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
         public ActionResult DeleteFilter(Guid id)
         {
-            //Response.Write("Delete id:" + id);
-
-            CombinedFilter masterFilter = (CombinedFilter)Session["Content"];
-
-            Response.Write("content del:" + masterFilter.Filters[0].Id);
-
-            FilterModel fm = new FilterModel(masterFilter);  
-            RemoveFilterFromFilterModel(fm, id);
-                 
-            masterFilter.Filters = ((CombinedFilter)fm.Content).Filters.ToArray<Filter>();
-            
+            // Get Content from Session
+            FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]);  
+            
+            // Remove Filter
+           bool filterRemoved =  fm.RemoveFilter(id);
+        
             // Set Content
-            Session["Content"] = masterFilter;
-
-         //   Response.Write("Delete id3:" + masterFilter.Filters.Length);
+            Session["Content"] = fm.Content;
            
             return View("Index", fm);
@@ -199,30 +147,4 @@
 
 
-        private Filter GetFilterForId(Filter [] activeFilters, Guid id)
-        {
-            foreach (Filter f in activeFilters)
-            {
-                Response.Write(f.Id + " " + id);
-
-                if (f.Id.Equals(id))
-                {
-                    return f;
-                }
-            }
-            return null;
-        }
-
-        private FilterModel RemoveFilterFromFilterModel(FilterModel fm, Guid id)
-        {
-            Response.Write("content :" + fm.Content.Id);
-            Filter filterToRemove = GetFilterForId(fm.Content.Filters, id);
-            if (filterToRemove != null)
-            {
-                Response.Write("rrrrr:" + id);
-                fm.Filters.Remove(filterToRemove);
-            }
-
-            return fm;
-        }
 
 
@@ -233,17 +155,14 @@
         public ActionResult AddFilterOr()
         {
-
-
-            CombinedFilter content = (CombinedFilter)Session["Content"];
-            FilterModel fm = new FilterModel(content);
-
-            List<Filter> orFilters = content.Filters.ToList<Filter>(); ;
-
-            CombinedFilter andFilter = fm.Filters.OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault();
+            FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]);
+
+            List<Filter> orFilters = fm.Content.Filters.ToList<Filter>(); ;
+
+            CombinedFilter andFilter = fm.AvailableFilters.OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault();
             orFilters.Add(andFilter);
-            content.Filters = orFilters.ToArray<Filter>();
-
-
-            Session["Content"] = content;
+            fm.Content.Filters = orFilters.ToArray<Filter>();
+
+
+            Session["Content"] = fm.Content;
 
             return View("Index", fm);
@@ -272,6 +191,6 @@
             {
                 // Add first Filter 
-                CombinedFilter orFilter = fm.Filters.OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.Or).FirstOrDefault();
-                CombinedFilter andFilter = fm.Filters.OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault();
+                CombinedFilter orFilter = fm.AvailableFilters.OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.Or).FirstOrDefault();
+                CombinedFilter andFilter = fm.AvailableFilters.OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault();
                 orFilter.Filters = new Filter[] { andFilter }; // 1st filter
 
Index: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/ViewModels/FilterModel.cs
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBQueryPlugin/ViewModels/FilterModel.cs	(revision 6165)
+++ branches/WebApplication/MVC2/HLWebOKBQueryPlugin/ViewModels/FilterModel.cs	(revision 6170)
@@ -15,25 +15,14 @@
     public class FilterModel
     {
-        private  List<bool> boolStates;
 
-        private List<Filter> _filters;
-
-        //public KeyValuePair<int,Filter> ParentFilter { get; set; }
-        public List<Filter> Filters
-        {
-
-            get
-            {
-                QueryServiceClient client = Query.GetClientFactory("okbtester", "okbtester");
-                return client.GetFilters().ToList<Filter>(); /// => won't work
-            }
-        
-
-        }
-        //public Dictionary<int,Filter> SelectedFilters { get; set; }
-        // use an unique id for reach filter "Control"
-        public CombinedFilter Content { get; set; }
+        public static string ComboboxName { get { return "filtersCombobox"; } }
+        public static string ParentIdName { get { return "parentId"; } }
+        public static string ValueTextbox { get { return "valueTextbox"; } }
+        public static string ValueDropDownList { get { return "valueDropDownList"; } }
 
 
+        /// <summary>
+        /// Constructor
+        /// </summary>
         public FilterModel()
         {
@@ -44,19 +33,156 @@
         {
             Content = filter;
-            //filter.i
+        }
+
+        /// <summary>
+        /// Get Bool States.
+        /// </summary>
+        public List<Boolean> BoolStates
+        {
+            get
+            {
+                List<Boolean> boolStates = new List<Boolean>();
+
+                boolStates = new List<Boolean>();
+                boolStates.Add(true);
+                boolStates.Add(false);
+
+                return boolStates;
+            }
         }
 
 
-        public List<Boolean> GetBoolStates()
+        /// <summary>
+        /// Available Filters
+        /// </summary>
+        public List<Filter> AvailableFilters
         {
-            if (boolStates == null)
+            get
             {
-                boolStates = new List<Boolean>();
-                boolStates.Add(true);
-                boolStates.Add(false);
+                QueryServiceClient client = Query.GetClientFactory("okbtester", "okbtester");
+                return client.GetFilters().ToList<Filter>();
             }
-            return boolStates;
         }
 
+
+        /// <summary>
+        /// Available Filters without AND and OR.
+        /// </summary>
+        public List<Filter> AvailableFilterForCombobox
+        {
+            get
+            {
+                List<Filter> filters = AvailableFilters;
+
+                filters.Remove(filters.OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.Or).FirstOrDefault());
+                filters.Remove(filters.OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault());
+
+                return filters;
+            }
+        }
+
+        /// <summary>
+        /// Content
+        /// </summary>
+        public CombinedFilter Content { get; set; }
+
+      
+
+        /// <summary>
+        /// Delete a filter with given id.
+        /// </summary>
+        /// <param name="id">filter id</param>
+        internal bool RemoveFilter(Guid id)
+        {
+            bool removed = false;
+            List<Filter> orFilters = Content.Filters.ToList<Filter>();
+
+            foreach (CombinedFilter f in orFilters)
+            {
+                Filter deleteFilter = f.Filters.Where(x => x.Id == id).FirstOrDefault();
+                if (deleteFilter != null)
+                {
+                    List<Filter> masterFilters = f.Filters.ToList<Filter>();
+                    masterFilters.Remove(deleteFilter);
+                    f.Filters = masterFilters.ToArray<Filter>();
+                    removed = true;
+                    break;
+                }
+            }
+
+            Content.Filters = orFilters.ToArray<Filter>();
+            return removed;
+        }
+
+        /// <summary>
+        /// Add a new filters
+        /// </summary>
+        /// <param name="filterTypeName">type name</param>
+        /// <param name="parentId">parent filter id</param>
+        internal void AddFilter(string filterTypeName, Guid parentId)
+        {
+
+            // get selected filter (combobox)
+            Filter filter = AvailableFilters.Where(x => x.FilterTypeName.Equals(filterTypeName)).FirstOrDefault();
+
+
+            // find the partent filterr
+            List<Filter> orFilters = Content.Filters.ToList<Filter>(); ;
+            CombinedFilter parentFilter = (CombinedFilter)orFilters.Where(e => e.Id.Equals(parentId)).FirstOrDefault();
+
+            // remove
+            orFilters.Remove(parentFilter);
+
+            List<Filter> filterList = parentFilter.Filters.ToList<Filter>();
+
+
+            // Add the new filter
+            filterList.Add(filter);
+            //Response.Write("addx:" + filter.Id);
+
+            parentFilter.Filters = filterList.ToArray<Filter>();
+
+            // Add the current filter (AND)
+            orFilters.Add(parentFilter);
+
+            Content.Filters = orFilters.ToArray<Filter>();
+        }
+
+        /// <summary>
+        /// Update existing filters with posted value
+        /// </summary>
+        /// <param name="parentId">parent filter id</param>
+        /// <param name="postValues">dictionary with posted values</param>
+        internal void UpdateWithPostValues(Dictionary<Guid, Dictionary<string, string>> postValues)
+        {
+            // Set values for the existing Filters
+            foreach (CombinedFilter cf in Content.Filters)
+            {
+                foreach (Filter f in cf.Filters)
+                {
+
+                    Dictionary<string, string> dict = postValues.Where(x => x.Key.Equals(f.Id)).FirstOrDefault().Value;
+                    if (dict != null)
+                    {
+                        foreach (KeyValuePair<string, string> kvp in dict)
+                        {
+                            if ("StringComparisonFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    ((StringComparisonFilter)f).Value = kvp.Value;
+                                }
+                                // To this for alle keys
+
+                            }
+                            else
+                            {
+                                // To this for all filters
+                            }
+                        }
+                    }
+                }
+            }
+        }
     }
 }
Index: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Filters.ascx
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Filters.ascx	(revision 6165)
+++ branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Filters.ascx	(revision 6170)
@@ -3,4 +3,6 @@
 <%@ Import Namespace="HLWebOKBQueryPlugin.OKBQueryService" %>
 <!-- Put all into a form that calls the "AddFilter" Action-->
+<div><table>
+<tr><td>A<br />N<br />D</td><td>
 <p>
     <%
@@ -11,11 +13,10 @@
     <%
   
-        string comboboxName = "filtersCombobox." + currentFilter.Id;
-        string hiddenName = "parentId." + currentFilter.Id;
+        string comboboxName = FilterModel.ComboboxName + "." + currentFilter.Id;
+        string hiddenName = FilterModel.ParentIdName + "." + currentFilter.Id;
     %>
  
-    Select Filter:
     <%: Html.Hidden(hiddenName,currentFilter.Id.ToString()) %>
-    <%: Html.DropDownList(comboboxName, new SelectList(((FilterModel)Model).Filters, "FilterTypeName", "Label"))%>
+    <%: Html.DropDownList(comboboxName, new SelectList(((FilterModel)Model).AvailableFilterForCombobox, "FilterTypeName", "Label"))%>
     <input type="submit" value="+" />
 </p>
@@ -30,5 +31,6 @@
            if (f != null)
            {  %>
-<div>
+
+           <table border="0"><tr><td>
     <%
            
@@ -37,9 +39,7 @@
 {  %>
     <% StringComparisonFilter filter = ((StringComparisonFilter)f); %>
-
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("=") %>
-    <%: Html.TextBox(f.Id + ".valueTextbox", (filter.Value))%>
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%>
+    <%: Html.Label("=")%>
+    <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, (filter.Value))%>
     <% }
 else if ("NameStringComparisonFilter".Equals(f.GetType().Name))
@@ -47,7 +47,6 @@
     <% NameStringComparisonFilter filter = ((NameStringComparisonFilter)f); %>
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("= xxx" + f.Id)%>
-    <%: Html.TextBox(f.Id + ".valueTextbox" + f.Id,  filter.Value )%>
-    <%: Html.ActionLink("-", "DeleteFilter", new { f.Id })%>
+    <%: Html.Label("=" + f.Id)%>
+    <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%>
     <% }
 else if ("StringComparisonAvailableValuesFilter".Equals(f.GetType().Name))
@@ -55,14 +54,12 @@
     <% StringComparisonAvailableValuesFilter filter = ((StringComparisonAvailableValuesFilter)f); %>
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("=")%> 
-    <%: Html.DropDownList(f.Id + ".valueDropDownList", new SelectList(filter.AvailableValues,filter.Value))%>
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%>
-<% }
+    <%: Html.Label("=")%>
+    <%: Html.DropDownList(f.Id + "." + FilterModel.ValueTextbox, new SelectList(filter.AvailableValues, filter.Value))%>
+    <% }
 else if ("NameEqualityComparisonByteArrayFilter".Equals(f.GetType().Name))
 { %>
     <% NameEqualityComparisonByteArrayFilter filter = ((NameEqualityComparisonByteArrayFilter)f); %>
-    <%: Html.Label(filter.Label)%>   
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%>
-<% }  
+    <%: Html.Label(filter.Label)%>
+    <% }
 else if ("NameEqualityComparisonBoolFilter".Equals(f.GetType().Name))
 { %>
@@ -70,68 +67,51 @@
     %>
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("is")%> 
-    <%: Html.DropDownList(f.Id + ".valueDropDownList", new SelectList(((FilterModel)Model).GetBoolStates(),filter.Value)) %>
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%>
-<% }
+    <%: Html.Label("is")%>
+    <%: Html.DropDownList(f.Id + "." + FilterModel.ValueDropDownList, new SelectList(((FilterModel)Model).BoolStates, filter.Value))%>
+    <% }
 else if ("NameOrdinalComparisonIntFilter".Equals(f.GetType().Name))
 { %>
     <% NameOrdinalComparisonIntFilter filter = ((NameOrdinalComparisonIntFilter)f);   %>
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("is")%>    
-
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%>
-<% }
+    <%: Html.Label("is")%>
+    <% }
 else if ("NameStringComparisonAvailableValuesFilter".Equals(f.GetType().Name))
 { %>
     <% NameStringComparisonAvailableValuesFilter filter = ((NameStringComparisonAvailableValuesFilter)f);   %>
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("=")%> 
-    <%: Html.DropDownList(f.Id + ".valueDropDownList", new SelectList(filter.AvailableValues,filter.Value))%>   
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%> 
-<% }
+    <%: Html.Label("=")%>
+    <%: Html.DropDownList(f.Id + "." + FilterModel.ValueDropDownList, new SelectList(filter.AvailableValues, filter.Value))%>
+    <% }
 else if ("NameOrdinalComparisonDoubleFilter".Equals(f.GetType().Name))
 { %>
     <% NameOrdinalComparisonDoubleFilter filter = ((NameOrdinalComparisonDoubleFilter)f);   %>
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("=")%> 
-    <%: Html.TextBox(f.Id + ".valueTextbox" + f.Id,  filter.Value )%>   
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%>
-<% }
+    <%: Html.Label("=")%>
+    <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%>
+    <% }
 else if ("NameOrdinalComparisonFloatFilter".Equals(f.GetType().Name))
 { %>
     <% NameOrdinalComparisonFloatFilter filter = ((NameOrdinalComparisonFloatFilter)f);   %>
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("=")%> 
-    <%: Html.TextBox(f.Id + ".valueTextbox" + f.Id,  filter.Value )%>   
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%>
-<% }  
-    else if ("NameOrdinalComparisonFloatFilter".Equals(f.GetType().Name))
+    <%: Html.Label("=")%>
+    <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%>
+    <% }
+else if ("NameOrdinalComparisonFloatFilter".Equals(f.GetType().Name))
 { %>
     <% NameOrdinalComparisonLongFilter filter = ((NameOrdinalComparisonLongFilter)f);   %>
     <%: Html.Label(filter.Label)%>
-    <%: Html.Label("=")%> 
-    <%: Html.TextBox(f.Id + ".valueTextbox" + f.Id,  filter.Value )%> 
-    <%: Html.ActionLink("-","DeleteFilter",  f.Id )%>  
-<% }                 
+    <%: Html.Label("=")%>
+    <%: Html.TextBox(f.Id + "." + FilterModel.ValueTextbox, filter.Value)%>
+    <% }                 
                   
-       
-    
-    
-     
-    
-    
-    
-    
-else
-{ %>
-    <!-- other types ... must be implemented -->
-    <%: Html.Label(f.GetType().Name)%>
-    <% }
     %>
-</div>
+    <%: Html.ActionLink("remove", "DeleteFilter", new { f.Id })%>
+
+<% }%>
+    </td></tr></table>
+    <% } %>
+ <%  }%>
 <% }
-       }
-   }%>
-<% }
-       
-%>
+      
+%> </td></tr>
+</table></div>
Index: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Index.aspx
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Index.aspx	(revision 6165)
+++ branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Filter/Index.aspx	(revision 6170)
@@ -3,10 +3,12 @@
 <%@ Import Namespace="HLWebOKBQueryPlugin.Models" %>
 <%@ Import Namespace="HLWebOKBQueryPlugin.OKBQueryService" %>
+<asp:Content ID="Content3" runat="server" ContentPlaceHolderID="SubMenuContent">
+   <% Html.RenderAction("Menu","Query"); %>
+</asp:Content>
 <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
-    Index
+    Filter
 </asp:Content>
 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
-    <h2>
-        Filter</h2>
+ 
     <!--
      This is the "user control" for the filters. This will call the action "AddFilter"
Index: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Web.config
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Web.config	(revision 6165)
+++ branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Web.config	(revision 6170)
@@ -7,8 +7,8 @@
 	<configSections>
 	</configSections>
-	<appSettings>
-  <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\temp\chart;" />
- </appSettings>
- <connectionStrings>
+  <appSettings>
+    <add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;"/>
+  </appSettings>
+  <connectionStrings>
 		<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
 	</connectionStrings>
