当前位置: 首页>>代码示例>>C#>>正文


C# IDataStore.UpdateStoreAsync方法代码示例

本文整理汇总了C#中IDataStore.UpdateStoreAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IDataStore.UpdateStoreAsync方法的具体用法?C# IDataStore.UpdateStoreAsync怎么用?C# IDataStore.UpdateStoreAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataStore的用法示例。


在下文中一共展示了IDataStore.UpdateStoreAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StorePage

		public StorePage (Store store)
		{
			
			dataStore = DependencyService.Get<IDataStore> ();
			Store = store;
			if (Store == null) {
				Store = new Store ();
				Store.MondayOpen = "9am";
				Store.TuesdayOpen = "9am";
				Store.WednesdayOpen = "9am";
				Store.ThursdayOpen = "9am";
				Store.FridayOpen = "9am";
				Store.SaturdayOpen = "9am";
				Store.SundayOpen = "12pm";
				Store.MondayClose = "8pm";
				Store.TuesdayClose = "8pm";
				Store.WednesdayClose = "8pm";
				Store.ThursdayClose = "8pm";
				Store.FridayClose = "8pm";
				Store.SaturdayClose = "8pm";
				Store.SundayClose = "6pm";
				isNew = true;
			}

			Title = isNew ? "New Store" : "Edit Store";
			
			ToolbarItems.Add (new ToolbarItem {
				Text="Save",
				Command = new Command(async (obj)=>
					{
						Store.Name = name.Text.Trim();
						Store.LocationHint = locationHint.Text.Trim();
						Store.City = city.Text.Trim();
						Store.PhoneNumber = phoneNumber.Text.Trim();
						Store.Image = imageUrl.Text.Trim();
						Store.StreetAddress = streetAddress.Text.Trim();
						Store.State = state.Text.Trim();
						Store.ZipCode = zipCode.Text.Trim();
						Store.LocationCode = locationCode.Text.Trim();
						Store.Country = country.Text.Trim();
						double lat;
						double lng;

						var parse1 = double.TryParse(latitude.Text.Trim(), out lat);
						var parse2 = double.TryParse(longitude.Text.Trim(), out lng);
						Store.Longitude = lng;
						Store.Latitude = lat;
						Store.MondayOpen = mondayOpen.Text.Trim();
						Store.MondayClose = mondayClose.Text.Trim();
						Store.TuesdayOpen = tuesdayOpen.Text.Trim();
						Store.TuesdayClose = tuesdayClose.Text.Trim();
						Store.WednesdayOpen = wednesdayOpen.Text.Trim();
						Store.WednesdayClose = wednesdayClose.Text.Trim();
						Store.ThursdayOpen = thursdayOpen.Text.Trim();
						Store.ThursdayClose = thursdayClose.Text.Trim();
						Store.FridayOpen = fridayOpen.Text.Trim();
						Store.FridayClose = fridayClose.Text.Trim();
						Store.SaturdayOpen = saturdayOpen.Text.Trim();
						Store.SaturdayClose = saturdayClose.Text.Trim();
						Store.SundayOpen = sundayOpen.Text.Trim();
						Store.SundayClose = sundayClose.Text.Trim();




						bool isAnyPropEmpty = Store.GetType().GetTypeInfo().DeclaredProperties
							.Where(p => p.GetValue(Store) is string && p.CanRead && p.CanWrite && p.Name != "State") // selecting only string props
							.Any(p => string.IsNullOrWhiteSpace((p.GetValue(Store) as string)));

						if(isAnyPropEmpty || !parse1 || !parse2)
						{
							await DisplayAlert("Not Valid", "Some fields are not valid, please check", "OK");
							return;
						}
						Title = "SAVING...";
						if(isNew)
						{
							await dataStore.AddStoreAsync(Store);
						}
						else
						{
							await dataStore.UpdateStoreAsync(Store);
						}

						await DisplayAlert("Saved", "Please refresh store list", "OK");
						await Navigation.PopAsync();
					})
			});


			Content = new TableView {
				HasUnevenRows = true,
				Intent = TableIntent.Form,
				Root = new TableRoot {
					new TableSection ("Information") {
						(name = new EntryCell {Label = "Name", Text = Store.Name}),
						(locationHint = new EntryCell {Label = "Location Hint", Text = Store.LocationHint}),
						(phoneNumber = new EntryCell {Label = "Phone Number", Text = Store.PhoneNumber, Placeholder ="555-555-5555"}),
						(locationCode = new EntryCell {Label = "Location Code", Text = Store.LocationCode}),

//.........这里部分代码省略.........
开发者ID:xamaringeek,项目名称:MyShoppe,代码行数:101,代码来源:StorePage.cs


注:本文中的IDataStore.UpdateStoreAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。