Index: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/FilterModel.cs
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/FilterModel.cs	(revision 6303)
+++ branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/FilterModel.cs	(revision 6303)
@@ -0,0 +1,368 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using HLWebOKBQueryPlugin.OKBQueryService;
+using HLWebOKBQueryPlugin.Helpers;
+using HLWebOKBQueryPlugin.ViewModels;
+using System.ComponentModel.DataAnnotations;
+
+namespace HLWebOKBQueryPlugin.Models
+{
+    /// <summary>
+    /// Model for Filter Data.
+    /// Current Filters (selected),
+    /// and available Filters. 
+    /// </summary>
+    public class FilterModel
+    {
+
+
+
+        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"; } }
+        public static string ComparisonDropDownList { get { return "comparisonDropDownList"; } }
+
+        [Required(ErrorMessage = "Field is required!")]
+        [StringLength(50, ErrorMessage = "Maximum 50 characters allowed!")]
+        public string IntValue { get; set; }
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        public FilterModel()
+        {
+
+        }
+
+        public FilterModel(CombinedFilter filter)
+        {
+            Content = filter;
+        }
+
+        /// <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 static List<ComparisonItem> BoolComparisons
+        {
+            get { return ComparisonsHelper.boolComparisons; }
+        }
+
+        public static List<ComparisonItem> OrdinalComparisons
+        {
+            get { return ComparisonsHelper.ordinalComparisons; }
+        }
+
+        public static List<ComparisonItem> StringComparisons
+        {
+            get { return ComparisonsHelper.stringComparisons; }
+        }
+
+
+
+
+        /// <summary>
+        /// Available Filters
+        /// </summary>
+        public List<Filter> AvailableFilters
+        {
+            get
+            {
+                QueryServiceClient client = Query.GetClientFactory("okbtester", "okbtester");
+                Filter[] filters = client.GetFilters();
+
+                if (filters == null)
+                {
+                    return new List<Filter>();
+                }
+                return filters.ToList<Filter>();
+            }
+        }
+
+
+        /// <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;
+                                    IntValue = kvp.Value;
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((StringComparisonFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("NameStringComparisonFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    ((NameStringComparisonFilter)f).Value = kvp.Value;
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((NameStringComparisonFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("StringComparisonAvailableValuesFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    ((StringComparisonAvailableValuesFilter)f).Value = kvp.Value;
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((StringComparisonAvailableValuesFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("NameStringComparisonAvailableValuesFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    ((NameStringComparisonAvailableValuesFilter)f).Value = kvp.Value;
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((NameStringComparisonAvailableValuesFilter)f).Comparison = ComparisonsHelper.GetStringComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("NameEqualityComparisonByteArrayFilter".Equals(f.GetType().Name))
+                            {
+                                //TODO not supported
+                            }
+                            else if ("NameEqualityComparisonBoolFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueDropDownList))
+                                {
+                                    ((NameEqualityComparisonBoolFilter)f).Value = Boolean.Parse(kvp.Value);
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((NameEqualityComparisonBoolFilter)f).Comparison = ComparisonsHelper.GetEqualityComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("NameOrdinalComparisonIntFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    try
+                                    {
+                                        ((NameOrdinalComparisonIntFilter)f).Value = Int32.Parse(kvp.Value);
+                                    }
+                                    catch (Exception)
+                                    {
+                                        //TOOD Fehler ausgeben
+                                    }
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((NameOrdinalComparisonIntFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("NameOrdinalComparisonLongFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    try
+                                    {
+                                        ((NameOrdinalComparisonLongFilter)f).Value = Int64.Parse(kvp.Value);
+                                    }
+                                    catch (Exception)
+                                    {
+                                        //TOOD Fehler ausgeben
+                                    }
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((NameOrdinalComparisonLongFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("NameOrdinalComparisonFloatFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    try
+                                    {
+                                        ((NameOrdinalComparisonFloatFilter)f).Value = float.Parse(kvp.Value);
+                                    }
+                                    catch (Exception)
+                                    {
+                                        //TOOD Fehler ausgeben
+                                    }
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((NameOrdinalComparisonFloatFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("OrdinalComparisonDateTimeFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    try
+                                    {
+                                        ((OrdinalComparisonDateTimeFilter)f).Value = DateTime.Parse(kvp.Value);
+                                    }
+                                    catch (Exception)
+                                    {
+                                        //TOOD Fehler ausgeben
+                                    }
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((OrdinalComparisonDateTimeFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value);
+                                }
+                            }
+                            else if ("NameOrdinalComparisonDoubleFilter".Equals(f.GetType().Name))
+                            {
+                                if (kvp.Key.Equals(FilterModel.ValueTextbox))
+                                {
+                                    try
+                                    {
+                                        ((NameOrdinalComparisonDoubleFilter)f).Value = Double.Parse(kvp.Value);
+                                    }
+                                    catch (Exception)
+                                    {
+                                        //TOOD Fehler ausgeben
+                                    }
+                                }
+                                else if (kvp.Key.Equals(FilterModel.ComparisonDropDownList))
+                                {
+                                    ((NameOrdinalComparisonDoubleFilter)f).Comparison = ComparisonsHelper.GetOrdinalComparisonForValue(kvp.Value);
+                                }
+                            }
+
+
+                            else
+                            {
+                                // To this for all filters
+                            }
+
+
+                        }
+
+
+                    }
+                }
+            }
+        }
+    }
+}
Index: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/QueryModel.cs
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/QueryModel.cs	(revision 6253)
+++ branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/QueryModel.cs	(revision 6303)
@@ -8,8 +8,12 @@
 using HLWebOKBQueryPlugin.Helpers;
 
-namespace HLWebPluginHost.Models {
+namespace HLWebOKBQueryPlugin.Models
+{
     public class QueryModel {
 
         public String SelectedSubMenu { get; set; }
+        private long[] runs;
+
+
 
         public IList<Filter> QueryFilterGetAll() {
@@ -41,26 +45,61 @@
         }
 
+
+        public long[] Runs
+        {
+            get
+            {
+                return this.runs;
+            }
+            set
+            {
+                this.runs = value;
+            }
+
+        }
+
+
+        public IList<RunCollectionData> RunCollection
+        {
+            get
+            {
+                QueryServiceClient client = Query.GetClientFactory();
+                if (client != null)
+                {
+                    IList<RunCollectionData> runCollection = new List<RunCollectionData>();
+
+                    IList<Run> runList = client.GetRuns(runs, false).ToList<Run>();
+
+                    foreach (Run r in runList)
+                        runCollection.Add(new RunCollectionData(r));
+
+                    return runCollection;
+                }
+                return new List<RunCollectionData>();
+            }
+        }
+
         // just 4 testing
-        public IList<RunCollectionData> getTestRuns() {
+        //public IList<RunCollectionData> getTestRuns() {
 
-            QueryServiceClient client = Query.GetClientFactory();
+        //    QueryServiceClient client = Query.GetClientFactory();
 
-            if (client != null) {
-                IList<RunCollectionData> runs = new List<RunCollectionData>();
+        //    if (client != null) {
+        //        IList<RunCollectionData> runs = new List<RunCollectionData>();
 
-                //long[] runIds = client.GetRunIds(new Filter());
-                //if (runIds.Length < cnt) cnt = runIds.Length;
+        //        //long[] runIds = client.GetRunIds(new Filter());
+        //        //if (runIds.Length < cnt) cnt = runIds.Length;
 
-                long[] getRuns = new long[2] { 1, 2 };
+        //        long[] getRuns = new long[2] { 1, 2 };
 
-                IList<Run> runList = client.GetRuns(getRuns, false).ToList<Run>();
+        //        IList<Run> runList = client.GetRuns(getRuns, false).ToList<Run>();
 
-                foreach (Run r in runList)
-                    runs.Add(new RunCollectionData(r));
+        //        foreach (Run r in runList)
+        //            runs.Add(new RunCollectionData(r));
 
-                return runs;
-            }
-            return new List<RunCollectionData>();
-        }
+        //        return runs;
+        //    }
+        //    return new List<RunCollectionData>();
+        //}
 
     }
