Merge branch 'vnext' of github.com:pazof/yavsc into vnext

This commit is contained in:
2017-01-09 16:30:43 +01:00
27 changed files with 202 additions and 141 deletions

View File

@ -251,8 +251,8 @@ namespace BookAStar.Droid
{
Task.Run(async () =>
{
App.ShowBookQuery(
await DataManager.Instance.BookQueries.Get(queryId));
var query = DataManager.Instance.BookQueries.LocalGet(queryId);
App.ShowBookQuery(query);
});
}
}

View File

@ -9,6 +9,9 @@ namespace BookAStar.Droid.Services
using Model.Social;
using Newtonsoft.Json;
using Model;
using Model.Social;
using Data;
using System.Linq;
namespace ClientApp
{
@ -52,13 +55,20 @@ namespace BookAStar.Droid.Services
var cid = long.Parse(data.GetString("Id"));
var clientJson = data.GetString("Client");
var client = JsonConvert.DeserializeObject<ClientProviderInfo>(clientJson);
var bq = new BookQueryData
var bq = new BookQuery
{
Id = cid,
Location = location,
Client = client,
Reason = data.GetString("Reason")
};
var dateString = data.GetString("EventDate");
DateTime evDate;
if (DateTime.TryParse(dateString, out evDate))
{
bq.EventDate = evDate;
}
SendBookQueryNotification(bq);
}
else
@ -84,9 +94,12 @@ namespace BookAStar.Droid.Services
notificationManager.Notify(0, notificationBuilder.Build());
}
void SendBookQueryNotification(BookQueryData bquery)
void SendBookQueryNotification(BookQuery bquery)
{
var bookquerynotifications = MainSettings.AddBookQueryNotification(bquery);
DataManager.Instance.BookQueries.Merge(bquery);
var bookquerynotifications = DataManager.Instance.BookQueries.Where(
q=> ! q.Read && q.EventDate > DateTime.Now
).ToArray();
var count = bookquerynotifications.Length;
var multiple = count > 1;
var title =

View File

@ -7,7 +7,6 @@ using Android.Widget;
namespace BookAStar.Droid
{
[Service]
public class MyGcmIntentService : IntentService
{
@ -31,6 +30,7 @@ namespace BookAStar.Droid
intent.SetClass(context, typeof(MyGcmIntentService));
context.StartService(intent);
}
static object locker = new object();
protected override void OnHandleIntent(Intent intent)
@ -74,16 +74,28 @@ namespace BookAStar.Droid
void SendNotification (string message)
{
var intent = new Intent (this, typeof(MainActivity));
/* Bundle valuesForActivity = new Bundle();
valuesForActivity.PutInt("count", count); */
var intent = new Intent (this, typeof(MainActivity));
intent.AddFlags (ActivityFlags.ClearTop);
var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot);
// Construct a back stack for cross-task navigation:
TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);
stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
stackBuilder.AddNextIntent(intent);
var notificationBuilder = new Notification.Builder(this)
// Create the PendingIntent with the back stack:
PendingIntent resultPendingIntent =
stackBuilder.GetPendingIntent(0, PendingIntentFlags.UpdateCurrent);
var notificationBuilder = new Notification.Builder(this)
.SetAutoCancel(true)
.SetSmallIcon (Resource.Drawable.icon)
.SetContentTitle ("GCM Message")
.SetContentText (message)
.SetAutoCancel (true)
.SetContentIntent (pendingIntent);
.SetContentIntent(resultPendingIntent) // Start 2nd activity when the intent is clicked.
;
var notificationManager = (NotificationManager) GetSystemService(Context.NotificationService);
notificationManager.Notify (0, notificationBuilder.Build());

View File

@ -30,6 +30,7 @@ namespace BookAStar
using ViewModels;
using Pages.Chat;
using System.Collections.Generic;
using Model.Social;
public partial class App : Application // superclass new in 1.3
{
@ -196,9 +197,8 @@ namespace BookAStar
ChatPage chatPage;
private void ShowPage(Page page)
public static void ShowPage(Page page)
{
if (Navigation.NavigationStack.Contains(page))
{
if (Navigation.NavigationStack.Last() == page) return;
@ -443,11 +443,11 @@ namespace BookAStar
PlatformSpecificInstance.InvokeApi("gcm/register", info);
}
public static void ShowBookQuery (BookQueryData query)
public static void ShowBookQuery (BookQuery query)
{
var page = ViewFactory.CreatePage<BookQueryViewModel
, BookQueryPage>((b, p) => p.BindingContext = new BookQueryViewModel(query));
App.Current.MainPage.Navigation.PushAsync(page as Page);
var page = new BookQueryPage
{ BindingContext = new BookQueryViewModel(query) };
ShowPage(page);
}
}
}

View File

@ -42,14 +42,14 @@
</Compile>
<Compile Include="Attributes\CurrencyAttribute.cs" />
<Compile Include="Attributes\DisplayAttribute.cs" />
<Compile Include="Behaviors\EmailValidatorBehavior.cs" />
<Compile Include="Behaviors\IntegerEntryBehavior.cs" />
<Compile Include="Behaviors\EditorMaxLengthValidator.cs" />
<Compile Include="Behaviors\DecimalValidatorBehavior.cs" />
<Compile Include="Behaviors\MarkdownViewLengthValidator.cs" />
<Compile Include="Behaviors\PickerBehavior.cs" />
<Compile Include="Behaviors\RegexValidatorBehavior.cs" />
<Compile Include="Behaviors\StarBehavior.cs" />
<Compile Include="Converters\Behaviors\EmailValidatorBehavior.cs" />
<Compile Include="Converters\Behaviors\IntegerEntryBehavior.cs" />
<Compile Include="Converters\Behaviors\EditorMaxLengthValidator.cs" />
<Compile Include="Converters\Behaviors\DecimalValidatorBehavior.cs" />
<Compile Include="Converters\Behaviors\MarkdownViewLengthValidator.cs" />
<Compile Include="Converters\Behaviors\PickerBehavior.cs" />
<Compile Include="Converters\Behaviors\RegexValidatorBehavior.cs" />
<Compile Include="Converters\Behaviors\StarBehavior.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Converters\NotValueConverter.cs" />
<Compile Include="Converters\SignalRConnectionStateToObject.cs" />
@ -57,11 +57,14 @@
<Compile Include="Data\EstimateEntity.cs" />
<Compile Include="Data\NonCrUD\RemoteFiles.cs" />
<Compile Include="Model\Access\BlackListed.cs" />
<Compile Include="Model\Booking\MusicalPreference.cs" />
<Compile Include="Model\Booking\MusicalTendency.cs" />
<Compile Include="Model\FileSystem\UserDirectoryInfo.cs" />
<Compile Include="Model\FileSystem\UserFileInfo.cs" />
<Compile Include="Model\Settings\SignatureSettings.cs" />
<Compile Include="Model\Social\Chat\ChatStatus.cs" />
<Compile Include="Model\Social\Chat\ChatMessage.cs" />
<Compile Include="Model\Social\LocationType.cs" />
<Compile Include="Pages\ClientPages\SearchPage.xaml.cs">
<DependentUpon>SearchPage.xaml</DependentUpon>
</Compile>
@ -161,7 +164,7 @@
<Compile Include="Interfaces\IPlatform.cs" />
<Compile Include="Model\Blog\Blog.cs" />
<Compile Include="Model\Blog\BlogTag.cs" />
<Compile Include="Model\BookQueryData.cs" />
<Compile Include="Model\Booking\BookQuery.cs" />
<Compile Include="Model\Market\BaseProduct.cs" />
<Compile Include="Model\Workflow\BillingLine.cs" />
<Compile Include="Model\Manager.cs" />

View File

@ -9,11 +9,12 @@
using ViewModels;
using Model.Access;
using ViewModels.Messaging;
using Model.Social;
public class DataManager
{
// TODO estimatetemplate rating service product tag
public RemoteEntityRO<BookQueryData, long> BookQueries { get; set; }
public RemoteEntityRO<BookQuery, long> BookQueries { get; set; }
public ChatUserCollection ChatUsers { get; set; }
public EstimateEntity Estimates { get; set; }
public RemoteEntity<Blog, long> Blogspot { get; set; }
@ -41,7 +42,7 @@
public DataManager()
{
BookQueries = new RemoteEntityRO<BookQueryData, long>("bookquery", q => q.Id);
BookQueries = new RemoteEntityRO<BookQuery, long>("bookquery", q => q.Id);
Estimates = new EstimateEntity();
Blogspot = new RemoteEntity<Blog, long>("blog", x=>x.Id);

View File

@ -1,10 +1,9 @@
using BookAStar.Interfaces;
using BookAStar.Model.Social;

using System;
namespace BookAStar.Model
namespace BookAStar.Model.Social
{
public class BookQueryData
public class BookQuery
{
public ClientProviderInfo Client { get; set; }
public Location Location { get; set; }
@ -12,5 +11,6 @@ namespace BookAStar.Model
public DateTime EventDate { get; set; }
public decimal? Previsionnal { get; set; }
public string Reason { get; set; }
public bool Read { get; set; }
}
}

View File

@ -0,0 +1,12 @@
namespace BookAStar.Model.Social
{
public class MusicalPreference : MusicalTendency {
public long OwnerId { get; set; }
public int Rate { get; set; }
}
}

View File

@ -0,0 +1,13 @@
namespace BookAStar.Model.Social
{
public class MusicalTendency {
public long Id {get; set; }
public string Name { get ; set; }
}
}

View File

@ -0,0 +1,10 @@
namespace BookAStar.Model.Social
{
public class LocationType
{
public long Id { get; set; }
public string Name { get; set; }
}
}

View File

@ -7,7 +7,6 @@ namespace BookAStar.Model.Workflow.Messaging
/// <summary>
/// Query, for a date, with a given perfomer, at this given place.
/// </summary>
public class BookQuery {
/// <summary>
/// The command identifier

View File

@ -1,6 +1,4 @@
using BookAStar.Data;
using BookAStar.Helpers;
using BookAStar.Model.Interfaces;

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@ -8,6 +6,10 @@ using System.Linq;
namespace BookAStar.Model.Workflow
{
using Data;
using Interfaces;
using Social;
public partial class Estimate : IEstimate
{
public long Id { get; set; }
@ -62,7 +64,7 @@ namespace BookAStar.Model.Workflow
}
public string ClientId { get; set; }
[JsonIgnore]
public BookQueryData Query
public BookQuery Query
{
get
{

View File

@ -7,14 +7,14 @@ namespace BookAStar.Pages
{
using Data;
using EstimatePages;
using Model;
using Model.Social;
using Model.Workflow;
using ViewModels.EstimateAndBilling;
public partial class BookQueryPage : ContentPage
{
public BookQueryData BookQuery
public BookQuery BookQuery
{
get
{
@ -32,14 +32,14 @@ namespace BookAStar.Pages
var pin = new Pin
{
Type = PinType.SavedPin,
Position = new Position(
lat, lon),
Position = new Xamarin.Forms.Maps.Position
(lat, lon),
Label = BookQuery.Client.UserName,
Address = BookQuery.Location.Address
};
map.Pins.Add(pin);
map.MoveToRegion(MapSpan.FromCenterAndRadius(
new Position(lat, lon), Distance.FromMeters(100)));
new Xamarin.Forms.Maps.Position(lat, lon), Distance.FromMeters(100)));
}
}

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.HomePage"
Style="{StaticResource PageStyle}"
Title="Accueil">
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
x:Class="BookAStar.Pages.HomePage"
Style="{StaticResource PageStyle}"
Title="Accueil">
<ContentPage.Resources>
<ResourceDictionary>
<Style TargetType="Label">
@ -19,28 +20,29 @@
<TabbedPage.Children>
<TabbedPage Title="{x:Static local:Strings.SearchForAPro}" >
<TabbedPage.Children>
<ContentPage Title="Les stars">
<StackLayout Orientation="Horizontal">
<Editor HorizontalOptions="FillAndExpand"/>
<Button HorizontalOptions="End" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="{x:Static local:Strings.GeographicalyNear}" />
<Switch HorizontalOptions="End" IsToggled="{Binding ByLocation, Mode=TwoWay}" />
</StackLayout>
</ContentPage>
<ContentPage Title="">
<StackLayout Orientation="Horizontal">
<Editor HorizontalOptions="FillAndExpand"/>
<Button HorizontalOptions="End" />
</StackLayout>
</ContentPage>
</TabbedPage.Children>
<ContentPage Title="Les stars, musiciens, chanteurs DJ">
<StackLayout Orientation="Horizontal">
<Editor HorizontalOptions="FillAndExpand"/>
<Button HorizontalOptions="End" />
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="Start">
<Label Text="{x:Static local:Strings.GeographicalyNear}" />
<Switch HorizontalOptions="End" VerticalOptions="Start"
IsToggled="{Binding ByLocation, Mode=TwoWay}" />
</StackLayout>
</ContentPage>
<ContentPage Title="Les formations musicales">
<StackLayout Orientation="Horizontal">
<Editor HorizontalOptions="FillAndExpand"/>
<Button HorizontalOptions="End" />
</StackLayout>
</ContentPage>
</TabbedPage.Children>
</TabbedPage>
<!--
<!--
les derniers sons/videos/articles postés
<TabbedPage.Children>
<ContentPage Title="Blogspot">
@ -51,67 +53,70 @@
</ContentPage>
</TabbedPage.Children>
-->
<!--
<!--
Les demandes devis en attente de réponse (pro)
-->
<ContentPage Title="Demandes de devis" BindingContext="{Binding BookQueries}"
IsVisible="{BindingContext UserProfile.IsAPerformer}">
<ListView x:Name="querylist"
RefreshCommand="{Binding RefreshQueries}"
IsPullToRefreshEnabled="True"
ItemsSource="{Binding Queries}"
ItemTapped="OnViewBookQueryDetail"
HasUnevenRows="true"
SeparatorVisibility="Default"
SeparatorColor="Black">
<ListView.ItemTemplate VerticalOptions="StartAndExpand" >
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Grid.Column="0" Grid.RowSpan="4" Source="{Binding Avatar}" />
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Client.UserName}" Style="{StaticResource LabelStyle}"></Label>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Data.Reason}"></Label>
<Label Grid.Row="2" Grid.Column="1" LineBreakMode="WordWrap" Text="{Binding EventDate, StringFormat='{0:dddd d MMMM à HH:mm}'}" FontFamily="Italic"/>
<Label Grid.Row="3" Grid.Column="1" LineBreakMode="WordWrap" Text="{Binding Location.Address}" />
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ContentPage Title="Demandes de devis"
IsVisible="{Binding UserProfile.IsAPerformer}">
<StackLayout BindingContext="{Binding BookQueries}">
<ListView x:Name="querylist"
RefreshCommand="{Binding RefreshQueries}"
IsPullToRefreshEnabled="True"
ItemsSource="{Binding Queries}"
ItemTapped="OnViewBookQueryDetail"
HasUnevenRows="true"
SeparatorVisibility="Default"
SeparatorColor="Black">
<ListView.ItemTemplate VerticalOptions="StartAndExpand" >
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Grid.Column="0" Grid.RowSpan="4" Source="{Binding Avatar}" />
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Client.UserName}" Style="{StaticResource LabelStyle}"></Label>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Data.Reason}"></Label>
<Label Grid.Row="2" Grid.Column="1" LineBreakMode="WordWrap" Text="{Binding EventDate, StringFormat='{0:dddd d MMMM à HH:mm}'}" FontFamily="Italic"/>
<Label Grid.Row="3" Grid.Column="1" LineBreakMode="WordWrap" Text="{Binding Location.Address}" />
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
<!-- Les signatures de contrat en souffreances (pro) -->
<ContentPage Title="Contrats à signer" IsVisible="{BindingContext UserProfile.IsAPerformer}">
<ContentPage Title="Contrats à signer" IsVisible="{Binding UserProfile.IsAPerformer}">
</ContentPage>
<!-- Les annonces pro (pro) -->
<ContentPage Title="Annonces pro" IsVisible="{BindingContext UserProfile.IsAPerformer}">
<StackLayout Orientation="Horizontal" >
<ContentPage Title="Annonces pro" IsVisible="{Binding UserProfile.IsAPerformer}">
<StackLayout Orientation="Horizontal" >
<Editor x:Name="search_pub_pro_phrase" HorizontalOptions="FillAndExpand"/>
<Button x:Name="btn_pro_pub" HorizontalOptions="End" />
</StackLayout>
</ContentPage>
<!-- les petites annonces des clients (pro) -->
<ContentPage Title="Annonces client" Icon="" IsVisible="{BindingContext UserProfile.IsAPerformer}">
<!-- les petites annonces des clients (pro) -->
<ContentPage Title="Annonces client" Icon="" IsVisible="{Binding UserProfile.IsAPerformer}">
<StackLayout Orientation="Horizontal" >
<Editor x:Name="search_pub_cli_phrase" HorizontalOptions="FillAndExpand"/>
<Button x:Name="btn_cli_pub" HorizontalOptions="End" />
</StackLayout>
</ContentPage>
</TabbedPage.Children>
</TabbedPage.Children>
</TabbedPage>

View File

@ -29,9 +29,11 @@ namespace BookAStar.Pages
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
// this technique make this view model
// non-sharable between view or pages
if (Model != null)
{
// set the refresh command before using it
Model.BookQueries.RefreshQueries =
new Command(() =>
{
@ -39,6 +41,9 @@ namespace BookAStar.Pages
this.querylist.EndRefresh();
});
}
// Use the new refresh command
base.OnBindingContextChanged();
}
private void OnViewBookQueryDetail(object sender, ItemTappedEventArgs e)

View File

@ -1,6 +1,4 @@
// Helpers/Settings.cs
using BookAStar.Model;
using BookAStar.Model.Auth.Account;
using Newtonsoft.Json;
using Plugin.Settings;
using Plugin.Settings.Abstractions;
@ -8,11 +6,12 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace BookAStar
{
using Model.Social;
using Model.Auth.Account;
using Data;
/// <summary>
/// This is the Settings static class that can be used in your Core solution or in any
@ -75,23 +74,13 @@ namespace BookAStar
}
}
public const string bookQueryNotificationsKey = "BookQueryNotifications";
public static BookQueryData[] GetBookQueryNotifications()
public static BookQuery[] GetBookQueryNotifications()
{
// Do not return any null List
var json = AppSettings.GetValueOrDefault<string>(bookQueryNotificationsKey);
if (!string.IsNullOrWhiteSpace(json))
return JsonConvert.DeserializeObject<BookQueryData[]>(json);
return new BookQueryData[] { };
}
public static BookQueryData[] AddBookQueryNotification(BookQueryData query)
{
var existing = new List<BookQueryData>(GetBookQueryNotifications());
existing.Add(query);
var result = existing.ToArray();
AppSettings.AddOrUpdateValue(bookQueryNotificationsKey,
JsonConvert.SerializeObject(result));
return result;
return JsonConvert.DeserializeObject<BookQuery[]>(json);
return new BookQuery[] { };
}
public static string GoogleRegId

View File

@ -21,7 +21,7 @@ namespace BookAStar.ViewModels.EstimateAndBilling
{
}
public BookQueryViewModel(BookQueryData data)
public BookQueryViewModel(BookQuery data)
{
Debug.Assert(data != null);
Client=data.Client;
@ -35,8 +35,8 @@ namespace BookAStar.ViewModels.EstimateAndBilling
));
this.data = data;
}
private BookQueryData data;
public BookQueryData Data {
private BookQuery data;
public BookQuery Data {
get
{
return data;

View File

@ -1,16 +1,16 @@
using System.Collections.Generic;
using BookAStar.Model.Workflow;
using System.Collections.ObjectModel;
using BookAStar.Model;
using Xamarin.Forms;
using BookAStar.Data;
using Newtonsoft.Json;
using System.Linq;
using BookAStar.ViewModels.Validation;
using System.ComponentModel;
namespace BookAStar.ViewModels.EstimateAndBilling
{
using Model;
using Model.Workflow;
using Model.Social;
using Validation;
public class EditEstimateViewModel : EditingViewModel<Estimate>
{
@ -129,7 +129,7 @@ namespace BookAStar.ViewModels.EstimateAndBilling
public ClientProviderInfo Client { get { return Data.Client; } }
[JsonIgnore]
public BookQueryData Query { get { return Data.Query; } }
public BookQuery Query { get { return Data.Query; } }
[JsonIgnore]
public FormattedString FormattedTotal

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using XLabs.Forms.Mvvm;
namespace BookAStar.ViewModels.Searching
{
class SearchingAnArtistViewModel: ViewModel
{
}
}