en supprimant Yavsc.Api

This commit is contained in:
2016-07-27 10:55:44 +02:00
parent 8167ce5091
commit ee4b70f32d
102 changed files with 326 additions and 80 deletions

View File

@ -1,26 +0,0 @@
namespace Yavsc.Models.Market {
using System.ComponentModel.DataAnnotations.Schema;
public enum BillingMode { 
Unitary,
SetPrice,
ByExecutionTime
}
public partial class Service : BaseProduct
{
public string ContextId { get; set; }
[ForeignKey("ContextId")]
public virtual Activity Context { get; set; }
public BillingMode? Billing { get; set; }
// TODO public ServiceSpecification Specification { get; set; }
/// <summary>
/// In euro, either by hour or by release
/// </summary>
/// <returns></returns>
public decimal? Pricing { get; set; }
}
}

View File

@ -24,8 +24,7 @@
"frameworks": {
"net451": {
"dependencies": {
"Yavsc.Client": "1.0.0-*"
}
}
}
}
}

View File

@ -751,13 +751,9 @@
"runtime": {
"lib/net45/_._": {}
}
},
"Yavsc.Client/1.0.0": {
"type": "project",
"framework": ".NETPortable,Version=v4.5,Profile=Profile111"
}
},
".NETFramework,Version=v4.5.1/win7-x86": {
".NETFramework,Version=v4.5.1/debian.8-x86": {
"EntityFramework.Commands/7.0.0-rc1-final": {
"type": "package",
"dependencies": {
@ -1506,13 +1502,9 @@
"runtime": {
"lib/net45/_._": {}
}
},
"Yavsc.Client/1.0.0": {
"type": "project",
"framework": ".NETPortable,Version=v4.5,Profile=Profile111"
}
},
".NETFramework,Version=v4.5.1/win7-x64": {
".NETFramework,Version=v4.5.1/debian.8-x64": {
"EntityFramework.Commands/7.0.0-rc1-final": {
"type": "package",
"dependencies": {
@ -2261,18 +2253,10 @@
"runtime": {
"lib/net45/_._": {}
}
},
"Yavsc.Client/1.0.0": {
"type": "project",
"framework": ".NETPortable,Version=v4.5,Profile=Profile111"
}
}
},
"libraries": {
"Yavsc.Client/1.0.0": {
"type": "project",
"path": "../wrap/Yavsc.Client/project.json"
},
"EntityFramework.Commands/7.0.0-rc1-final": {
"type": "package",
"serviceable": true,
@ -3057,8 +3041,6 @@
"Newtonsoft.Json >= 9.0.1",
"System.Json >= 4.0.20126.16343"
],
".NETFramework,Version=v4.5.1": [
"Yavsc.Client >= 1.0.0-*"
]
".NETFramework,Version=v4.5.1": []
}
}

View File

@ -0,0 +1,99 @@
//
// PostJson.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Net;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System;
using System.Json;
namespace Yavsc.Helpers
{
/// <summary>
/// Simple json post method.
/// </summary>
public class SimpleJsonPostMethod : IDisposable
{
private HttpWebRequest request=null;
/// <summary>
/// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class.
/// </summary>
/// <param name="pathToMethod">Path to method.</param>
public SimpleJsonPostMethod (string pathToMethod, string authorizationHeader = null)
{
request = (HttpWebRequest) WebRequest.Create (pathToMethod);
request.Method = "POST";
request.Accept = "application/json";
request.ContentType = "application/json";
request.SendChunked = true;
request.TransferEncoding = "UTF-8";
if (authorizationHeader!=null)
request.Headers["Authorization"]=authorizationHeader;
}
public void Dispose()
{
request.Abort();
}
/// <summary>
/// Invoke the specified query.
/// </summary>
/// <param name="query">Query.</param>
public TAnswer Invoke<TAnswer>(object query)
{
using (Stream streamQuery = request.GetRequestStream()) {
using (StreamWriter writer = new StreamWriter(streamQuery)) {
writer.Write (JsonConvert.SerializeObject(query));
}}
TAnswer ans = default (TAnswer);
using (WebResponse response = request.GetResponse ()) {
using (Stream responseStream = response.GetResponseStream ()) {
using (StreamReader rdr = new StreamReader (responseStream)) {
ans = (TAnswer) JsonConvert.DeserializeObject<TAnswer> (rdr.ReadToEnd ());
}
}
response.Close();
}
return ans;
}
public async Task<JsonValue> InvokeJson(object query)
{
JsonValue jsonDoc=null;
using (Stream streamQuery = request.GetRequestStream()) {
using (StreamWriter writer = new StreamWriter(streamQuery)) {
writer.Write (JsonConvert.SerializeObject(query));
}}
using (WebResponse response = request.GetResponse ()) {
using (Stream stream = response.GetResponseStream ()) {
if (stream.Length>0)
jsonDoc = await Task.Run (() => JsonObject.Load (stream));
}
response.Close();
}
return jsonDoc;
}
}
}

View File

@ -0,0 +1,9 @@
namespace Yavsc.Models
{
public interface IAccountBalance
{
long ContactCredits { get; set; }
decimal Credits { get; set; }
string UserId { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System.Collections.Generic;
using Yavsc.Models.Identity;
namespace Yavsc.Models
{
public interface IApplicationUser
{
IAccountBalance AccountBalance { get; set; }
IList<IContact> Book { get; set; }
IList<ICircle> Circles { get; set; }
string DedicatedGoogleCalendar { get; set; }
IList<IGoogleCloudMobileDeclaration> Devices { get; set; }
ILocation PostalAddress { get; set; }
IList<IBlog> Posts { get; set; }
}
}

17
Yavsc/Interfaces/IBlog.cs Normal file
View File

@ -0,0 +1,17 @@
using System;
namespace Yavsc.Models
{
public interface IBlog
{
string AuthorId { get; set; }
string bcontent { get; set; }
long Id { get; set; }
DateTime modified { get; set; }
string photo { get; set; }
DateTime posted { get; set; }
int rate { get; set; }
string title { get; set; }
bool visible { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace Yavsc.Models
{
public interface ICircle
{
long Id { get; set; }
IList<ICircleMember> Members { get; set; }
string Name { get; set; }
IApplicationUser Owner { get; set; }
string OwnerId { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace Yavsc.Models
{
public interface ICircleMember
{
ICircle Circle { get; set; }
long Id { get; set; }
IApplicationUser Member { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace Yavsc.Models
{
public interface IContact
{
IApplicationUser Owner { get; set; }
string OwnerId { get; set; }
string UserId { get; set; }
}
}

View File

@ -0,0 +1,18 @@
namespace Yavsc.Models.Identity
{
public interface IGCMDeclaration
{
string DeviceId { get; set; }
string GCMRegistrationId { get; set; }
string Model { get; set; }
string Platform { get; set; }
string Version { get; set; }
}
public interface IGoogleCloudMobileDeclaration: IGCMDeclaration
{
IApplicationUser DeviceOwner { get; set; }
string DeviceOwnerId { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace Yavsc
{
public interface ILocation
{
string Address { get; set; }
long Id { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace Yavsc
{
public interface IPosition
{
double Latitude { get; set; }
double Longitude { get; set; }
}
}

View File

@ -10,7 +10,7 @@ namespace Yavsc.Models
public string UserId { get; set; }
[ForeignKey("UserId")]
public virtual IApplicationUser Owner { get; set; }
public virtual ApplicationUser Owner { get; set; }
[Required,Display(Name="Credits in €")]
public decimal Credits { get; set; }

View File

@ -0,0 +1,11 @@
using Yavsc.Models.Market;
namespace Yavsc.Models.Billing
{
public class ServiceContract<P> where P : Service
{
}
}

View File

@ -7,7 +7,7 @@ using Yavsc.Models.Booking;
namespace Yavsc.Models.Billing
{
public partial class RDVEstimate
public partial class Estimate
{
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }

View File

@ -1,10 +1,12 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.Models.Billing
{
public partial class EstimateAgreement : RDVEstimate
public partial class Contract : Estimate
{
[Required]
public DateTime ClientValidationDate { get; set; }
}
}

View File

@ -4,22 +4,28 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
public partial class Blog: IBlog
public partial class Blog
{
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
[Display(Name="Content")]
public string bcontent { get; set; }
[DisplayAttribute(Name="Modified")]
[Display(Name="Modified")]
public DateTime modified { get; set; }
[Display(Name="Photo")]
public string photo { get; set; }
[Display(Name="Posted")]
public DateTime posted { get; set; }
[Display(Name="Rate")]
public int rate { get; set; }
[Display(Name="Title")]
public string title { get; set; }
[Required]
public string AuthorId { get; set; }
[ForeignKey("AuthorId")]
public IApplicationUser Author { set; get; }
public ApplicationUser Author { set; get; }
[Display(Name="Visible")]
public bool visible { get; set; }
}
}

View File

@ -8,25 +8,25 @@ using Yavsc.Models.Identity;
namespace Yavsc.Models
{
public class ApplicationUser : IdentityUser, IApplicationUser
public class ApplicationUser : IdentityUser
{
[Display(Name="AccountBalance")]
public virtual IAccountBalance AccountBalance { get; set; }
public virtual AccountBalance AccountBalance { get; set; }
[InverseProperty("Author")]
public virtual IList<IBlog> Posts { get; set; }
public virtual List<Blog> Posts { get; set; }
[InverseProperty("Owner")]
public virtual IList<IContact> Book { get; set; }
public virtual List<Contact> Book { get; set; }
[InverseProperty("DeviceOwner")]
public virtual IList<IGoogleCloudMobileDeclaration> Devices { get; set; }
public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; }
[InverseProperty("Owner")]
public virtual IList<ICircle> Circles { get; set; }
public virtual ILocation PostalAddress { get; set; }
public virtual List<Circle> Circles { get; set; }
public virtual Location PostalAddress { get; set; }
public string DedicatedGoogleCalendar { get; set; }

View File

@ -1,3 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
@ -18,7 +19,7 @@ namespace Yavsc.Models.Identity
public string Platform { get; set; }
public string Version { get; set; }
public string DeviceOwnerId { get; set; }
public DateTime DeclarationDate { get; set; }
[JsonIgnore,ForeignKey("DeviceOwnerId")]
public virtual ApplicationUser DeviceOwner { get; set; }
}

View File

@ -0,0 +1,67 @@
namespace Yavsc.Models.Market {
using System;
using System.ComponentModel.DataAnnotations.Schema;
public enum BillingMode { 
Unitary,
SetPrice,
ByExecutionTime
}
public interface IUnit<VType> {
string Name { get; }
bool CanConvertFrom(IUnit<VType> other);
VType ConvertFrom (IUnit<VType> other, VType orgValue) ;
}
public class Money : IUnit<decimal>
{
public Money(string name, decimal euroExchangeRate)
{
Name = name;
EuroExchangeRate = euroExchangeRate;
}
public string Name
{
get; private set ;
}
public decimal EuroExchangeRate
{
get; private set ;
}
public bool CanConvertFrom(IUnit<decimal> other)
{
if (other is Money)
return true;
return false;
}
public decimal ConvertFrom(IUnit<decimal> other, decimal orgValue)
{
if (other is Money) {
var om = other as Money;
return orgValue * om.EuroExchangeRate / EuroExchangeRate;
}
throw new NotImplementedException();
}
}
public partial class Service : BaseProduct
{
public string ContextId { get; set; }
[ForeignKey("ContextId")]
public virtual Activity Context { get; set; }
public BillingMode? Billing { get; set; }
// TODO public ServiceSpecification Specification { get; set; }
/// <summary>
/// In euro
/// </summary>
/// <returns></returns>
public decimal? Pricing { get; set; }
}
}

View File

@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
public partial class Circle: ICircle {
public partial class Circle {
[Key, DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
@ -13,9 +13,9 @@ namespace Yavsc.Models
public string OwnerId { get; set; }
[ForeignKey("OwnerId")]
public virtual IApplicationUser Owner { get; set; }
public virtual ApplicationUser Owner { get; set; }
[InverseProperty("Circle")]
public virtual IList<ICircleMember> Members { get; set; }
public virtual List<CircleMember> Members { get; set; }
}
}

View File

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
public class Contact: IContact
public class Contact
{
[Required()]
public string UserId { get; set; }
@ -13,6 +13,6 @@ namespace Yavsc.Models
public string OwnerId { get; set; }
[ForeignKeyAttribute("OwnerId")]
public virtual IApplicationUser Owner { get; set; }
public virtual ApplicationUser Owner { get; set; }
}
}

View File

@ -7,7 +7,7 @@ namespace Yavsc
/// <summary>
/// Position.
/// </summary>
public class Position: IPosition
public class Position
{
/// <summary>
/// The longitude.
@ -27,7 +27,7 @@ namespace Yavsc
}
public class Location : Position, ILocation {
public class Location : Position {
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
[Required(),

View File

@ -36,7 +36,5 @@ namespace Yavsc.Models
/// <returns></returns>
string ModeratorGroupName { get; set; }
}
}

View File

@ -8,8 +8,8 @@ namespace Yavsc.Models.Workflow
public class PerformerProfile {
[Key]
public string PerfomerId { get; set; }
[ForeignKey("PerfomerId"),Display(Name="Performer")]
public string PerformerId { get; set; }
[ForeignKey("PerformerId"),Display(Name="Performer")]
public virtual ApplicationUser Performer { get; set; }
[Display(Name="Activity"),Required]
@ -21,10 +21,10 @@ namespace Yavsc.Models.Workflow
RegularExpression(@"^[0-9]{9,14}$", ErrorMessage = "Only numbers are allowed here")]
public string SIREN { get; set; }
public long OrganisationAddressId { get; set; }
public long OrganizationAddressId { get; set; }
[Required,Display(Name="Organisation address"),ForeignKey("OrganisationAddressId")]
public virtual Location OrganisationAddress { get; set; }
[Required,Display(Name="Organization address"),ForeignKey("OrganizationAddressId")]
public virtual Location OrganizationAddress { get; set; }
[ForeignKey("ActivityCode"),Display(Name="Activity")]
public virtual Activity Activity { get; set; }
@ -35,8 +35,8 @@ namespace Yavsc.Models.Workflow
[Display(Name="Accept notifications from non-VIP users")]
public bool AcceptPublicContact { get; set; }
[Display(Name="Allow my geolocatisation, nearby my clients")]
public bool AcceptGeoLocalisation { get; set; }
[Display(Name="Allow my geo-localization, nearby my clients")]
public bool AcceptGeoLocalization { get; set; }
[Display(Name="Web site")]
public string WebSite { get; set; }

Some files were not shown because too many files have changed in this diff Show More