TableItem

Namespace: Azure.Data.Tables
We found 10 examples in language CSharp for this search. You will see 38 fragments of code.
        /// <summary>Tests fixture tear down.</summary>
        [TestFixtureTearDown]
        public void TestFixtureTearDown()
        {
            CsvConfig<TableItem>.Reset();
        }


        public void AddItem(uint chance, String description)
        {
            TableItems.Add(new TableItem(chance, description));
            SetRollsAndTable();
        }

        private void SetRollsAndTable()
        {
            table.Clear();

            uint current = 1;
            foreach (TableItem tableItem in TableItems)
            {
                SetRoll(tableItem, current);
                SetTable(tableItem, current);

                current += tableItem.Chance;
            }
        }

        private void SetTable(TableItem tableItem, uint current)
        {
            for (uint i = 0; i < tableItem.Chance; i++)
            {
                table.Add(current + i, tableItem);
            }
        }

        private void SetRoll(TableItem tableItem, uint current)
        {
            if (tableItem.Chance > 1)
            {
                tableItem.Roll = current + "-" + (current + (tableItem.Chance - 1));
            }
            else
            {
                tableItem.Roll = current + "";
            }
        }


		public void AddStaffGroup()
		{
			if(_staffGroupToAdd == null || _staffGroupTable.Items.Contains(_staffGroupToAdd))
				return;

			_staffGroupTable.Items.Add(new TableItem(_staffGroupToAdd, true, true));
		}

		public void DeleteStaffGroup()
		{
			if(_selectedTableItem == null || !_selectedTableItem.IsNew)
				return;

			TableItem itemToDelete = _selectedTableItem;
			_selectedTableItem = null;
			NotifyPropertyChanged("SelectedTableItem");

			_staffGroupTable.Items.Remove(itemToDelete);
		}

        void AddColumn(IColumn<TableItem> column);
        void RemoveColumn(IColumn<TableItem> column);
        Task OnDeleteItem(TableItem item);
        void EditItem(TableItem item);
        Task SetSelectedItem(TableItem item);
        Task RowClicked(TableItem item);

		[TestFixtureTearDown]
		public void TestFixtureTearDown()
		{
			CsvConfig<TableItem>.Reset();
		}

		[Test]
		public void Can_serialize_custom_headers_map()
		{
			CsvConfig<TableItem>.CustomHeadersMap = new Dictionary<string, string> {
				{"Column1Data", "Column 1"},
				{"Column2Data", "Column 2"},
				{"Column3Data", "Column,3"},
				{"Column4Data", "Column\n4"},
				{"Column5Data", "Column 5"},
			};
			var data = new List<TableItem> {
				new TableItem { Column1Data = "I", Column2Data = "Like", Column3Data = "To", Column4Data = "Read", Column5Data = "Novels" },
				new TableItem { Column1Data = "I am", Column2Data = "Very", Column3Data = "Cool", Column4Data = "And", Column5Data = "Awesome" },
			};

			var csv = CsvSerializer.SerializeToCsv(data);

			Console.WriteLine(csv);

			Assert.That(csv, Is.EqualTo(
				"Column 1,Column 2,\"Column,3\",\"Column\n4\",Column 5"
				+ Environment.NewLine
				+ "I,Like,To,Read,Novels"
				+ Environment.NewLine
				+ "I am,Very,Cool,And,Awesome"
				+ Environment.NewLine
			));
		}

		[Test]
		public void Can_serialize_custom_anonymous_type_headers()
		{
			CsvConfig<TableItem>.CustomHeaders = new {
				Column1Data = "Column 1",
				Column2Data = "Column 2",
				Column3Data = "Column,3",
				Column4Data = "Column\n4",
				Column5Data = "Column 5",
			};
			var data = new List<TableItem> {
				new TableItem { Column1Data = "I", Column2Data = "Like", Column3Data = "To", Column4Data = "Read", Column5Data = "Novels" },
				new TableItem { Column1Data = "I am", Column2Data = "Very", Column3Data = "Cool", Column4Data = "And", Column5Data = "Awesome" },
			};

			var csv = CsvSerializer.SerializeToCsv(data);

			Console.WriteLine(csv);

			Assert.That(csv, Is.EqualTo(
				"Column 1,Column 2,\"Column,3\",\"Column\n4\",Column 5"
				+ Environment.NewLine
				+ "I,Like,To,Read,Novels"
				+ Environment.NewLine
				+ "I am,Very,Cool,And,Awesome"
				+ Environment.NewLine
			));
		}

		[Test]
		public void Can_serialize_partial_custom_headers_map()
		{
			CsvConfig<TableItem>.CustomHeadersMap = new Dictionary<string, string> {
				{"Column1Data", "Column 1"},
				{"Column3Data", "Column,3"},
				{"Column5Data", "Column 5"},
			};
			var data = new List<TableItem> {
				new TableItem { Column1Data = "I", Column2Data = "Like", Column3Data = "To", Column4Data = "Read", Column5Data = "Novels" },
				new TableItem { Column1Data = "I am", Column2Data = "Very", Column3Data = "Cool", Column4Data = "And", Column5Data = "Awesome" },
			};

			var csv = CsvSerializer.SerializeToCsv(data);

			Console.WriteLine(csv);

			Assert.That(csv, Is.EqualTo(
				"Column 1,\"Column,3\",Column 5"
				+ Environment.NewLine
				+ "I,To,Novels"
				+ Environment.NewLine
				+ "I am,Cool,Awesome"
				+ Environment.NewLine
			));
		}

		[Test]
		public void Can_serialize_without_headers()
		{
			CsvConfig<TableItem>.OmitHeaders = true;

			CsvConfig<TableItem>.CustomHeadersMap = new Dictionary<string, string> {
				{"Column1Data", "Column 1"},
				{"Column2Data", "Column 2"},
				{"Column3Data", "Column,3"},
				{"Column4Data", "Column\n4"},
				{"Column5Data", "Column 5"},
			};
			var data = new List<TableItem> {
				new TableItem { Column1Data = "I", Column2Data = "Like", Column3Data = "To", Column4Data = "Read", Column5Data = "Novels" },
				new TableItem { Column1Data = "I am", Column2Data = "Very", Column3Data = "Cool", Column4Data = "And", Column5Data = "Awesome" },
			};

			var csv = CsvSerializer.SerializeToCsv(data);

			Console.WriteLine(csv);

			Assert.That(csv, Is.EqualTo(
				"I,Like,To,Read,Novels"
				+ Environment.NewLine
				+ "I am,Very,Cool,And,Awesome"
				+ Environment.NewLine
			));
		}

        public List<TableItem> GetAll()
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                return entities.TableItem.Include(typeof(Table).Name).Where(t => t.Deleted == 0).ToList();
            }
        }
        public TableItem Add(int TableId)
        {
            //添加
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {

                try
                {
                    TableItem mt = new TableItem();
                    mt.TableId = TableId;
                    mt.CreateBy = SubjectUtils.GetAuthenticationId();
                    mt.CreateDatetime = DateTime.Now;
                    var market = entities.TableItem.Add(mt);
                    entities.SaveChanges();
                    return market;
                }
                catch (Exception e)
                {
                    e.ToString();
                    return null;
                }
            }
        }
        public bool Remove(int TableId)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                var type = entities.TableItem.SingleOrDefault(bt => bt.Deleted == 0 && bt.TableId == TableId);
                if (type != null)
                {
                    type.UpdateBy = SubjectUtils.GetAuthenticationId();
                    type.UpdateDatetime = DateTime.Now;
                    type.Deleted = 1;
                    entities.SaveChanges();
                    return true;
                }
            }
            return false;
        }
        public bool ModifyStatus(int TableId, int Status)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                var type = entities.TableItem.SingleOrDefault(bt => bt.Deleted == 0 && bt.TableId == TableId);
                if (type != null)
                {
                    type.UpdateBy = SubjectUtils.GetAuthenticationId();
                    type.UpdateDatetime = DateTime.Now;
                    type.Status = Status;
                    entities.SaveChanges();
                    return true;
                }
                return false;
            }
        }
        //TODO 建立与开台关联的关系和获取订单对象
        public List<TableItem> GetDetailByTableId(int TableId)
        {
            List<TableItem> tis;
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                tis=entities.TableItem.Include(typeof(Table).Name).Include(typeof(DeskDishes).Name).Where(t => t.Deleted == 0&&t.TableId==TableId).ToList();
                
            }
            return tis;
        }
        //TODO 建立与开台关联的关系和获取开台关联信息
        public List<TableItem> GetDetailByStatus(int Status)
        {
            List<TableItem> tis;
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                tis = entities.TableItem.Include(typeof(Table).Name).Where(t => t.Deleted == 0&&t.Status==Status).ToList();

            }
            return tis;
        }

		[TestFixtureTearDown]
		public void TestFixtureTearDown()
		{
			CsvConfig<TableItem>.Reset();
		}

		[Test]
		public void Can_serialize_custom_headers_map()
		{
			CsvConfig<TableItem>.CustomHeadersMap = new Dictionary<string, string> {
				{"Column1Data", "Column 1"},
				{"Column2Data", "Column 2"},
				{"Column3Data", "Column,3"},
				{"Column4Data", "Column\n4"},
				{"Column5Data", "Column 5"},
			};
			var data = new List<TableItem> {
				new TableItem { Column1Data = "I", Column2Data = "Like", Column3Data = "To", Column4Data = "Read", Column5Data = "Novels" },
				new TableItem { Column1Data = "I am", Column2Data = "Very", Column3Data = "Cool", Column4Data = "And", Column5Data = "Awesome" },
			};

			var csv = CsvSerializer.SerializeToCsv(data);

			Console.WriteLine(csv);

			Assert.That(csv, Is.EqualTo(
				"Column 1,Column 2,\"Column,3\",\"Column\n4\",Column 5"
				+ Environment.NewLine
				+ "I,Like,To,Read,Novels"
				+ Environment.NewLine
				+ "I am,Very,Cool,And,Awesome"
				+ Environment.NewLine
			));
		}

		[Test]
		public void Can_serialize_custom_anonymous_type_headers()
		{
			CsvConfig<TableItem>.CustomHeaders = new {
				Column1Data = "Column 1",
				Column2Data = "Column 2",
				Column3Data = "Column,3",
				Column4Data = "Column\n4",
				Column5Data = "Column 5",
			};
			var data = new List<TableItem> {
				new TableItem { Column1Data = "I", Column2Data = "Like", Column3Data = "To", Column4Data = "Read", Column5Data = "Novels" },
				new TableItem { Column1Data = "I am", Column2Data = "Very", Column3Data = "Cool", Column4Data = "And", Column5Data = "Awesome" },
			};

			var csv = CsvSerializer.SerializeToCsv(data);

			Console.WriteLine(csv);

			Assert.That(csv, Is.EqualTo(
				"Column 1,Column 2,\"Column,3\",\"Column\n4\",Column 5"
				+ Environment.NewLine
				+ "I,Like,To,Read,Novels"
				+ Environment.NewLine
				+ "I am,Very,Cool,And,Awesome"
				+ Environment.NewLine
			));
		}

		[Test]
		public void Can_serialize_partial_custom_headers_map()
		{
			CsvConfig<TableItem>.CustomHeadersMap = new Dictionary<string, string> {
				{"Column1Data", "Column 1"},
				{"Column3Data", "Column,3"},
				{"Column5Data", "Column 5"},
			};
			var data = new List<TableItem> {
				new TableItem { Column1Data = "I", Column2Data = "Like", Column3Data = "To", Column4Data = "Read", Column5Data = "Novels" },
				new TableItem { Column1Data = "I am", Column2Data = "Very", Column3Data = "Cool", Column4Data = "And", Column5Data = "Awesome" },
			};

			var csv = CsvSerializer.SerializeToCsv(data);

			Console.WriteLine(csv);

			Assert.That(csv, Is.EqualTo(
				"Column 1,\"Column,3\",Column 5"
				+ Environment.NewLine
				+ "I,To,Novels"
				+ Environment.NewLine
				+ "I am,Cool,Awesome"
				+ Environment.NewLine
			));
		}

		[Test]
		public void Can_serialize_without_headers()
		{
			CsvConfig<TableItem>.OmitHeaders = true;

			CsvConfig<TableItem>.CustomHeadersMap = new Dictionary<string, string> {
				{"Column1Data", "Column 1"},
				{"Column2Data", "Column 2"},
				{"Column3Data", "Column,3"},
				{"Column4Data", "Column\n4"},
				{"Column5Data", "Column 5"},
			};
			var data = new List<TableItem> {
				new TableItem { Column1Data = "I", Column2Data = "Like", Column3Data = "To", Column4Data = "Read", Column5Data = "Novels" },
				new TableItem { Column1Data = "I am", Column2Data = "Very", Column3Data = "Cool", Column4Data = "And", Column5Data = "Awesome" },
			};

			var csv = CsvSerializer.SerializeToCsv(data);

			Console.WriteLine(csv);

			Assert.That(csv, Is.EqualTo(
				"I,Like,To,Read,Novels"
				+ Environment.NewLine
				+ "I am,Very,Cool,And,Awesome"
				+ Environment.NewLine
			));
		}

		public void Apply()
		{
			OrderNoteboxConfigurationComponent component = new OrderNoteboxConfigurationComponent();
			ApplicationComponentExitCode exitCode = ApplicationComponent.LaunchAsDialog(
				this.Context.DesktopWindow, component, "Group Notebox Folder Configuration");

			if(exitCode == ApplicationComponentExitCode.Accepted)
			{
				this.Context.RebuildGroupFolders();
			}

		}

		public override void Start()
		{
			// create table
			_staffGroupTable = new Table<TableItem>();
			_staffGroupTable.Columns.Add(new TableColumn<TableItem, bool>("Show Folder",
				delegate(TableItem item) { return item.IsChecked; },
				delegate(TableItem item, bool value) { item.IsChecked = value; }));

			_staffGroupTable.Columns.Add(new TableColumn<TableItem, string>("Group Name",
				delegate(TableItem item) { return item.Item.Name; }));
			_staffGroupTable.Columns.Add(new TableColumn<TableItem, string>("Description",
				delegate(TableItem item) { return item.Item.Description; }));

			_actionModel = new CrudActionModel(false, false, true);
			_actionModel.Delete.SetClickHandler(DeleteStaffGroup);
			_actionModel.Delete.Enabled = false;

			// load existing group memberships
			Platform.GetService<IOrderNoteService>(
				delegate(IOrderNoteService service)
				{
					List<string> visibleGroups = OrderNoteboxFolderSystemSettings.Default.GroupFolders.StaffGroupNames;
					List<StaffGroupSummary> groups = service.ListStaffGroups(new ListStaffGroupsRequest()).StaffGroups;
					_staffGroupTable.Items.AddRange(
						CollectionUtils.Map<StaffGroupSummary, TableItem>(groups,
							delegate(StaffGroupSummary g)
							{
								bool visible = CollectionUtils.Contains(visibleGroups,
									delegate (string groupName) { return g.Name == groupName;});
								 return new TableItem(g, visible, false);
							}));
				});

			_staffGroupLookupHandler = new StaffGroupLookupHandler(this.Host.DesktopWindow, true);

			base.Start();
		}

		public void AddStaffGroup()
		{
			if(_staffGroupToAdd == null || _staffGroupTable.Items.Contains(_staffGroupToAdd))
				return;

			_staffGroupTable.Items.Add(new TableItem(_staffGroupToAdd, true, true));
		}

		public void DeleteStaffGroup()
		{
			if(_selectedTableItem == null || !_selectedTableItem.IsNew)
				return;

			TableItem itemToDelete = _selectedTableItem;
			_selectedTableItem = null;
			NotifyPropertyChanged("SelectedTableItem");

			_staffGroupTable.Items.Remove(itemToDelete);
		}

		public void Accept()
		{
			try
			{
				// if the user added any new groups, need to add the user as a member of those groups
				List<TableItem> newItems = CollectionUtils.Select(_staffGroupTable.Items,
					delegate(TableItem item) { return item.IsNew; });

				if (newItems.Count > 0)
				{
					AddStaffGroupsRequest request = new AddStaffGroupsRequest(
						CollectionUtils.Map<TableItem, StaffGroupSummary>(newItems,
							delegate(TableItem item) { return item.Item; }));

					Platform.GetService<IOrderNoteService>(
						delegate(IOrderNoteService service)
						{
							service.AddStaffGroups(request);
						});
				}

				// save the set of folders that should be visible
				List<TableItem> visibleItems = CollectionUtils.Select(_staffGroupTable.Items,
					delegate(TableItem item) { return item.IsChecked; });

				OrderNoteboxFolderSystemSettings.Default.GroupFolders = 
					new OrderNoteboxFolderSystemSettings.GroupFoldersData(
						CollectionUtils.Map<TableItem, string>(visibleItems,
							delegate(TableItem item) { return item.Item.Name; }));

				OrderNoteboxFolderSystemSettings.Default.Save();

				this.Exit(ApplicationComponentExitCode.Accepted);

			}
			catch (Exception e)
			{
				ExceptionHandler.Report(e, "", this.Host.DesktopWindow,
					delegate
					{
						this.Exit(ApplicationComponentExitCode.Error);
					});
			}
		}

		public void Cancel()
		{
			this.Exit(ApplicationComponentExitCode.None);
		}

		
		#endregion
		
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			Title = "Table with Index";
			
			CreateTableItems ();
			TableView.Source = tableSource;
			
		}

		/// <summary>
		/// Creates a set of table items.
		/// </summary>
		protected void CreateTableItems ()
		{
			List<TableItemGroup> tableItems = new List<TableItemGroup> ();
			Dictionary<string, int> indexSectionMap = new Dictionary<string, int>();
			
			// declare vars
			TableItemGroup tGroup;
			
			// Section
			tGroup = new TableItemGroup() { Name = "A"};
			tGroup.Items.Add (new TableItem("Apple"));
			tGroup.Items.Add (new TableItem("Artichoke"));
			tableItems.Add (tGroup);
			indexSectionMap["A"] = 0;
			
			// Section
			tGroup = new TableItemGroup() { Name = "B"};
			tGroup.Items.Add (new TableItem("Banana"));
			tGroup.Items.Add (new TableItem("Berries"));
			tableItems.Add (tGroup);
			indexSectionMap["B"] = 1;
			
			// Section
			tGroup = new TableItemGroup() { Name = "C"};
			tGroup.Items.Add (new TableItem("Cucumber"));
			tGroup.Items.Add (new TableItem("Cantalopes"));
			tableItems.Add (tGroup);
			indexSectionMap["C"] = 2;
			
			// Section
			tGroup = new TableItemGroup() { Name = "D"};
			tGroup.Items.Add (new TableItem("Daikon"));
			tableItems.Add (tGroup);
			indexSectionMap["D"] = 3;
			
			// Section
			tGroup = new TableItemGroup() { Name = "E"};
			tGroup.Items.Add (new TableItem("Eggplant"));
			tGroup.Items.Add (new TableItem("Elderberry"));
			tableItems.Add (tGroup);
			indexSectionMap["E"] = 4;
			
			// Section
			tGroup = new TableItemGroup() { Name = "F"};
			tGroup.Items.Add (new TableItem("Fig"));
			tableItems.Add (tGroup);
			indexSectionMap["F"] = 5;
			
			// Section
			tGroup = new TableItemGroup() { Name = "G"};
			tGroup.Items.Add (new TableItem("Grape"));
			tGroup.Items.Add (new TableItem("Guava"));
			tableItems.Add (tGroup);
			indexSectionMap["G"] = 6;
			
			// Section
			tGroup = new TableItemGroup() { Name = "H"};
			tGroup.Items.Add (new TableItem("Honeydew"));
			tGroup.Items.Add (new TableItem("Huckleberry"));
			tableItems.Add (tGroup);
			indexSectionMap["H"] = 7;
			
			// Section
			tGroup = new TableItemGroup() { Name = "I"};
			tGroup.Items.Add (new TableItem("Indian Fig"));
			tableItems.Add (tGroup);
			indexSectionMap["I"] = 8;
			
			// Section
			tGroup = new TableItemGroup() { Name = "J"};
			tGroup.Items.Add (new TableItem("Jackfruit"));
			tableItems.Add (tGroup);
			indexSectionMap["J"] = 9;
			
			// Section
			tGroup = new TableItemGroup() { Name = "K"};
			tGroup.Items.Add (new TableItem("Kiwi"));
			tGroup.Items.Add (new TableItem("Kumquat"));
			tableItems.Add (tGroup);
			indexSectionMap["K"] = 10;
			
			
			indexSectionMap["L"] = 10;
			indexSectionMap["M"] = 10;
			indexSectionMap["N"] = 10;
			indexSectionMap["O"] = 10;
			indexSectionMap["P"] = 10;
			indexSectionMap["Q"] = 10;
			indexSectionMap["R"] = 10;
			indexSectionMap["S"] = 10;
			indexSectionMap["T"] = 10;
			indexSectionMap["U"] = 10;
			indexSectionMap["V"] = 10;
			indexSectionMap["W"] = 10;
			indexSectionMap["X"] = 10;
			indexSectionMap["Y"] = 10;
			indexSectionMap["Z"] = 10;
	
			// For custom cells, comment out the first and uncomment the second.
			tableSource = new TableSourceWithIndex(tableItems, indexSectionMap);
		}


		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			table = new UITableView(new CGRect(0, 20, View.Bounds.Width, View.Bounds.Height - 20)); // defaults to Plain style
			table.AutoresizingMask = UIViewAutoresizing.All;
			List<TableItem> tableItems = new List<TableItem>();
			
			// credit for images
			// http://en.wikipedia.org/wiki/List_of_culinary_vegetables
			tableItems.Add (new TableItem("Vegetables") { SubHeading="65 items", ImageName="Vegetables.jpg"});
			tableItems.Add (new TableItem("Fruits") { SubHeading="17 items", ImageName="Fruits.jpg"});
			tableItems.Add (new TableItem("Flower Buds") { SubHeading="5 items", ImageName="Flower Buds.jpg"});
			tableItems.Add (new TableItem("Legumes") { SubHeading="33 items", ImageName="Legumes.jpg"});
			tableItems.Add (new TableItem("Bulbs") { SubHeading="18 items", ImageName="Bulbs.jpg"});
			tableItems.Add (new TableItem("Tubers") { SubHeading="43 items", ImageName="Tubers.jpg"});
			table.Source = new TableSource(tableItems, this);
			Add (table);
		}

Azure.Data.Tables.Models.TableItem : Object

Constructors :

public TableItem(String name = )

Methods :

public String get_Name()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()