Paul Schneider 9 years ago
commit 916929d25a
84 changed files with 350 additions and 278 deletions

@ -1,6 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
@ -47,7 +49,7 @@ namespace Yavsc.Controllers
} }
// PUT: api/ActivityApi/5 // PUT: api/ActivityApi/5
[HttpPut("{id}")] [HttpPut("{id}"),Authorize("AdministratorOnly")]
public async Task<IActionResult> PutActivity([FromRoute] string id, [FromBody] Activity activity) public async Task<IActionResult> PutActivity([FromRoute] string id, [FromBody] Activity activity)
{ {
if (!ModelState.IsValid) if (!ModelState.IsValid)
@ -64,7 +66,7 @@ namespace Yavsc.Controllers
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -82,7 +84,7 @@ namespace Yavsc.Controllers
} }
// POST: api/ActivityApi // POST: api/ActivityApi
[HttpPost] [HttpPost,Authorize("AdministratorOnly")]
public async Task<IActionResult> PostActivity([FromBody] Activity activity) public async Task<IActionResult> PostActivity([FromBody] Activity activity)
{ {
if (!ModelState.IsValid) if (!ModelState.IsValid)
@ -93,7 +95,7 @@ namespace Yavsc.Controllers
_context.Activities.Add(activity); _context.Activities.Add(activity);
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -111,7 +113,7 @@ namespace Yavsc.Controllers
} }
// DELETE: api/ActivityApi/5 // DELETE: api/ActivityApi/5
[HttpDelete("{id}")] [HttpDelete("{id}"),Authorize("AdministratorOnly")]
public async Task<IActionResult> DeleteActivity([FromRoute] string id) public async Task<IActionResult> DeleteActivity([FromRoute] string id)
{ {
if (!ModelState.IsValid) if (!ModelState.IsValid)
@ -126,7 +128,7 @@ namespace Yavsc.Controllers
} }
_context.Activities.Remove(activity); _context.Activities.Remove(activity);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return Ok(activity); return Ok(activity);
} }

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
@ -63,7 +64,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -92,7 +93,7 @@ namespace Yavsc.Controllers
_context.Users.Add(applicationUser); _context.Users.Add(applicationUser);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -125,7 +126,7 @@ namespace Yavsc.Controllers
} }
_context.Users.Remove(applicationUser); _context.Users.Remove(applicationUser);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(applicationUser); return Ok(applicationUser);
} }

@ -75,7 +75,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -107,7 +107,7 @@ namespace Yavsc.Controllers
_context.BlackListed.Add(blackListed); _context.BlackListed.Add(blackListed);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -143,7 +143,7 @@ namespace Yavsc.Controllers
return HttpBadRequest(); return HttpBadRequest();
_context.BlackListed.Remove(blackListed); _context.BlackListed.Remove(blackListed);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(blackListed); return Ok(blackListed);
} }

@ -70,7 +70,7 @@ namespace Yavsc.Controllers
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -109,7 +109,7 @@ namespace Yavsc.Controllers
_context.BlogACL.Add(circleAuthorizationToBlogPost); _context.BlogACL.Add(circleAuthorizationToBlogPost);
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -145,7 +145,7 @@ namespace Yavsc.Controllers
return HttpNotFound(); return HttpNotFound();
} }
_context.BlogACL.Remove(circleAuthorizationToBlogPost); _context.BlogACL.Remove(circleAuthorizationToBlogPost);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return Ok(circleAuthorizationToBlogPost); return Ok(circleAuthorizationToBlogPost);
} }

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
@ -62,7 +63,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -91,7 +92,7 @@ namespace Yavsc.Controllers
_context.Blogspot.Add(blog); _context.Blogspot.Add(blog);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -124,7 +125,7 @@ namespace Yavsc.Controllers
} }
_context.Blogspot.Remove(blog); _context.Blogspot.Remove(blog);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(blog); return Ok(blog);
} }

@ -102,7 +102,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -136,7 +136,7 @@ namespace Yavsc.Controllers
_context.Commands.Add(bookQuery); _context.Commands.Add(bookQuery);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -171,7 +171,7 @@ namespace Yavsc.Controllers
if (bookQuery.ClientId != uid) return HttpNotFound(); if (bookQuery.ClientId != uid) return HttpNotFound();
_context.Commands.Remove(bookQuery); _context.Commands.Remove(bookQuery);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(bookQuery); return Ok(bookQuery);
} }

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
@ -64,7 +65,7 @@ namespace Yavsc.Controllers
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -93,7 +94,7 @@ namespace Yavsc.Controllers
_context.Circle.Add(circle); _context.Circle.Add(circle);
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -126,7 +127,7 @@ namespace Yavsc.Controllers
} }
_context.Circle.Remove(circle); _context.Circle.Remove(circle);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return Ok(circle); return Ok(circle);
} }

@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
@ -43,7 +44,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -72,7 +73,7 @@ namespace Yavsc.Controllers
_context.ClientProviderInfo.Add(clientProviderInfo); _context.ClientProviderInfo.Add(clientProviderInfo);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -105,7 +106,7 @@ namespace Yavsc.Controllers
} }
_context.ClientProviderInfo.Remove(clientProviderInfo); _context.ClientProviderInfo.Remove(clientProviderInfo);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(clientProviderInfo); return Ok(clientProviderInfo);
} }

@ -86,7 +86,7 @@ namespace Yavsc.Controllers
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -118,7 +118,7 @@ namespace Yavsc.Controllers
_context.DimissClicked.Add(dimissClicked); _context.DimissClicked.Add(dimissClicked);
try try
{ {
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -155,7 +155,7 @@ namespace Yavsc.Controllers
} }
_context.DimissClicked.Remove(dimissClicked); _context.DimissClicked.Remove(dimissClicked);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return Ok(dimissClicked); return Ok(dimissClicked);
} }

@ -91,7 +91,7 @@ namespace Yavsc.Controllers
var entry = _context.Attach(estimate); var entry = _context.Attach(estimate);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -143,7 +143,7 @@ namespace Yavsc.Controllers
*/ */
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -184,7 +184,7 @@ namespace Yavsc.Controllers
} }
} }
_context.Estimates.Remove(estimate); _context.Estimates.Remove(estimate);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(estimate); return Ok(estimate);
} }

@ -70,7 +70,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -100,7 +100,7 @@ namespace Yavsc.Controllers
_context.EstimateTemplates.Add(estimateTemplate); _context.EstimateTemplates.Add(estimateTemplate);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -137,7 +137,7 @@ namespace Yavsc.Controllers
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden); return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
_context.EstimateTemplates.Remove(estimateTemplate); _context.EstimateTemplates.Remove(estimateTemplate);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(estimateTemplate); return Ok(estimateTemplate);
} }

@ -57,7 +57,7 @@ namespace Yavsc.ApiControllers
foreach (var f in Request.Form.Files) foreach (var f in Request.Form.Files)
{ {
var item = user.ReceiveUserFile(root, f); var item = user.ReceiveUserFile(root, f);
dbContext.SaveChanges(); dbContext.SaveChanges(User.GetUserId());
yield return item; yield return item;
}; };
} }

@ -48,7 +48,7 @@ public class GCMController : Controller
alreadyRegisteredDevice.Platform = declaration.Platform; alreadyRegisteredDevice.Platform = declaration.Platform;
alreadyRegisteredDevice.Version = declaration.Version; alreadyRegisteredDevice.Version = declaration.Version;
_context.Update(alreadyRegisteredDevice); _context.Update(alreadyRegisteredDevice);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
else else
{ {
@ -56,7 +56,7 @@ public class GCMController : Controller
declaration.DeclarationDate = DateTime.Now; declaration.DeclarationDate = DateTime.Now;
declaration.DeviceOwnerId = uid; declaration.DeviceOwnerId = uid;
_context.GCMDevices.Add(declaration as GoogleCloudMobileDeclaration); _context.GCMDevices.Add(declaration as GoogleCloudMobileDeclaration);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
var latestActivityUpdate = _context.Activities.Max(a=>a.DateModified); var latestActivityUpdate = _context.Activities.Max(a=>a.DateModified);
return Json(new { return Json(new {

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
@ -62,7 +63,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -91,7 +92,7 @@ namespace Yavsc.Controllers
_context.MusicalPreferences.Add(musicalPreference); _context.MusicalPreferences.Add(musicalPreference);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -124,7 +125,7 @@ namespace Yavsc.Controllers
} }
_context.MusicalPreferences.Remove(musicalPreference); _context.MusicalPreferences.Remove(musicalPreference);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(musicalPreference); return Ok(musicalPreference);
} }

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
@ -63,7 +64,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -92,7 +93,7 @@ namespace Yavsc.Controllers
_context.MusicalTendency.Add(musicalTendency); _context.MusicalTendency.Add(musicalTendency);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -125,7 +126,7 @@ namespace Yavsc.Controllers
} }
_context.MusicalTendency.Remove(musicalTendency); _context.MusicalTendency.Remove(musicalTendency);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(musicalTendency); return Ok(musicalTendency);
} }

@ -32,14 +32,15 @@ namespace Yavsc.ApiControllers
public PdfEstimateController( public PdfEstimateController(
IAuthorizationService authorizationService, IAuthorizationService authorizationService,
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
IStringLocalizer<Yavsc.Resources.YavscLocalisation> SR,
ApplicationDbContext context) ApplicationDbContext context)
{ {
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
dbContext = context; dbContext = context;
logger = loggerFactory.CreateLogger<PdfEstimateController>(); logger = loggerFactory.CreateLogger<PdfEstimateController>();
this._localizer = SR;
} }
[HttpGet("get/{id}", Name = "Get"), Authorize] [HttpGet("get/{id}", Name = "Get"), Authorize]
public async Task<IActionResult> Get(long id) public async Task<IActionResult> Get(long id)
{ {
@ -89,10 +90,12 @@ namespace Yavsc.ApiControllers
[HttpPost("prosign/{id}")] [HttpPost("prosign/{id}")]
public async Task<IActionResult> ProSign(long id) public async Task<IActionResult> ProSign(long id)
{ {
var uid = User.GetUserId(); var estimate = dbContext.Estimates.
var estimate = dbContext.Estimates.Include( Include(e=>e.Client).Include(e=>e.Client.Devices)
e=>e.Query .Include(e=>e.Bill).Include(e=>e.Owner).Include(e=>e.Owner.Performer)
).FirstOrDefault(e=>e.Id == id && e.OwnerId == uid ); .FirstOrDefault(e=>e.Id == id);
if (estimate == null)
return new BadRequestResult();
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement())) if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
{ {
return new ChallengeResult(); return new ChallengeResult();
@ -101,11 +104,16 @@ namespace Yavsc.ApiControllers
return new BadRequestResult(); return new BadRequestResult();
User.ReceiveProSignature(id,Request.Form.Files[0],"pro"); User.ReceiveProSignature(id,Request.Form.Files[0],"pro");
estimate.ProviderValidationDate = DateTime.Now; estimate.ProviderValidationDate = DateTime.Now;
dbContext.SaveChanges(); dbContext.SaveChanges(User.GetUserId());
// Notify the client // Notify the client
var locstr = _localizer["EstimationMessageToClient"];
var yaev = new EstimationEvent(dbContext,estimate,_localizer); var yaev = new EstimationEvent(dbContext,estimate,_localizer);
var regids = estimate.Client.Devices.Select(d => d.GCMRegistrationId);
var regids = estimate.Client.Devices.Select(d => d.GCMRegistrationId).ToArray();
logger.LogWarning($"new regids: {regids}");
var grep = await _GCMSender.NotifyEstimateAsync(_googleSettings,regids,yaev); var grep = await _GCMSender.NotifyEstimateAsync(_googleSettings,regids,yaev);
logger.LogWarning($"grep: {grep}");
return Ok (new { ProviderValidationDate = estimate.ProviderValidationDate, GCMSent = grep.success }); return Ok (new { ProviderValidationDate = estimate.ProviderValidationDate, GCMSent = grep.success });
} }
@ -130,7 +138,8 @@ namespace Yavsc.ApiControllers
{ {
var uid = User.GetUserId(); var uid = User.GetUserId();
var estimate = dbContext.Estimates.Include( e=>e.Query var estimate = dbContext.Estimates.Include( e=>e.Query
).FirstOrDefault( e=> e.Id == id && e.Query.ClientId == uid ); ).Include(e=>e.Owner).Include(e=>e.Owner.Performer).Include(e=>e.Client)
.FirstOrDefault( e=> e.Id == id && e.Query.ClientId == uid );
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement())) if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
{ {
return new ChallengeResult(); return new ChallengeResult();
@ -139,7 +148,7 @@ namespace Yavsc.ApiControllers
return new BadRequestResult(); return new BadRequestResult();
User.ReceiveProSignature(id,Request.Form.Files[0],"cli"); User.ReceiveProSignature(id,Request.Form.Files[0],"cli");
estimate.ClientValidationDate = DateTime.Now; estimate.ClientValidationDate = DateTime.Now;
dbContext.SaveChanges(); dbContext.SaveChanges(User.GetUserId());
return Ok (new { ClientValidationDate = estimate.ClientValidationDate }); return Ok (new { ClientValidationDate = estimate.ClientValidationDate });
} }

@ -1,14 +1,13 @@
using System.Collections.Generic;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using System.Linq; using System.Linq;
using Yavsc.Models;
using Yavsc.Models.Workflow;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.Data.Entity;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using Models;
[Produces("application/json")] [Produces("application/json")]
[Route("api/performers")] [Route("api/performers")]
public class PerformersApiController : Controller public class PerformersApiController : Controller
@ -24,15 +23,32 @@ namespace Yavsc.Controllers
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[Authorize(Roles="Performer")] [Authorize(Roles="Performer"),HttpGet("{id}")]
public IActionResult Get(string id) public IActionResult Get(string id)
{ {
var pfr = dbContext.Performers.Include(
p=>p.OrganizationAddress
).Include(
p=>p.Performer
).Include(
p=>p.Performer.Posts
).SingleOrDefault(p=> p.PerformerId == id);
if (id==null) if (id==null)
{ {
ModelState.AddModelError("id","Specifier un code activité"); ModelState.AddModelError("id","Specifier un identifiant de prestataire valide");
return new BadRequestObjectResult(ModelState); }
else {
var uid = User.GetUserId();
if (!User.IsInRole("Administrator"))
if (uid != id) return new ChallengeResult();
if (!pfr.Active)
{
ModelState.AddModelError("id","Prestataire désactivé.");
}
} }
return Ok(dbContext.Performers.Where(p=>p.Active && p.PerformerId == id)); if (ModelState.IsValid) return Ok(pfr);
return new BadRequestObjectResult(ModelState);
} }
} }
} }

@ -39,7 +39,7 @@ namespace Yavsc.Controllers
return HttpBadRequest(); return HttpBadRequest();
blogpost.Rate = rate; blogpost.Rate = rate;
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(); return Ok();
} }

@ -6,6 +6,7 @@ using Microsoft.Data.Entity;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using System.Security.Claims;
using Models; using Models;
using Models.Relationship; using Models.Relationship;
@ -64,7 +65,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -93,7 +94,7 @@ namespace Yavsc.Controllers
_context.TagsDomain.Add(postTag); _context.TagsDomain.Add(postTag);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -126,7 +127,7 @@ namespace Yavsc.Controllers
} }
_context.TagsDomain.Remove(postTag); _context.TagsDomain.Remove(postTag);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(postTag); return Ok(postTag);
} }

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
@ -64,7 +65,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -93,7 +94,7 @@ namespace Yavsc.Controllers
_context.Products.Add(product); _context.Products.Add(product);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -126,7 +127,7 @@ namespace Yavsc.Controllers
} }
_context.Products.Remove(product); _context.Products.Remove(product);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(product); return Ok(product);
} }

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
@ -64,7 +65,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -93,7 +94,7 @@ namespace Yavsc.Controllers
_context.Services.Add(service); _context.Services.Add(service);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -126,7 +127,7 @@ namespace Yavsc.Controllers
} }
_context.Services.Remove(service); _context.Services.Remove(service);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(service); return Ok(service);
} }

@ -7,6 +7,7 @@ using Yavsc.Models;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using System.Security.Claims;
using Models.Relationship; using Models.Relationship;
[Produces("application/json")] [Produces("application/json")]
[Route("api/TagsApi")] [Route("api/TagsApi")]
@ -63,7 +64,7 @@ namespace Yavsc.Controllers
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
@ -92,7 +93,7 @@ namespace Yavsc.Controllers
_context.Tags.Add(tag); _context.Tags.Add(tag);
try try
{ {
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
catch (DbUpdateException) catch (DbUpdateException)
{ {
@ -125,7 +126,7 @@ namespace Yavsc.Controllers
} }
_context.Tags.Remove(tag); _context.Tags.Remove(tag);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return Ok(tag); return Ok(tag);
} }

@ -241,7 +241,7 @@ namespace Yavsc.Controllers
var ninfo = _dbContext.UserLogins.First(l=>l.ProviderKey == info.ProviderKey && l.LoginProvider == info.LoginProvider); var ninfo = _dbContext.UserLogins.First(l=>l.ProviderKey == info.ProviderKey && l.LoginProvider == info.LoginProvider);
ninfo.ProviderDisplayName = info.ProviderDisplayName; ninfo.ProviderDisplayName = info.ProviderDisplayName;
_dbContext.Entry(ninfo).State = EntityState.Modified; _dbContext.Entry(ninfo).State = EntityState.Modified;
_dbContext.SaveChanges(); _dbContext.SaveChanges(User.GetUserId());
return Redirect(returnUrl); return Redirect(returnUrl);
} }

@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using System.Security.Claims;
using Models; using Models;
using Models.Workflow; using Models.Workflow;
@ -137,7 +138,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Activities.Add(activity); _context.Activities.Add(activity);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
SetSettingClasseInfo(); SetSettingClasseInfo();
@ -174,7 +175,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(activity); _context.Update(activity);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(activity); return View(activity);
@ -205,7 +206,7 @@ namespace Yavsc.Controllers
{ {
Activity activity = _context.Activities.Single(m => m.Code == id); Activity activity = _context.Activities.Single(m => m.Code == id);
_context.Activities.Remove(activity); _context.Activities.Remove(activity);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -134,7 +134,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Blogspot.Add(blog); _context.Blogspot.Add(blog);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ModelState.AddModelError("Unknown","Invalid Blog posted ..."); ModelState.AddModelError("Unknown","Invalid Blog posted ...");
@ -188,7 +188,7 @@ namespace Yavsc.Controllers
{ {
// saves the change // saves the change
_context.Update(blog); _context.Update(blog);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
ViewData["StatusMessage"] = "Post modified"; ViewData["StatusMessage"] = "Post modified";
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
@ -231,7 +231,7 @@ namespace Yavsc.Controllers
if (auth.Result) if (auth.Result)
{ {
_context.Blogspot.Remove(blog); _context.Blogspot.Remove(blog);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
} }
return RedirectToAction("Index"); return RedirectToAction("Index");
} }

@ -1,4 +1,5 @@
using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
@ -53,7 +54,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Circle.Add(circle); _context.Circle.Add(circle);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(circle); return View(circle);
@ -83,7 +84,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(circle); _context.Update(circle);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(circle); return View(circle);
@ -114,7 +115,7 @@ namespace Yavsc.Controllers
{ {
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id); Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
_context.Circle.Remove(circle); _context.Circle.Remove(circle);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -68,7 +68,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.CircleMembers.Add(circleMember); _context.CircleMembers.Add(circleMember);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ViewData["CircleId"] = new SelectList(_context.Circle, "Id", "Name", circleMember.CircleId); ViewData["CircleId"] = new SelectList(_context.Circle, "Id", "Name", circleMember.CircleId);
@ -102,7 +102,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(circleMember); _context.Update(circleMember);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ViewData["CircleId"] = new SelectList(_context.Circle, "Id", "Circle", circleMember.CircleId); ViewData["CircleId"] = new SelectList(_context.Circle, "Id", "Circle", circleMember.CircleId);
@ -135,7 +135,7 @@ namespace Yavsc.Controllers
{ {
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.MemberId == id); CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.MemberId == id);
_context.CircleMembers.Remove(circleMember); _context.CircleMembers.Remove(circleMember);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -6,6 +6,7 @@ using Microsoft.Data.Entity;
using System.Collections.Generic; using System.Collections.Generic;
using Yavsc.Models; using Yavsc.Models;
using Yavsc.Models.Auth; using Yavsc.Models.Auth;
using System.Security.Claims;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
@ -56,7 +57,7 @@ namespace Yavsc.Controllers
{ {
client.Id = Guid.NewGuid().ToString(); client.Id = Guid.NewGuid().ToString();
_context.Applications.Add(client); _context.Applications.Add(client);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
SetAppTypesInputValues(); SetAppTypesInputValues();
@ -100,7 +101,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(client); _context.Update(client);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(client); return View(client);
@ -131,7 +132,7 @@ namespace Yavsc.Controllers
{ {
Client client = await _context.Applications.SingleAsync(m => m.Id == id); Client client = await _context.Applications.SingleAsync(m => m.Id == id);
_context.Applications.Remove(client); _context.Applications.Remove(client);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.Rendering;
@ -57,7 +58,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.WorkflowProviders.Add(coWorking); _context.WorkflowProviders.Add(coWorking);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId); ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
@ -91,7 +92,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(coWorking); _context.Update(coWorking);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId); ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
@ -124,7 +125,7 @@ namespace Yavsc.Controllers
{ {
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id); CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
_context.WorkflowProviders.Remove(coWorking); _context.WorkflowProviders.Remove(coWorking);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -1,3 +1,4 @@
using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
@ -52,7 +53,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Color.Add(color); _context.Color.Add(color);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(color); return View(color);
@ -82,7 +83,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(color); _context.Update(color);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(color); return View(color);
@ -113,7 +114,7 @@ namespace Yavsc.Controllers
{ {
Color color = await _context.Color.SingleAsync(m => m.Id == id); Color color = await _context.Color.SingleAsync(m => m.Id == id);
_context.Color.Remove(color); _context.Color.Remove(color);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -162,7 +162,7 @@ namespace Yavsc.Controllers
} }
else _context.Attach<Location>(command.Location); else _context.Attach<Location>(command.Location);
_context.BookQueries.Add(command, GraphBehavior.IncludeDependents); _context.BookQueries.Add(command, GraphBehavior.IncludeDependents);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
var yaev = command.CreateEvent(_localizer); var yaev = command.CreateEvent(_localizer);
MessageWithPayloadResponse grep = null; MessageWithPayloadResponse grep = null;
@ -222,7 +222,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(command); _context.Update(command);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(command); return View(command);
@ -253,7 +253,7 @@ namespace Yavsc.Controllers
{ {
BookQuery command = _context.BookQueries.Single(m => m.Id == id); BookQuery command = _context.BookQueries.Single(m => m.Id == id);
_context.BookQueries.Remove(command); _context.BookQueries.Remove(command);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.Rendering;
@ -59,7 +60,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.CommandForm.Add(commandForm); _context.CommandForm.Add(commandForm);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
SetViewBag(commandForm); SetViewBag(commandForm);
@ -91,7 +92,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(commandForm); _context.Update(commandForm);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
SetViewBag(commandForm); SetViewBag(commandForm);
@ -123,7 +124,7 @@ namespace Yavsc.Controllers
{ {
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id); CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
_context.CommandForm.Remove(commandForm); _context.CommandForm.Remove(commandForm);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -78,7 +78,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.UserActivities.Add(userActivity); _context.UserActivities.Add(userActivity);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ViewBag.DoesCode = new SelectList(_context.Activities, "Code", "Name", userActivity.DoesCode); ViewBag.DoesCode = new SelectList(_context.Activities, "Code", "Name", userActivity.DoesCode);
@ -120,7 +120,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(userActivity); _context.Update(userActivity);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ViewData["DoesCode"] = new SelectList(_context.Activities, "Code", "Does", userActivity.DoesCode); ViewData["DoesCode"] = new SelectList(_context.Activities, "Code", "Does", userActivity.DoesCode);
@ -161,7 +161,7 @@ namespace Yavsc.Controllers
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
_context.UserActivities.Remove(userActivity); _context.UserActivities.Remove(userActivity);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -42,7 +42,8 @@ namespace Yavsc.Controllers
.Include(e=>e.Query.PerformerProfile.Performer) .Include(e=>e.Query.PerformerProfile.Performer)
.Where( .Where(
e=>e.OwnerId == uid || e.ClientId == uid e=>e.OwnerId == uid || e.ClientId == uid
).ToList()); ).OrderByDescending(e=>e.ProviderValidationDate)
.ToList());
} }
// GET: Estimate/Details/5 // GET: Estimate/Details/5
@ -101,7 +102,7 @@ namespace Yavsc.Controllers
{ {
_context.Estimates _context.Estimates
.Add(estimate); .Add(estimate);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
var query = _context.BookQueries.FirstOrDefault( var query = _context.BookQueries.FirstOrDefault(
q=>q.Id == estimate.CommandId q=>q.Id == estimate.CommandId
); );
@ -177,7 +178,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(estimate); _context.Update(estimate);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(estimate); return View(estimate);
@ -210,7 +211,7 @@ namespace Yavsc.Controllers
{ {
Estimate estimate = _context.Estimates.Single(m => m.Id == id); Estimate estimate = _context.Estimates.Single(m => m.Id == id);
_context.Estimates.Remove(estimate); _context.Estimates.Remove(estimate);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -1,3 +1,4 @@
using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
@ -52,7 +53,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Form.Add(form); _context.Form.Add(form);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(form); return View(form);
@ -82,7 +83,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(form); _context.Update(form);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(form); return View(form);
@ -113,7 +114,7 @@ namespace Yavsc.Controllers
{ {
Form form = await _context.Form.SingleAsync(m => m.Id == id); Form form = await _context.Form.SingleAsync(m => m.Id == id);
_context.Form.Remove(form); _context.Form.Remove(form);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -79,7 +79,7 @@ namespace Yavsc.Controllers
{ {
_context.BookQueries.Update(bookQuery); _context.BookQueries.Update(bookQuery);
} }
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
// TODO Send sys notifications & // TODO Send sys notifications &
// notify the user (make him a basket badge) // notify the user (make him a basket badge)
return View("Index"); return View("Index");

@ -1,3 +1,4 @@
using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
@ -57,7 +58,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.HairTaint.Add(hairTaint); _context.HairTaint.Add(hairTaint);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId); ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId);
@ -89,7 +90,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(hairTaint); _context.Update(hairTaint);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId); ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId);
@ -121,7 +122,7 @@ namespace Yavsc.Controllers
{ {
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id); HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
_context.HairTaint.Remove(hairTaint); _context.HairTaint.Remove(hairTaint);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -4,17 +4,17 @@ using Microsoft.AspNet.Http.Features;
using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Hosting;
using Yavsc.Models;
using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity;
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using System.Collections.Generic;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using Models;
[ServiceFilter(typeof(LanguageActionFilter)),AllowAnonymous] [ServiceFilter(typeof(LanguageActionFilter)),AllowAnonymous]
public class HomeController : Controller public class HomeController : Controller
{ {

@ -68,7 +68,7 @@ namespace Yavsc.Controllers
return new ChallengeResult(); return new ChallengeResult();
_context.Instrumentation.Add(model); _context.Instrumentation.Add(model);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(model); return View(model);
@ -103,7 +103,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(musicianSettings); _context.Update(musicianSettings);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(musicianSettings); return View(musicianSettings);
@ -142,7 +142,7 @@ namespace Yavsc.Controllers
_context.Instrumentation.Remove(musicianSettings); _context.Instrumentation.Remove(musicianSettings);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -3,6 +3,7 @@ using Microsoft.AspNet.Mvc;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using System.Security.Claims;
using Models; using Models;
using Models.Musical; using Models.Musical;
public class InstrumentsController : Controller public class InstrumentsController : Controller
@ -51,7 +52,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Instrument.Add(instrument); _context.Instrument.Add(instrument);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(instrument); return View(instrument);
@ -81,7 +82,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(instrument); _context.Update(instrument);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(instrument); return View(instrument);
@ -112,7 +113,7 @@ namespace Yavsc.Controllers
{ {
Instrument instrument = _context.Instrument.Single(m => m.Id == id); Instrument instrument = _context.Instrument.Single(m => m.Id == id);
_context.Instrument.Remove(instrument); _context.Instrument.Remove(instrument);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -3,6 +3,7 @@ using Microsoft.AspNet.Mvc;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using System.Security.Claims;
using Models; using Models;
using Models.Relationship; using Models.Relationship;
public class LocationTypesController : Controller public class LocationTypesController : Controller
@ -51,7 +52,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.LocationType.Add(locationType); _context.LocationType.Add(locationType);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(locationType); return View(locationType);
@ -81,7 +82,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(locationType); _context.Update(locationType);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(locationType); return View(locationType);
@ -112,7 +113,7 @@ namespace Yavsc.Controllers
{ {
LocationType locationType = _context.LocationType.Single(m => m.Id == id); LocationType locationType = _context.LocationType.Single(m => m.Id == id);
_context.LocationType.Remove(locationType); _context.LocationType.Remove(locationType);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -25,7 +25,6 @@ namespace Yavsc.Controllers
using Models.Relationship; using Models.Relationship;
using PayPal.PayPalAPIInterfaceService; using PayPal.PayPalAPIInterfaceService;
using PayPal.PayPalAPIInterfaceService.Model; using PayPal.PayPalAPIInterfaceService.Model;
using PayPal.PayPalAPIInterfaceService.Model;
[Authorize, ServiceFilter(typeof(LanguageActionFilter))] [Authorize, ServiceFilter(typeof(LanguageActionFilter))]
public class ManageController : Controller public class ManageController : Controller
@ -295,7 +294,7 @@ namespace Yavsc.Controllers
{ {
var user = _dbContext.Users.FirstOrDefault(u => u.Id == User.GetUserId()); var user = _dbContext.Users.FirstOrDefault(u => u.Id == User.GetUserId());
user.DedicatedGoogleCalendar = model.GoogleCalendarId; user.DedicatedGoogleCalendar = model.GoogleCalendarId;
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync(User.GetUserId());
if (string.IsNullOrEmpty(model.ReturnUrl)) if (string.IsNullOrEmpty(model.ReturnUrl))
return RedirectToAction("Index"); return RedirectToAction("Index");
else return Redirect(model.ReturnUrl); else return Redirect(model.ReturnUrl);
@ -570,7 +569,7 @@ namespace Yavsc.Controllers
_dbContext.Update(model); _dbContext.Update(model);
} }
else _dbContext.Performers.Add(model); else _dbContext.Performers.Add(model);
_dbContext.SaveChanges(); _dbContext.SaveChanges(User.GetUserId());
// Give this user the Performer role // Give this user the Performer role
if (!User.IsInRole("Performer")) if (!User.IsInRole("Performer"))
await _userManager.AddToRoleAsync(user, "Performer"); await _userManager.AddToRoleAsync(user, "Performer");
@ -597,7 +596,7 @@ namespace Yavsc.Controllers
_dbContext.Performers.Remove( _dbContext.Performers.Remove(
_dbContext.Performers.First(x => x.PerformerId == uid) _dbContext.Performers.First(x => x.PerformerId == uid)
); );
_dbContext.SaveChanges(); _dbContext.SaveChanges(User.GetUserId());
await _userManager.RemoveFromRoleAsync(user, "Performer"); await _userManager.RemoveFromRoleAsync(user, "Performer");
} }
var message = ManageMessageId.UnsetActivitySuccess; var message = ManageMessageId.UnsetActivitySuccess;

@ -3,6 +3,7 @@ using Microsoft.AspNet.Mvc;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using System.Security.Claims;
using Models; using Models;
using Models.Musical; using Models.Musical;
public class MusicalTendenciesController : Controller public class MusicalTendenciesController : Controller
@ -51,7 +52,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.MusicalTendency.Add(musicalTendency); _context.MusicalTendency.Add(musicalTendency);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(musicalTendency); return View(musicalTendency);
@ -81,7 +82,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(musicalTendency); _context.Update(musicalTendency);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(musicalTendency); return View(musicalTendency);
@ -112,7 +113,7 @@ namespace Yavsc.Controllers
{ {
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id); MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
_context.MusicalTendency.Remove(musicalTendency); _context.MusicalTendency.Remove(musicalTendency);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -1,7 +1,6 @@
using System.Linq; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Yavsc.Models; using Yavsc.Models;
using Yavsc.Models.Messaging; using Yavsc.Models.Messaging;
@ -54,7 +53,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Notification.Add(notification); _context.Notification.Add(notification);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(notification); return View(notification);
@ -84,7 +83,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(notification); _context.Update(notification);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(notification); return View(notification);
@ -115,7 +114,7 @@ namespace Yavsc.Controllers
{ {
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id); Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
_context.Notification.Remove(notification); _context.Notification.Remove(notification);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Yavsc.Models; using Yavsc.Models;
@ -53,7 +54,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.ExceptionsSIREN.Add(exceptionSIREN); _context.ExceptionsSIREN.Add(exceptionSIREN);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(exceptionSIREN); return View(exceptionSIREN);
@ -83,7 +84,7 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_context.Update(exceptionSIREN); _context.Update(exceptionSIREN);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
return View(exceptionSIREN); return View(exceptionSIREN);
@ -114,7 +115,7 @@ namespace Yavsc.Controllers
{ {
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id); ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
_context.ExceptionsSIREN.Remove(exceptionSIREN); _context.ExceptionsSIREN.Remove(exceptionSIREN);
_context.SaveChanges(); _context.SaveChanges(User.GetUserId());
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
} }

@ -29,6 +29,8 @@ namespace Yavsc.Helpers
using Models.Google.Messaging; using Models.Google.Messaging;
using Models.Messaging; using Models.Messaging;
using Models; using Models;
using Interfaces.Workflow;
/// <summary> /// <summary>
/// Google helpers. /// Google helpers.
@ -73,6 +75,16 @@ namespace Yavsc.Helpers
(this GoogleAuthSettings googleSettings, IEnumerable<string> regids, Event ev) (this GoogleAuthSettings googleSettings, IEnumerable<string> regids, Event ev)
where Event : IEvent where Event : IEvent
{ {
if (ev == null)
throw new Exception("Spécifier un évènement");
if (ev.Message == null)
throw new Exception("Spécifier un message");
if (ev.Sender == null)
throw new Exception("Spécifier un expéditeur");
if (regids == null)
throw new NotImplementedException("Notify & No GCM reg ids");
var msg = new MessageWithPayload<Event>() var msg = new MessageWithPayload<Event>()
{ {
notification = new Notification() notification = new Notification()
@ -84,13 +96,15 @@ namespace Yavsc.Helpers
data = ev, data = ev,
registration_ids = regids.ToArray() registration_ids = regids.ToArray()
}; };
try {
if (regids == null)
throw new NotImplementedException("Notify & No GCM reg ids");
using (var m = new SimpleJsonPostMethod("https://gcm-http.googleapis.com/gcm/send",$"key={googleSettings.ApiKey}")) { using (var m = new SimpleJsonPostMethod("https://gcm-http.googleapis.com/gcm/send",$"key={googleSettings.ApiKey}")) {
return m.Invoke<MessageWithPayloadResponse>(msg); return m.Invoke<MessageWithPayloadResponse>(msg);
} }
} }
catch (Exception ex) {
throw new Exception ("Quelque chose s'est mal passé à l'envoi",ex);
}
}
public static async Task<UserCredential> GetCredentialForGoogleApiAsync(this UserManager<ApplicationUser> userManager, ApplicationDbContext context, string uid) public static async Task<UserCredential> GetCredentialForGoogleApiAsync(this UserManager<ApplicationUser> userManager, ApplicationDbContext context, string uid)
{ {
var user = await userManager.FindByIdAsync(uid); var user = await userManager.FindByIdAsync(uid);

@ -38,7 +38,6 @@ namespace Yavsc
if (Context.User != null) if (Context.User != null)
{ {
isAuth = Context.User.Identity.IsAuthenticated; isAuth = Context.User.Identity.IsAuthenticated;
userName = Context.User.Identity.Name;
var group = isAuth ? var group = isAuth ?
"authenticated" : "anonymous"; "authenticated" : "anonymous";
// Log ("Cx: " + group); // Log ("Cx: " + group);
@ -55,9 +54,8 @@ namespace Yavsc
UserAgent = Context.Request.Headers["User-Agent"], UserAgent = Context.Request.Headers["User-Agent"],
Connected = true Connected = true
}); });
db.SaveChanges(); db.SaveChanges(user.Id);
} }
} }
} }
else Groups.Add(Context.ConnectionId, "anonymous"); else Groups.Add(Context.ConnectionId, "anonymous");
@ -78,16 +76,16 @@ namespace Yavsc
var cx = db.Connections.SingleOrDefault(c => c.ConnectionId == Context.ConnectionId); var cx = db.Connections.SingleOrDefault(c => c.ConnectionId == Context.ConnectionId);
if (cx != null) if (cx != null)
{ {
var user = db.Users.Single(u => u.UserName == userName);
if (stopCalled) if (stopCalled)
{ {
var user = db.Users.Single(u => u.UserName == userName);
user.Connections.Remove(cx); user.Connections.Remove(cx);
} }
else else
{ {
cx.Connected = false; cx.Connected = false;
} }
db.SaveChanges(); db.SaveChanges(user.Id);
} }
} }
} }
@ -110,7 +108,7 @@ namespace Yavsc
if (cx != null) if (cx != null)
{ {
cx.Connected = true; cx.Connected = true;
db.SaveChanges(); db.SaveChanges(user.Id);
} }
else cx = new Connection { ConnectionId = Context.ConnectionId, else cx = new Connection { ConnectionId = Context.ConnectionId,
UserAgent = Context.Request.Headers["User-Agent"], UserAgent = Context.Request.Headers["User-Agent"],
@ -147,10 +145,9 @@ namespace Yavsc
var cx = db.Connections.SingleOrDefault(c=>c.ConnectionId == Context.ConnectionId); var cx = db.Connections.SingleOrDefault(c=>c.ConnectionId == Context.ConnectionId);
if (cx!=null) { if (cx!=null) {
db.Connections.Remove(cx); db.Connections.Remove(cx);
db.SaveChanges(); db.SaveChanges(cx.ApplicationUserId);
} }
} }
} }
} }

@ -1,6 +1,6 @@
namespace Yavsc.Interfaces.Workflow {
public interface IEvent { public interface IEvent {
/// <summary> /// <summary>
/// <c>/topic/(bookquery|estimate)</c> /// <c>/topic/(bookquery|estimate)</c>
/// </summary> /// </summary>
@ -16,4 +16,7 @@ public interface IEvent {
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
string Message { get; set; } string Message { get; set; }
}
} }

@ -1,7 +1,6 @@
using System; using System;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure; using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations; using Microsoft.Data.Entity.Migrations;
using Yavsc.Models; using Yavsc.Models;

@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations; using Microsoft.Data.Entity.Migrations;
using Yavsc.Interfaces.Workflow; using Yavsc.Interfaces.Workflow;

@ -1,7 +1,6 @@
using System; using System;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure; using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations; using Microsoft.Data.Entity.Migrations;
using Yavsc.Models; using Yavsc.Models;

@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations; using Microsoft.Data.Entity.Migrations;
namespace Yavsc.Migrations namespace Yavsc.Migrations

@ -1,7 +1,6 @@
using System; using System;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure; using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations; using Microsoft.Data.Entity.Migrations;
using Yavsc.Models; using Yavsc.Models;

@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations; using Microsoft.Data.Entity.Migrations;
namespace Yavsc.Migrations namespace Yavsc.Migrations

@ -1,7 +1,6 @@
using System; using System;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure; using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations; using Microsoft.Data.Entity.Migrations;
using Yavsc.Models; using Yavsc.Models;

@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations; using Microsoft.Data.Entity.Migrations;
namespace Yavsc.Migrations namespace Yavsc.Migrations

@ -1,8 +1,6 @@
using System; using System;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure; using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
using Yavsc.Models; using Yavsc.Models;
namespace Yavsc.Migrations namespace Yavsc.Migrations

@ -5,10 +5,8 @@ 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 System.Web;
using System.Threading; using System.Threading;
using Yavsc.Models.Haircut; using Yavsc.Models.Haircut;
using Yavsc.Models.Messaging;
namespace Yavsc.Models namespace Yavsc.Models
{ {
@ -28,6 +26,7 @@ namespace Yavsc.Models
using Musical.Profiles; using Musical.Profiles;
using Workflow.Profiles; using Workflow.Profiles;
using Drawing; using Drawing;
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{ {
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)
@ -123,7 +122,7 @@ namespace Yavsc.Models
public Task ClearTokensAsync() public Task ClearTokensAsync()
{ {
Tokens.RemoveRange(this.Tokens); Tokens.RemoveRange(this.Tokens);
SaveChanges(); SaveChanges(null);
return Task.FromResult(0); return Task.FromResult(0);
} }
@ -138,7 +137,7 @@ namespace Yavsc.Models
if (item != null) if (item != null)
{ {
Tokens.Remove(item); Tokens.Remove(item);
SaveChanges(); SaveChanges(email);
} }
return Task.FromResult(0); return Task.FromResult(0);
} }
@ -184,7 +183,7 @@ namespace Yavsc.Models
item.RefreshToken = value.RefreshToken; item.RefreshToken = value.RefreshToken;
Tokens.Update(item); Tokens.Update(item);
} }
SaveChanges(); SaveChanges(googleUserId);
return Task.FromResult(0); return Task.FromResult(0);
} }
@ -225,13 +224,11 @@ namespace Yavsc.Models
public DbSet<GeneralSettings> GeneralSettings { get; set; } public DbSet<GeneralSettings> GeneralSettings { get; set; }
public DbSet<CoWorking> WorkflowProviders { get; set; } public DbSet<CoWorking> WorkflowProviders { get; set; }
private void AddTimestamps() private void AddTimestamps(string currentUsername)
{ {
var entities = ChangeTracker.Entries().Where(x => x.Entity.GetType().GetInterface("IBaseTrackedEntity")!=null && (x.State == EntityState.Added || x.State == EntityState.Modified)); var entities = ChangeTracker.Entries().Where(x => x.Entity.GetType().GetInterface("IBaseTrackedEntity")!=null && (x.State == EntityState.Added || x.State == EntityState.Modified));
var currentUsername = !string.IsNullOrEmpty(System.Web.HttpContext.Current?.User?.Identity?.Name) // Microsoft.AspNet.Identity;
? HttpContext.Current.User.Identity.Name
: "Anonymous";
foreach (var entity in entities) foreach (var entity in entities)
{ {
@ -245,15 +242,13 @@ namespace Yavsc.Models
((IBaseTrackedEntity)entity.Entity).UserModified = currentUsername; ((IBaseTrackedEntity)entity.Entity).UserModified = currentUsername;
} }
} }
public int SaveChanges(string userId) {
AddTimestamps(userId);
override public int SaveChanges() {
AddTimestamps();
return base.SaveChanges(); return base.SaveChanges();
} }
public override async Task<int> SaveChangesAsync(CancellationToken ctoken = default(CancellationToken)) { public async Task<int> SaveChangesAsync(string userId, CancellationToken ctoken = default(CancellationToken)) {
AddTimestamps(); AddTimestamps(userId);
return await base.SaveChangesAsync(); return await base.SaveChangesAsync();
} }

@ -16,6 +16,8 @@ namespace Yavsc.Models.Billing
public string Description { get; set; } public string Description { get; set; }
public BaseProduct Article { get; set; } public BaseProduct Article { get; set; }
public int Count { get; set; } public int Count { get; set; }
[DisplayFormat(DataFormatString="{0:C}")]
public decimal UnitaryCost { get; set; } public decimal UnitaryCost { get; set; }
public long EstimateId { get; set; } public long EstimateId { get; set; }

@ -9,6 +9,7 @@ namespace Yavsc.Models.Billing
{ {
using Interfaces; using Interfaces;
using Models.Workflow; using Models.Workflow;
using Newtonsoft.Json;
public partial class Estimate : IEstimate public partial class Estimate : IEstimate
{ {
@ -22,7 +23,7 @@ namespace Yavsc.Models.Billing
/// it will result in a new estimate template /// it will result in a new estimate template
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[ForeignKey("CommandId")] [ForeignKey("CommandId"),JsonIgnore]
public BookQuery Query { get; set; } public BookQuery Query { get; set; }
public string Description { get; set; } public string Description { get; set; }
public string Title { get; set; } public string Title { get; set; }
@ -62,12 +63,12 @@ namespace Yavsc.Models.Billing
[Required] [Required]
public string OwnerId { get; set; } public string OwnerId { get; set; }
[ForeignKey("OwnerId")] [ForeignKey("OwnerId"),JsonIgnore]
public virtual PerformerProfile Owner { get; set; } public virtual PerformerProfile Owner { get; set; }
[Required] [Required]
public string ClientId { get; set; } public string ClientId { get; set; }
[ForeignKey("ClientId")] [ForeignKey("ClientId"),JsonIgnore]
public virtual ApplicationUser Client { get; set; } public virtual ApplicationUser Client { get; set; }
public string CommandType public string CommandType

@ -2,13 +2,12 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Interfaces.Workflow;
using Yavsc.Models.Market;
using Yavsc.Models.Workflow;
using YavscLib;
namespace Yavsc.Models.Billing namespace Yavsc.Models.Billing
{ {
using Interfaces.Workflow;
using Workflow;
using YavscLib;
public abstract class NominativeServiceCommand : IBaseTrackedEntity, IQuery public abstract class NominativeServiceCommand : IBaseTrackedEntity, IQuery
{ {

@ -1,4 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Models.Billing; using Yavsc.Models.Billing;

@ -1,3 +1,5 @@
using Yavsc.Interfaces.Workflow;
namespace Yavsc.Models.Haircut namespace Yavsc.Models.Haircut
{ {
public class HairCutQueryEvent : BookQueryProviderInfo, IEvent public class HairCutQueryEvent : BookQueryProviderInfo, IEvent

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Models.Market; using Yavsc.Models.Market;
namespace Yavsc.Models.Haircut namespace Yavsc.Models.Haircut

@ -11,6 +11,8 @@ namespace Yavsc.Models
using Models.Chat; using Models.Chat;
using Models.Bank; using Models.Bank;
using Models.Access; using Models.Access;
using Newtonsoft.Json;
public class ApplicationUser : IdentityUser public class ApplicationUser : IdentityUser
{ {
/// <summary> /// <summary>
@ -40,24 +42,24 @@ namespace Yavsc.Models
/// User's posts /// User's posts
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[InverseProperty("Author")] [InverseProperty("Author"),JsonIgnore]
public virtual List<Blog> Posts { get; set; } public virtual List<Blog> Posts { get; set; }
/// <summary> /// <summary>
/// User's contact list /// User's contact list
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[InverseProperty("Owner")] [InverseProperty("Owner"),JsonIgnore]
public virtual List<Contact> Book { get; set; } public virtual List<Contact> Book { get; set; }
/// <summary> /// <summary>
/// External devices using the API /// External devices using the API
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[InverseProperty("DeviceOwner")] [InverseProperty("DeviceOwner"),JsonIgnore]
public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; } public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; }
[InverseProperty("Owner")] [InverseProperty("Owner"),JsonIgnore]
public virtual List<Connection> Connections { get; set; } public virtual List<Connection> Connections { get; set; }
@ -65,7 +67,7 @@ namespace Yavsc.Models
/// User's circles /// User's circles
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[InverseProperty("Owner")] [InverseProperty("Owner"),JsonIgnore]
public virtual List<Circle> Circles { get; set; } public virtual List<Circle> Circles { get; set; }
@ -90,6 +92,7 @@ namespace Yavsc.Models
public long DiskQuota { get; set; } = 512*1024*1024; public long DiskQuota { get; set; } = 512*1024*1024;
public long DiskUsage { get; set; } = 0; public long DiskUsage { get; set; } = 0;
[JsonIgnore]
public virtual List<BlackListed> BlackList { get; set; } public virtual List<BlackListed> BlackList { get; set; }
} }
} }

@ -24,6 +24,8 @@ using System.ComponentModel.DataAnnotations;
namespace Yavsc.Models.Messaging namespace Yavsc.Models.Messaging
{ {
using Interfaces; using Interfaces;
using Interfaces.Workflow;
/// <summary> /// <summary>
/// Base event. /// Base event.
/// </summary> /// </summary>

@ -1,7 +1,3 @@
namespace Yavsc.Models.Messaging
{
// //
// BookQueryEvent.cs // BookQueryEvent.cs
// //
@ -23,6 +19,12 @@ namespace Yavsc.Models.Messaging
// You should have received a copy of the GNU Lesser General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace Yavsc.Models.Messaging
{
using Interfaces.Workflow;
public class BookQueryEvent: BookQueryProviderInfo, IEvent public class BookQueryEvent: BookQueryProviderInfo, IEvent
{ {
public BookQueryEvent() public BookQueryEvent()

@ -1,16 +1,22 @@
using System.Linq; using System.Linq;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Yavsc.Helpers;
using Yavsc.Models.Billing;
namespace Yavsc.Models.Messaging namespace Yavsc.Models.Messaging
{ {
using Interfaces.Workflow;
using Billing;
using Yavsc.Helpers;
public class EstimationEvent: IEvent public class EstimationEvent: IEvent
{ {
public EstimationEvent(ApplicationDbContext context, Estimate estimate, IStringLocalizer SR) public EstimationEvent(ApplicationDbContext context, Estimate estimate, IStringLocalizer SR)
{ {
Topic = "Estimation";
Estimation = estimate; Estimation = estimate;
var perfer = context.Performers.FirstOrDefault( var perfer = context.Performers.Include(
p=>p.Performer
).FirstOrDefault(
p => p.PerformerId == estimate.OwnerId p => p.PerformerId == estimate.OwnerId
); );
// Use estimate.OwnerId; // Use estimate.OwnerId;
@ -27,26 +33,17 @@ namespace Yavsc.Models.Messaging
ProviderClientInfo ProviderInfo { get; set; } ProviderClientInfo ProviderInfo { get; set; }
Estimate Estimation { get; set; } Estimate Estimation { get; set; }
private string subtopic = null; public string Topic
string IEvent.Topic
{
get
{ {
return "/topic/estimate"+subtopic!=null?"/"+subtopic:""; get; set;
}
set
{
subtopic = value;
}
} }
string IEvent.Sender public string Sender
{ {
get; set; get; set;
} }
string IEvent.Message public string Message
{ {
get; set; get; set;
} }

@ -5,7 +5,6 @@ using Newtonsoft.Json;
namespace Yavsc.Models.Workflow namespace Yavsc.Models.Workflow
{ {
using YavscLib;
using Yavsc.Models.Billing; using Yavsc.Models.Billing;
using Yavsc.Models.Relationship; using Yavsc.Models.Relationship;
/// <summary> /// <summary>

@ -5,8 +5,9 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models.Workflow namespace Yavsc.Models.Workflow
{ {
using Models.Relationship; using Models.Relationship;
using YavscLib.Workflow;
public class PerformerProfile { public class PerformerProfile : IPerformerProfile {
[Key] [Key]
public string PerformerId { get; set; } public string PerformerId { get; set; }

@ -1,9 +1,6 @@
using System;
namespace Yavsc.Models.Workflow namespace Yavsc.Models.Workflow
{ {
using Interfaces.Workflow; using Interfaces.Workflow;
using Models.Market;
using YavscLib; using YavscLib;
public interface IQuery: IBaseTrackedEntity public interface IQuery: IBaseTrackedEntity

@ -212,14 +212,13 @@
<data name="EstimateToProduce"><value>Demandes de Devis en souffrance</value></data> <data name="EstimateToProduce"><value>Demandes de Devis en souffrance</value></data>
<data name="EstimateToSignAsPro"><value>Devis à valider</value></data> <data name="EstimateToSignAsPro"><value>Devis à valider</value></data>
<data name="EstimateToSignAsCli"><value>Devis à accèpter ou refuser</value></data> <data name="EstimateToSignAsCli"><value>Devis à accèpter ou refuser</value></data>
<data name="EstimationMessageToClient"><value>{0} à validé et évalué votre demande, avec un devis à {1:C}</value></data>
<data name="EventDate"><value>Date de l'évennement</value></data> <data name="EventDate"><value>Date de l'évennement</value></data>
<data name="BillToSignAsPro"><value>Factures à produire</value></data> <data name="BillToSignAsPro"><value>Factures à produire</value></data>
<data name="BillToSignAsCli"><value>Factures à honnorer</value></data> <data name="BillToSignAsCli"><value>Factures à honnorer</value></data>
<data name="PayementsDone"><value>Paiements effectués</value></data> <data name="PayementsDone"><value>Paiements effectués</value></data>
<data name="EstimationMessageToClient"><value>{0} a validé un devis pour vous : {1}\nAu total : {2} €
Il attend maintenant votre signature.</value></data>
<data name="EstimateWanted"><value>Demande de devis</value></data> <data name="EstimateWanted"><value>Demande de devis</value></data>
<data name="Event date"><value>Date de l'évennement</value></data> <data name="Event date"><value>Date de l'évennement</value></data>
<data name="EventWebPage"><value>Page web de l'événement</value></data> <data name="EventWebPage"><value>Page web de l'événement</value></data>

@ -4,6 +4,8 @@ namespace Yavsc
{ {
public string Title { get; set; } public string Title { get; set; }
public string Slogan { get; set; } public string Slogan { get; set; }
public string Banner { get; set; }
/// <summary> /// <summary>
/// Conceptually, /// Conceptually,
/// This authorisation server only has this present site as unique audience. /// This authorisation server only has this present site as unique audience.

@ -16,7 +16,6 @@ using Microsoft.AspNet.Localization;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNet.Http.Extensions;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -232,6 +231,7 @@ namespace Yavsc
IOptions<RequestLocalizationOptions> localizationOptions, IOptions<RequestLocalizationOptions> localizationOptions,
IOptions<OAuth2AppSettings> oauth2SettingsContainer, IOptions<OAuth2AppSettings> oauth2SettingsContainer,
RoleManager<IdentityRole> roleManager, RoleManager<IdentityRole> roleManager,
UserManager<ApplicationUser> userManager,
IAuthorizationService authorizationService, IAuthorizationService authorizationService,
ILoggerFactory loggerFactory) ILoggerFactory loggerFactory)
{ {
@ -320,7 +320,7 @@ namespace Yavsc
{ {
foreach (var c in db.Connections) foreach (var c in db.Connections)
db.Connections.Remove(c); db.Connections.Remove(c);
db.SaveChanges(); db.SaveChanges("Startup");
} }
}); });
@ -339,13 +339,13 @@ namespace Yavsc
ConfigureWorkflow(app, SiteSetup); ConfigureWorkflow(app, SiteSetup);
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"fr")); app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"fr"));
app.UseSession(); app.UseSession();
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute( routes.MapRoute(
name: "default", name: "default",
template: "{controller=Home}/{action=Index}/{id?}"); template: "{controller=Home}/{action=Index}/{id?}");
}); });
} }
// Entry point for the application. // Entry point for the application.

@ -9,7 +9,6 @@
<div> <div>
<h4>Estimate</h4> <h4>Estimate</h4>
<hr /> <hr />
@Html.DisplayFor(model => model) @Html.DisplayFor(model => model)
<p> <p>
<a asp-action="Edit" asp-route-id="@Model.Id">@SR["Edit"]</a> | <a asp-action="Edit" asp-route-id="@Model.Id">@SR["Edit"]</a> |

@ -12,10 +12,10 @@
<table class="table"> <table class="table">
<tr> <tr>
<th> <th>
@Html.DisplayNameFor(model => model.Description) @Html.DisplayNameFor(model => model.Title)
</th> </th>
<th> <th>
@Html.DisplayNameFor(model => model.Title) @Html.DisplayNameFor(model => model.Description)
</th> </th>
<th> <th>
@Html.DisplayNameFor(model => model.Query.Client) @Html.DisplayNameFor(model => model.Query.Client)
@ -23,6 +23,9 @@
<th> <th>
@SR["Performer"] @SR["Performer"]
</th> </th>
<th>
@Html.DisplayNameFor(model => model.ProviderValidationDate)
</th>
<th> <th>
@SR["Id"] @SR["Id"]
</th> </th>
@ -32,10 +35,10 @@
@foreach (var item in Model) { @foreach (var item in Model) {
<tr> <tr>
<td> <td>
@Html.DisplayFor(modelItem => item.Description) @Html.DisplayFor(modelItem => item.Title)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => item.Title) @Html.DisplayFor(modelItem => item.Description)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => item.Query.Client.UserName) @Html.DisplayFor(modelItem => item.Query.Client.UserName)
@ -43,6 +46,9 @@
<td> <td>
@Html.DisplayFor(modelItem => item.Query.PerformerProfile.Performer.UserName) @Html.DisplayFor(modelItem => item.Query.PerformerProfile.Performer.UserName)
</td> </td>
<td>
@Html.DisplayFor(modelItem => item.ProviderValidationDate)
</td>
<td> <td>
@Html.DisplayFor(modelItem => item.Id) @Html.DisplayFor(modelItem => item.Id)
</td> </td>

@ -27,7 +27,7 @@
<div class="carousel-caption-s" > <div class="carousel-caption-s" >
@if (act.Children.Count>0) { @if (act.Children.Count>0) {
<p><em><a asp-route-id="@act.Code">@act.Name</a></em><br/> <p><em>@act.Name</em><br/>
@act.Description </p> @act.Description </p>
<a asp-route-id="@act.Code"> <a asp-route-id="@act.Code">
@foreach (Activity c in act.Children) { @foreach (Activity c in act.Children) {

@ -1,4 +1,5 @@
@model Estimate @model Estimate
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt> <dt>
@Html.DisplayNameFor(model => model.Title) @Html.DisplayNameFor(model => model.Title)
@ -23,5 +24,8 @@
} }
</dd> </dd>
</dl> </dl>
</div> <label>Signature fournisseur :
<img src="/api/pdfestimate/prosign/@Model.Id" alt="" style="height:100px; background-color: white;">
</label>
@await Component.InvokeAsync("Estimate",Model.Id) @await Component.InvokeAsync("Estimate",Model.Id)

@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no" />
<link rel="icon" href="/favicon.ico?v2" /> <link rel="icon" href="/favicon.ico?v2" />
<title>@ViewData["Title"] - @SiteSettings.Value.Title</title> <title>@ViewData["Title"] - @SiteSettings.Value.Title</title>
<environment names="Development"> <environment names="Development">
<link rel="stylesheet" href="~/css/bootstrap.css" /> <link rel="stylesheet" href="~/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" /> <link rel="stylesheet" href="~/css/site.css" />
@ -32,13 +33,18 @@
<script src="~/js/site.js"></script> <script src="~/js/site.js"></script>
</environment> </environment>
<script src="~/js/jquery.signalR-2.2.1.js"></script> <script src="~/js/jquery.signalR-2.2.1.js"></script>
<style>
nav {
background: url(@Startup.SiteSetup.Banner) 0% 50%;
}
</style>
@RenderSection("header", required: false) @RenderSection("header", required: false)
</head> </head>
<body> <body>
@if (ViewData ["Notify"] != null) { @if (ViewData ["Notify"] != null) {
foreach (Notification n in ViewData ["Notify"] as IEnumerable<Notification>) { foreach (Notification n in ViewData ["Notify"] as IEnumerable<Notification>) {
<div class="alert alert-info alert-dismissable"> <div class="alert alert-info alert-dismissable">
<em><strong>@n.title</strong></em><br> <h1>@n.title</h1><em></em>
@n.body @n.body
<a class="close" data-dismiss="alert" aria-label="close" onclick="notifClick(@n.Id)">@((n.click_action==null)?SR["Fermer"]:SR[n.click_action])</a> <a class="close" data-dismiss="alert" aria-label="close" onclick="notifClick(@n.Id)">@((n.click_action==null)?SR["Fermer"]:SR[n.click_action])</a>
</div> </div>
@ -75,12 +81,7 @@
<environment names="Development"> <environment names="Development">
<p><em>Site de développement</em></p> <p><em>Site de développement</em></p>
</environment> </environment>
<environment names="Lua"> <i>@SiteSettings.Value.Slogan</i>
<i>Get up.</i>
</environment>
<environment names="ZicMoove">
<i>Get up.</i>
</environment>
<script> <script>
window.fbAsyncInit = function() { window.fbAsyncInit = function() {

@ -14,7 +14,8 @@
}, },
"Site": { "Site": {
"Title": "Yavsc", "Title": "Yavsc",
"Slogan":"Yavsc!", "Slogan": "Yavsc!",
"Banner": "/images/banner.jpg",
"Authority": "http://127.0.0.1:5000/", "Authority": "http://127.0.0.1:5000/",
"Audience": "http://127.0.0.1:5000/", "Audience": "http://127.0.0.1:5000/",
"Owner": { "Owner": {

@ -155,10 +155,6 @@ footer {
background-color: rgba(200,256,200,.4); background-color: rgba(200,256,200,.4);
} }
nav {
background: url('/images/arts/musique-3.jpg') 0% 50%;
}
footer { footer {
color:rgb(128,128,128); color:rgb(128,128,128);
font-weight: bolder; font-weight: bolder;

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

@ -0,0 +1,17 @@
namespace YavscLib.Workflow
{
public interface IPerformerProfile
{
string PerformerId { get; set; }
string SIREN { get; set; }
bool AcceptNotifications { get; set; }
long OrganizationAddressId { get; set; }
bool AcceptPublicContact { get; set; }
bool UseGeoLocalizationToReduceDistanceWithClients { get; set; }
string WebSite { get; set; }
bool Active { get; set; }
int? MaxDailyCost { get; set; }
int? MinDailyCost { get; set; }
int Rate { get; set; }
}
}
Loading…