refactoring & Activities update

main
Paul Schneider 9 years ago
parent 3dcec64d31
commit 47342a3def
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,14 +52,13 @@ 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

@ -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

@ -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]

@ -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>

@ -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,8 +5,14 @@ using Newtonsoft.Json;
namespace Yavsc.Models.Identity namespace Yavsc.Models.Identity
{ {
using YavscLib;
[JsonObject] [JsonObject]
public class GivenGoogleCloudMobileDeclaration : GoogleCloudMobileDeclaration, IGCMDeclaration {
public DateTime? LatestActivityUpdate { get; set; }
}
public class GoogleCloudMobileDeclaration { public class GoogleCloudMobileDeclaration {
[Required] [Required]
@ -23,7 +29,7 @@ namespace Yavsc.Models.Identity
[JsonIgnore,ForeignKey("DeviceOwnerId")] [JsonIgnore,ForeignKey("DeviceOwnerId")]
public virtual ApplicationUser DeviceOwner { get; set; } public virtual ApplicationUser DeviceOwner { get; set; }
public DateTime LatestActivityUpdate { get; set; }
} }
} }

@ -1,9 +1,10 @@
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
{ {

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
{ {

@ -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
{ {

@ -1,6 +1,6 @@
using System; using System;
namespace Yavsc.Models namespace YavscLib
{ {
public interface IBaseTrackedEntity public interface IBaseTrackedEntity
{ {

@ -1,5 +1,5 @@
 
namespace Yavsc.Models namespace YavscLib
{ {
public interface IBlog : IBaseTrackedEntity public interface IBlog : IBaseTrackedEntity
{ {

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Yavsc.Models namespace YavscLib
{ {
public interface ICircle public interface ICircle
{ {

@ -1,4 +1,4 @@
namespace Yavsc.Models namespace YavscLib
{ {
public interface ICircleMember public interface ICircleMember
{ {

@ -1,4 +1,4 @@
namespace Yavsc.Models namespace YavscLib
{ {
public interface IContact public interface IContact
{ {

@ -18,7 +18,7 @@
using System; using System;
namespace Yavsc.Models.Identity namespace YavscLib
{ {
public interface IGCMDeclaration public interface IGCMDeclaration
{ {

@ -1,4 +1,4 @@
namespace Yavsc namespace YavscLib
{ {
public interface ILocation public interface ILocation
{ {

@ -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…