refactoring & Activities update
This commit is contained in:
parent
c70f9c3fa0
commit
28c53cc2ee
19 changed files with 5740 additions and 114 deletions
|
|
@ -28,17 +28,18 @@ public class GCMController : Controller
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Authorize, HttpPost("register")]
|
[Authorize, HttpPost("register")]
|
||||||
public IActionResult Register(
|
public IActionResult Register(
|
||||||
[FromBody] GoogleCloudMobileDeclaration declaration)
|
[FromBody] GivenGoogleCloudMobileDeclaration declaration)
|
||||||
{
|
{
|
||||||
var uid = User.GetUserId();
|
var uid = User.GetUserId();
|
||||||
|
|
||||||
_logger.LogWarning($"Registering device with id:{declaration.DeviceId} for {uid}");
|
_logger.LogInformation($"Registering device with id:{declaration.DeviceId} for {uid}");
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
var alreadyRegisteredDevice = _context.GCMDevices.FirstOrDefault(d => d.DeviceId == declaration.DeviceId);
|
var alreadyRegisteredDevice = _context.GCMDevices.FirstOrDefault(d => d.DeviceId == declaration.DeviceId);
|
||||||
var deviceAlreadyRegistered = (alreadyRegisteredDevice!=null);
|
var deviceAlreadyRegistered = (alreadyRegisteredDevice!=null);
|
||||||
if (deviceAlreadyRegistered)
|
if (deviceAlreadyRegistered)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation($"deviceAlreadyRegistered");
|
||||||
// Override an exiting owner
|
// Override an exiting owner
|
||||||
alreadyRegisteredDevice.DeclarationDate = DateTime.Now;
|
alreadyRegisteredDevice.DeclarationDate = DateTime.Now;
|
||||||
alreadyRegisteredDevice.DeviceOwnerId = uid;
|
alreadyRegisteredDevice.DeviceOwnerId = uid;
|
||||||
|
|
@ -51,17 +52,16 @@ public class GCMController : Controller
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation($"new device");
|
||||||
declaration.DeclarationDate = DateTime.Now;
|
declaration.DeclarationDate = DateTime.Now;
|
||||||
declaration.DeviceOwnerId = uid;
|
declaration.DeviceOwnerId = uid;
|
||||||
_context.GCMDevices.Add(declaration);
|
_context.GCMDevices.Add(declaration as GoogleCloudMobileDeclaration);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
}
|
}
|
||||||
var latestActivityUpdate = _context.Activities.Aggregate(
|
var latestActivityUpdate = _context.Activities.Max(a=>a.DateModified);
|
||||||
(a,b)=>a.DateModified>b.DateModified?a:b
|
|
||||||
).DateModified;
|
|
||||||
return Json(new {
|
return Json(new {
|
||||||
IsAnUpdate = deviceAlreadyRegistered,
|
IsAnUpdate = deviceAlreadyRegistered,
|
||||||
UpdateActivities = latestActivityUpdate>declaration.LatestActivityUpdate
|
UpdateActivities = latestActivityUpdate > declaration.LatestActivityUpdate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return new BadRequestObjectResult(ModelState);
|
return new BadRequestObjectResult(ModelState);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Yavsc.Models.Access
|
namespace Yavsc.Models.Access
|
||||||
{
|
{
|
||||||
|
using YavscLib;
|
||||||
|
|
||||||
public class Ban : IBaseTrackedEntity
|
public class Ban : IBaseTrackedEntity
|
||||||
{
|
{
|
||||||
public DateTime DateCreated
|
public DateTime DateCreated
|
||||||
|
|
@ -29,4 +31,4 @@ namespace Yavsc.Models.Access
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,14 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Authentication.OAuth;
|
using Microsoft.AspNet.Authentication.OAuth;
|
||||||
using Microsoft.AspNet.Identity.EntityFramework;
|
using Microsoft.AspNet.Identity.EntityFramework;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.Data.Entity;
|
||||||
using Yavsc.Models.Relationship;
|
using System.Web;
|
||||||
using Yavsc.Models.Forms;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models
|
||||||
{
|
{
|
||||||
|
using Relationship;
|
||||||
|
using Forms;
|
||||||
|
using YavscLib;
|
||||||
using Auth;
|
using Auth;
|
||||||
using Billing;
|
using Billing;
|
||||||
using Booking;
|
using Booking;
|
||||||
|
|
@ -21,9 +23,7 @@ namespace Yavsc.Models
|
||||||
using Chat;
|
using Chat;
|
||||||
using Messaging;
|
using Messaging;
|
||||||
using Access;
|
using Access;
|
||||||
using Yavsc.Models.Booking.Profiles;
|
using Booking.Profiles;
|
||||||
using System.Web;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models
|
||||||
{
|
{
|
||||||
|
using YavscLib;
|
||||||
|
|
||||||
public partial class AccountBalance: IAccountBalance {
|
public partial class AccountBalance: IAccountBalance {
|
||||||
[Key]
|
[Key]
|
||||||
|
|
@ -17,4 +18,4 @@ namespace Yavsc.Models
|
||||||
public long ContactCredits { get; set; }
|
public long ContactCredits { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@ using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Yavsc.Models.Billing;
|
|
||||||
using Yavsc.Models.Relationship;
|
|
||||||
using Yavsc.Models.Workflow;
|
|
||||||
|
|
||||||
namespace Yavsc.Models.Booking
|
namespace Yavsc.Models.Booking
|
||||||
{
|
{
|
||||||
|
using YavscLib;
|
||||||
|
using Yavsc.Models.Billing;
|
||||||
|
using Yavsc.Models.Relationship;
|
||||||
|
using Yavsc.Models.Workflow;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query, for a date, with a given perfomer, at this given place.
|
/// Query, for a date, with a given perfomer, at this given place.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -57,4 +58,4 @@ namespace Yavsc.Models.Booking
|
||||||
public virtual Activity Context { get; set ; }
|
public virtual Activity Context { get; set ; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
//
|
|
||||||
// GCMRegisterModel.cs
|
|
||||||
//
|
|
||||||
// Author:
|
|
||||||
// paul <>
|
|
||||||
//
|
|
||||||
// Copyright (c) 2015 paul
|
|
||||||
//
|
|
||||||
// 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.ComponentModel;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Yavsc.Models.Google.Messaging
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// GCM register model.
|
|
||||||
/// </summary>
|
|
||||||
public class GCMRegisterModel {
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the name of the user.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The name of the user.</value>
|
|
||||||
[Localizable(true)]
|
|
||||||
[Display(Name="UserName")]
|
|
||||||
[Required(ErrorMessage = "S'il vous plait, entrez un nom d'utilisateur")]
|
|
||||||
public string UserName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the password.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The password.</value>
|
|
||||||
[DisplayName("Mot de passe")]
|
|
||||||
[Required(ErrorMessage = "S'il vous plait, entez un mot de passe")]
|
|
||||||
public string Password { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the email.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The email.</value>
|
|
||||||
[DisplayName("Adresse e-mail")]
|
|
||||||
[Required(ErrorMessage = "S'il vous plait, entrez un e-mail valide")]
|
|
||||||
public string Email { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the registration identifier against Google Clood Messaging and their info on this application.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The registration identifier.</value>
|
|
||||||
public string RegistrationId { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,7 +5,13 @@ using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Yavsc.Models.Identity
|
namespace Yavsc.Models.Identity
|
||||||
{
|
{
|
||||||
[JsonObject]
|
using YavscLib;
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
|
||||||
|
public class GivenGoogleCloudMobileDeclaration : GoogleCloudMobileDeclaration, IGCMDeclaration {
|
||||||
|
public DateTime? LatestActivityUpdate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class GoogleCloudMobileDeclaration {
|
public class GoogleCloudMobileDeclaration {
|
||||||
|
|
||||||
|
|
@ -22,8 +28,8 @@ namespace Yavsc.Models.Identity
|
||||||
public DateTime DeclarationDate { get; set; }
|
public DateTime DeclarationDate { get; set; }
|
||||||
[JsonIgnore,ForeignKey("DeviceOwnerId")]
|
[JsonIgnore,ForeignKey("DeviceOwnerId")]
|
||||||
public virtual ApplicationUser DeviceOwner { get; set; }
|
public virtual ApplicationUser DeviceOwner { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public DateTime LatestActivityUpdate { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using Yavsc.Interfaces.Workflow;
|
|
||||||
using Yavsc.Models.Market;
|
|
||||||
|
|
||||||
namespace Yavsc.Models.Workflow
|
namespace Yavsc.Models.Workflow
|
||||||
{
|
{
|
||||||
|
using Interfaces.Workflow;
|
||||||
|
using Models.Market;
|
||||||
|
using YavscLib;
|
||||||
|
|
||||||
public class Query<P>: IBaseTrackedEntity where P : BaseProduct
|
public class Query<P>: IBaseTrackedEntity where P : BaseProduct
|
||||||
{
|
{
|
||||||
public DateTime DateCreated
|
public DateTime DateCreated
|
||||||
{
|
{
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Yavsc.Models
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface IAccountBalance
|
public interface IAccountBalance
|
||||||
{
|
{
|
||||||
|
|
@ -6,4 +6,4 @@
|
||||||
decimal Credits { get; set; }
|
decimal Credits { get; set; }
|
||||||
string UserId { get; set; }
|
string UserId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Yavsc.Models.Identity;
|
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface IApplicationUser
|
public interface IApplicationUser
|
||||||
{
|
{
|
||||||
|
|
@ -13,4 +12,4 @@ namespace Yavsc.Models
|
||||||
ILocation PostalAddress { get; set; }
|
ILocation PostalAddress { get; set; }
|
||||||
IList<IBlog> Posts { get; set; }
|
IList<IBlog> Posts { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface IBaseTrackedEntity
|
public interface IBaseTrackedEntity
|
||||||
{
|
{
|
||||||
|
|
@ -9,4 +9,4 @@ namespace Yavsc.Models
|
||||||
DateTime DateModified { get; set; }
|
DateTime DateModified { get; set; }
|
||||||
string UserModified { get; set; }
|
string UserModified { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface IBlog : IBaseTrackedEntity
|
public interface IBlog : IBaseTrackedEntity
|
||||||
{
|
{
|
||||||
|
|
@ -12,4 +12,4 @@ namespace Yavsc.Models
|
||||||
string Title { get; set; }
|
string Title { get; set; }
|
||||||
bool Visible { get; set; }
|
bool Visible { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface ICircle
|
public interface ICircle
|
||||||
{
|
{
|
||||||
|
|
@ -10,4 +10,4 @@ namespace Yavsc.Models
|
||||||
IApplicationUser Owner { get; set; }
|
IApplicationUser Owner { get; set; }
|
||||||
string OwnerId { get; set; }
|
string OwnerId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Yavsc.Models
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface ICircleMember
|
public interface ICircleMember
|
||||||
{
|
{
|
||||||
|
|
@ -6,4 +6,4 @@
|
||||||
long Id { get; set; }
|
long Id { get; set; }
|
||||||
IApplicationUser Member { get; set; }
|
IApplicationUser Member { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Yavsc.Models
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface IContact
|
public interface IContact
|
||||||
{
|
{
|
||||||
|
|
@ -6,4 +6,4 @@
|
||||||
string OwnerId { get; set; }
|
string OwnerId { get; set; }
|
||||||
string UserId { get; set; }
|
string UserId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Yavsc.Models.Identity
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface IGCMDeclaration
|
public interface IGCMDeclaration
|
||||||
{
|
{
|
||||||
|
|
@ -35,4 +35,4 @@ namespace Yavsc.Models.Identity
|
||||||
IApplicationUser DeviceOwner { get; set; }
|
IApplicationUser DeviceOwner { get; set; }
|
||||||
string DeviceOwnerId { get; set; }
|
string DeviceOwnerId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
namespace Yavsc
|
namespace YavscLib
|
||||||
{
|
{
|
||||||
public interface ILocation
|
public interface ILocation
|
||||||
{
|
{
|
||||||
string Address { get; set; }
|
string Address { get; set; }
|
||||||
long Id { get; set; }
|
long Id { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,20 @@
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"targets": {
|
"targets": {
|
||||||
".NETFramework,Version=v4.5.1": {},
|
".NETFramework,Version=v4.5.1": {},
|
||||||
".NETPortable,Version=v4.5,Profile=Profile111": {}
|
".NETPortable,Version=v4.5,Profile=Profile111": {},
|
||||||
|
".NETFramework,Version=v4.5.1/debian.8-x86": {},
|
||||||
|
".NETFramework,Version=v4.5.1/debian.8-x64": {},
|
||||||
|
".NETPortable,Version=v4.5,Profile=Profile111/debian.8-x86": {},
|
||||||
|
".NETPortable,Version=v4.5,Profile=Profile111/debian.8-x64": {}
|
||||||
},
|
},
|
||||||
"libraries": {},
|
"libraries": {},
|
||||||
"projectFileDependencyGroups": {
|
"projectFileDependencyGroups": {
|
||||||
"": [],
|
"": [],
|
||||||
".NETFramework,Version=v4.5.1": [],
|
".NETFramework,Version=v4.5.1": [],
|
||||||
".NETPortable,Version=v4.5,Profile=Profile111": [
|
".NETPortable,Version=v4.5,Profile=Profile111": [
|
||||||
"System.Globalization >= 4.0.0",
|
"fx/System.Runtime >= 4.0.0",
|
||||||
"System.Resources.ResourceManager >= 4.0.0",
|
"fx/System.Globalization >= 4.0.0",
|
||||||
"System.Runtime >= 4.0.0"
|
"fx/System.Resources.ResourceManager >= 4.0.0"
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
"tools": {},
|
|
||||||
"projectFileToolGroups": {}
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue