refactoring & Activities update

vnext
Paul Schneider 8 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>
[Authorize, HttpPost("register")]
public IActionResult Register(
[FromBody] GoogleCloudMobileDeclaration declaration)
[FromBody] GivenGoogleCloudMobileDeclaration declaration)
{
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)
{
var alreadyRegisteredDevice = _context.GCMDevices.FirstOrDefault(d => d.DeviceId == declaration.DeviceId);
var deviceAlreadyRegistered = (alreadyRegisteredDevice!=null);
if (deviceAlreadyRegistered)
{
_logger.LogInformation($"deviceAlreadyRegistered");
// Override an exiting owner
alreadyRegisteredDevice.DeclarationDate = DateTime.Now;
alreadyRegisteredDevice.DeviceOwnerId = uid;
@ -51,17 +52,16 @@ public class GCMController : Controller
}
else
{
_logger.LogInformation($"new device");
declaration.DeclarationDate = DateTime.Now;
declaration.DeviceOwnerId = uid;
_context.GCMDevices.Add(declaration);
_context.GCMDevices.Add(declaration as GoogleCloudMobileDeclaration);
_context.SaveChanges();
}
var latestActivityUpdate = _context.Activities.Aggregate(
(a,b)=>a.DateModified>b.DateModified?a:b
).DateModified;
var latestActivityUpdate = _context.Activities.Max(a=>a.DateModified);
return Json(new {
IsAnUpdate = deviceAlreadyRegistered,
UpdateActivities = latestActivityUpdate>declaration.LatestActivityUpdate
UpdateActivities = latestActivityUpdate > declaration.LatestActivityUpdate
});
}
return new BadRequestObjectResult(ModelState);

@ -4,6 +4,8 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models.Access
{
using YavscLib;
public class Ban : IBaseTrackedEntity
{
public DateTime DateCreated
@ -29,4 +31,4 @@ namespace Yavsc.Models.Access
get; set;
}
}
}
}

@ -5,12 +5,14 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Authentication.OAuth;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
using Yavsc.Models.Relationship;
using Yavsc.Models.Forms;
using System.Web;
using System.Threading;
namespace Yavsc.Models
{
using Relationship;
using Forms;
using YavscLib;
using Auth;
using Billing;
using Booking;
@ -21,9 +23,7 @@ namespace Yavsc.Models
using Chat;
using Messaging;
using Access;
using Yavsc.Models.Booking.Profiles;
using System.Web;
using System.Threading;
using Booking.Profiles;
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
using YavscLib;
public partial class AccountBalance: IAccountBalance {
[Key]
@ -17,4 +18,4 @@ namespace Yavsc.Models
public long ContactCredits { get; set; }
}
}
}

@ -2,12 +2,13 @@ using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Yavsc.Models.Billing;
using Yavsc.Models.Relationship;
using Yavsc.Models.Workflow;
namespace Yavsc.Models.Booking
{
using YavscLib;
using Yavsc.Models.Billing;
using Yavsc.Models.Relationship;
using Yavsc.Models.Workflow;
/// <summary>
/// Query, for a date, with a given perfomer, at this given place.
/// </summary>
@ -57,4 +58,4 @@ namespace Yavsc.Models.Booking
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
{
[JsonObject]
using YavscLib;
[JsonObject]
public class GivenGoogleCloudMobileDeclaration : GoogleCloudMobileDeclaration, IGCMDeclaration {
public DateTime? LatestActivityUpdate { get; set; }
}
public class GoogleCloudMobileDeclaration {
@ -22,8 +28,8 @@ namespace Yavsc.Models.Identity
public DateTime DeclarationDate { get; set; }
[JsonIgnore,ForeignKey("DeviceOwnerId")]
public virtual ApplicationUser DeviceOwner { get; set; }
public DateTime LatestActivityUpdate { get; set; }
}
}

@ -1,11 +1,12 @@
using System;
using Yavsc.Interfaces.Workflow;
using Yavsc.Models.Market;
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
{

File diff suppressed because it is too large Load Diff

@ -1,4 +1,4 @@
namespace Yavsc.Models
namespace YavscLib
{
public interface IAccountBalance
{
@ -6,4 +6,4 @@
decimal Credits { get; set; }
string UserId { get; set; }
}
}
}

@ -1,7 +1,6 @@
using System.Collections.Generic;
using Yavsc.Models.Identity;
namespace Yavsc.Models
namespace YavscLib
{
public interface IApplicationUser
{
@ -13,4 +12,4 @@ namespace Yavsc.Models
ILocation PostalAddress { get; set; }
IList<IBlog> Posts { get; set; }
}
}
}

@ -1,6 +1,6 @@
using System;
namespace Yavsc.Models
namespace YavscLib
{
public interface IBaseTrackedEntity
{
@ -9,4 +9,4 @@ namespace Yavsc.Models
DateTime DateModified { get; set; }
string UserModified { get; set; }
}
}
}

@ -1,5 +1,5 @@

namespace Yavsc.Models
namespace YavscLib
{
public interface IBlog : IBaseTrackedEntity
{
@ -12,4 +12,4 @@ namespace Yavsc.Models
string Title { get; set; }
bool Visible { get; set; }
}
}
}

@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace Yavsc.Models
namespace YavscLib
{
public interface ICircle
{
@ -10,4 +10,4 @@ namespace Yavsc.Models
IApplicationUser Owner { get; set; }
string OwnerId { get; set; }
}
}
}

@ -1,4 +1,4 @@
namespace Yavsc.Models
namespace YavscLib
{
public interface ICircleMember
{
@ -6,4 +6,4 @@
long Id { get; set; }
IApplicationUser Member { get; set; }
}
}
}

@ -1,4 +1,4 @@
namespace Yavsc.Models
namespace YavscLib
{
public interface IContact
{
@ -6,4 +6,4 @@
string OwnerId { get; set; }
string UserId { get; set; }
}
}
}

@ -18,7 +18,7 @@
using System;
namespace Yavsc.Models.Identity
namespace YavscLib
{
public interface IGCMDeclaration
{
@ -35,4 +35,4 @@ namespace Yavsc.Models.Identity
IApplicationUser DeviceOwner { get; set; }
string DeviceOwnerId { get; set; }
}
}
}

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

@ -3,18 +3,20 @@
"version": 2,
"targets": {
".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": {},
"projectFileDependencyGroups": {
"": [],
".NETFramework,Version=v4.5.1": [],
".NETPortable,Version=v4.5,Profile=Profile111": [
"System.Globalization >= 4.0.0",
"System.Resources.ResourceManager >= 4.0.0",
"System.Runtime >= 4.0.0"
"fx/System.Runtime >= 4.0.0",
"fx/System.Globalization >= 4.0.0",
"fx/System.Resources.ResourceManager >= 4.0.0"
]
},
"tools": {},
"projectFileToolGroups": {}
}
}
Loading…