using System.Collections.Generic; using AyaNova.Biz; using AyaNova.Models; namespace AyaNova.DataList { internal class CustomerNoteDataList : DataListProcessingBase, IDataListInternalCriteria { public CustomerNoteDataList() { DefaultListObjectType = AyaType.CustomerNote; SQLFrom = "from acustomernote left join auser on (acustomernote.userid=auser.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ // //Default ListView // dynamic dlistView = new JArray(); // dynamic cm = new JObject(); // cm.fld = "notedate"; // cm.sort = "-"; // dlistView.Add(cm); // cm = new JObject(); // cm.fld = "notes"; // dlistView.Add(cm); // cm = new JObject(); // cm.fld = "username"; // dlistView.Add(cm); // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); DefaultColumns = new List() { "notedate", "notes", "username" }; DefaultSortBy = new Dictionary() { { "notedate", "-" } }; //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "User", FieldKey = "username", AyaObjectType = (int)AyaType.User, UiFieldDataType = (int)UiFieldDataType.Text, SqlIdColumnName = "auser.id", SqlValueColumnName = "auser.name", IsRowId = false }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "CustomerNoteNotes", FieldKey = "notes", AyaObjectType = (int)AyaType.CustomerNote, UiFieldDataType = (int)UiFieldDataType.Text, SqlIdColumnName = "acustomernote.id", SqlValueColumnName = "acustomernote.notes", IsRowId = true }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "CustomerNoteNoteDate", FieldKey = "notedate", UiFieldDataType = (int)UiFieldDataType.DateTime, SqlValueColumnName = "acustomernote.notedate" }); //META column FieldDefinitions.Add(new DataListFieldDefinition { FieldKey = "metacustomer", UiFieldDataType = (int)UiFieldDataType.InternalId, SqlIdColumnName = "acustomernote.customerid", SqlValueColumnName = "acustomernote.customerid", IsMeta = true }); } public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria) { List ret = new List(); //ClientCriteria MUST be CustomerId if (string.IsNullOrWhiteSpace(clientCriteria)) throw new System.ArgumentNullException("CustomerNoteDataList - ClientCriteria is empty, should be Customer ID"); DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" }; FilterOption.Items.Add(new DataListColumnFilter() { value = clientCriteria, op = DataListFilterComparisonOperator.Equality }); ret.Add(FilterOption); return ret; } }//eoc }//eons