diff --git a/Yavsc/Controllers/Haircut/HairCutCommandController.cs b/Yavsc/Controllers/Haircut/HairCutCommandController.cs index ad61db60..9abdd218 100644 --- a/Yavsc/Controllers/Haircut/HairCutCommandController.cs +++ b/Yavsc/Controllers/Haircut/HairCutCommandController.cs @@ -229,6 +229,7 @@ Le client final: {clientFinal} // TODO utiliser Markdown-av+tags var uid = User.GetUserId(); var prid = model.PerformerId; + var brusherProfile = await _context.BrusherProfile.SingleAsync(p => p.UserId == prid); long[] longtaintIds = null; List colors = null; @@ -246,52 +247,52 @@ Le client final: {clientFinal} { _logger.LogInformation("le Model _est_ valide."); var pro = _context.Performers.Include( - u => u.Performer - ).Include(u => u.Performer.Devices) - .FirstOrDefault( - x => x.PerformerId == model.PerformerId - ); - - - if (taintIds != null) - { - longtaintIds = taintIds.Split(',').Select(s => long.Parse(s)).ToArray(); - colors = _context.HairTaint.Where(t => longtaintIds.Contains(t.Id)).ToList(); - // a Prestation is required - model.Prestation.Taints = colors.Select(c => - new HairTaintInstance { Taint = c }).ToList(); - } - - // Une prestation pour enfant ou homme inclut toujours la coupe. - if (model.Prestation.Gender != HairCutGenders.Women) - model.Prestation.Cut = true; - if (model.Location != null) - { - var existingLocation = await _context.Locations.FirstOrDefaultAsync(x => x.Address == model.Location.Address - && x.Longitude == model.Location.Longitude && x.Latitude == model.Location.Latitude); - - if (existingLocation != null) - { - model.Location = existingLocation; - } - else _context.Attach(model.Location); - } - var existingPrestation = await _context.HairPrestation.FirstOrDefaultAsync(x => model.PrestationId == x.Id); - - if (existingPrestation != null) - { - model.Prestation = existingPrestation; - } - else _context.Attach(model.Prestation); - - _context.HairCutQueries.Add(model); - var brusherProfile = await _context.BrusherProfile.SingleAsync(p => p.UserId == pro.PerformerId); - - await _context.SaveChangesAsync(uid); + u => u.Performer + ).Include(u => u.Performer.Devices) + .FirstOrDefault( + x => x.PerformerId == model.PerformerId + ); + + + if (taintIds != null) + { + longtaintIds = taintIds.Split(',').Select(s => long.Parse(s)).ToArray(); + colors = _context.HairTaint.Where(t => longtaintIds.Contains(t.Id)).ToList(); + // a Prestation is required + model.Prestation.Taints = colors.Select(c => + new HairTaintInstance { Taint = c }).ToList(); + } + + // Une prestation pour enfant ou homme inclut toujours la coupe. + if (model.Prestation.Gender != HairCutGenders.Women) + model.Prestation.Cut = true; + if (model.Location != null) + { + var existingLocation = await _context.Locations.FirstOrDefaultAsync(x => x.Address == model.Location.Address + && x.Longitude == model.Location.Longitude && x.Latitude == model.Location.Latitude); + + if (existingLocation != null) + { + model.Location = existingLocation; + } + else _context.Attach(model.Location); + } + var existingPrestation = await _context.HairPrestation.FirstOrDefaultAsync(x => model.PrestationId == x.Id); + + if (existingPrestation != null) + { + model.Prestation = existingPrestation; + } + else _context.Attach(model.Prestation); + + _context.HairCutQueries.Add(model); + + await _context.SaveChangesAsync(uid); _logger.LogInformation("la donnée _est_ sauvée."); - var yaev = model.CreateNewHairCutQueryEvent(_localizer); MessageWithPayloadResponse grep = null; + model.SelectedProfile = brusherProfile; + var yaev = model.CreateNewHairCutQueryEvent(_localizer); if (pro.AcceptPublicContact) { @@ -344,6 +345,7 @@ Le client final: {clientFinal} } ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == model.ActivityCode); ViewBag.GoogleSettings = _googleSettings; + model.SelectedProfile = brusherProfile; SetViewData(model.ActivityCode, model.PerformerId, model.Prestation); return View("HairCut", model); } diff --git a/Yavsc/Controllers/ManageController.cs b/Yavsc/Controllers/ManageController.cs index 788c0917..d0e05ac0 100644 --- a/Yavsc/Controllers/ManageController.cs +++ b/Yavsc/Controllers/ManageController.cs @@ -273,10 +273,14 @@ namespace Yavsc.Controllers [HttpGet] public async Task SetGoogleCalendar(string returnUrl, string pageToken) + { + var calendar = await _calendarManager.GetCalendarsAsync(User.GetUserId(), pageToken); + if (calendar == null) + return new ChallengeResult(); return View(new SetGoogleCalendarViewModel { ReturnUrl = returnUrl, - Calendars = await _calendarManager.GetCalendarsAsync(User.GetUserId(), pageToken) + Calendars = calendar }); } diff --git a/Yavsc/Makefile b/Yavsc/Makefile index 91750ab3..f193d988 100644 --- a/Yavsc/Makefile +++ b/Yavsc/Makefile @@ -2,7 +2,7 @@ DESTDIR=/srv/www/yavscpre PRODDESTDIR=/srv/www/yavsc ASPNET_ENV=Development CONFIGURATION=Release -ASPNET_LOG_LEVEL=warn +ASPNET_LOG_LEVEL=info #warn all: bin/$(CONFIGURATION) diff --git a/Yavsc/Models/HairCut/HairCutQuery.cs b/Yavsc/Models/HairCut/HairCutQuery.cs index dcfe64c7..62871efc 100644 --- a/Yavsc/Models/HairCut/HairCutQuery.cs +++ b/Yavsc/Models/HairCut/HairCutQuery.cs @@ -70,10 +70,8 @@ namespace Yavsc.Models.Haircut List bill = new List(); -#if DEBUG - if (this.Prestation==null) throw new InvalidOperationException("Prestation"); - if (this.SelectedProfile==null) throw new InvalidOperationException("SelectedProfile"); -#endif + if (this.Prestation==null) throw new InvalidOperationException("Prestation property is null"); + if (this.SelectedProfile==null) throw new InvalidOperationException("SelectedProfile property is null"); // Le shampoing if (this.Prestation.Shampoo) bill.Add(new CommandLine { Name = "Shampoing", Description="Shampoing", UnitaryCost = SelectedProfile.ShampooPrice }); diff --git a/Yavsc/Services/GoogleApis/CalendarManager.cs b/Yavsc/Services/GoogleApis/CalendarManager.cs index 32259f56..9c6ff9bd 100644 --- a/Yavsc/Services/GoogleApis/CalendarManager.cs +++ b/Yavsc/Services/GoogleApis/CalendarManager.cs @@ -238,6 +238,7 @@ namespace Yavsc.Services public async Task CreateUserCalendarServiceAsync(string userId) { var login = await _dbContext.GetGoogleUserLoginAsync(userId); + if (login == null) return null; var token = await _flow.LoadTokenAsync(login.ProviderKey, CancellationToken.None); UserCredential cred = new UserCredential(_flow,login.ProviderKey,token); return new CalendarService(new BaseClientService.Initializer() diff --git a/Yavsc/Yavsc.csproj b/Yavsc/Yavsc.csproj deleted file mode 100644 index 8c97faab..00000000 --- a/Yavsc/Yavsc.csproj +++ /dev/null @@ -1,1215 +0,0 @@ - - - - Library - netcoreapp1.0 - debian.8-x64,win10-x64;osx.10.11-x64;ubuntu.16.04-x64 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Yavsc/project.lock.json b/Yavsc/project.lock.json index 5295e340..09ecf866 100644 --- a/Yavsc/project.lock.json +++ b/Yavsc/project.lock.json @@ -261,7 +261,7 @@ "lib/net451/MailKit.dll": {} } }, - "MarkdownDeep-av.NET/1.5.6.3": { + "MarkdownDeep-av.NET/1.5.6": { "type": "package", "compile": { "lib/net451/MarkdownDeep.dll": {} @@ -2834,7 +2834,7 @@ ] } }, - "DNX,Version=v4.5.1/win7-x86": { + "DNX,Version=v4.5.1/debian.9-x86": { "Antlr/3.4.1.9004": { "type": "package", "compile": { @@ -3093,7 +3093,7 @@ "lib/net451/MailKit.dll": {} } }, - "MarkdownDeep-av.NET/1.5.6.3": { + "MarkdownDeep-av.NET/1.5.6": { "type": "package", "compile": { "lib/net451/MarkdownDeep.dll": {} @@ -4136,9 +4136,6 @@ }, "runtime": { "lib/dnx451/Microsoft.AspNet.Server.Kestrel.dll": {} - }, - "native": { - "runtimes/win7-x86/native/libuv.dll": {} } }, "Microsoft.AspNet.Server.WebListener/1.0.0-rc1-final": { @@ -4343,12 +4340,7 @@ } }, "Microsoft.DiaSymReader.Native/1.5.0": { - "type": "package", - "native": { - "runtimes/win/native/Microsoft.DiaSymReader.Native.amd64.dll": {}, - "runtimes/win/native/Microsoft.DiaSymReader.Native.arm.dll": {}, - "runtimes/win/native/Microsoft.DiaSymReader.Native.x86.dll": {} - } + "type": "package" }, "Microsoft.Dnx.Compilation.Abstractions/1.0.0-rc1-final": { "type": "package", @@ -5674,7 +5666,7 @@ ] } }, - "DNX,Version=v4.5.1/win7-x64": { + "DNX,Version=v4.5.1/debian.9-x64": { "Antlr/3.4.1.9004": { "type": "package", "compile": { @@ -5933,7 +5925,7 @@ "lib/net451/MailKit.dll": {} } }, - "MarkdownDeep-av.NET/1.5.6.3": { + "MarkdownDeep-av.NET/1.5.6": { "type": "package", "compile": { "lib/net451/MarkdownDeep.dll": {} @@ -6976,9 +6968,6 @@ }, "runtime": { "lib/dnx451/Microsoft.AspNet.Server.Kestrel.dll": {} - }, - "native": { - "runtimes/win7-x64/native/libuv.dll": {} } }, "Microsoft.AspNet.Server.WebListener/1.0.0-rc1-final": { @@ -7183,12 +7172,7 @@ } }, "Microsoft.DiaSymReader.Native/1.5.0": { - "type": "package", - "native": { - "runtimes/win/native/Microsoft.DiaSymReader.Native.amd64.dll": {}, - "runtimes/win/native/Microsoft.DiaSymReader.Native.arm.dll": {}, - "runtimes/win/native/Microsoft.DiaSymReader.Native.x86.dll": {} - } + "type": "package" }, "Microsoft.Dnx.Compilation.Abstractions/1.0.0-rc1-final": { "type": "package", @@ -8743,15 +8727,15 @@ "MailKit.nuspec" ] }, - "MarkdownDeep-av.NET/1.5.6.3": { + "MarkdownDeep-av.NET/1.5.6": { "type": "package", - "sha512": "ToMBBut9I6k5WV3lv42D7NTwqL67+JS5CNVgc89+3gVk8n1Y2faSbNOKv1qfYQ0Dt9591iAZyIGhBdnptxzX5A==", + "sha512": "/nK/Hzru+vAmNGX5tZtEkKxCqjUS8a/u1vZaQ4pEmlvm6C9IIJ5rWIJephDWVwbzi6eKdEeduU+xmPfLNXrQwQ==", "files": [ "lib/dnxcore50/MarkdownDeep.dll", + "lib/MonoAndroid10/MarkdownDeep.dll", "lib/net451/MarkdownDeep.dll", - "lib/portable-net45+win8+wpa81+wp8/MarkdownDeep.dll", - "MarkdownDeep-av.NET.1.5.6.3.nupkg", - "MarkdownDeep-av.NET.1.5.6.3.nupkg.sha512", + "MarkdownDeep-av.NET.1.5.6.nupkg", + "MarkdownDeep-av.NET.1.5.6.nupkg.sha512", "MarkdownDeep-av.NET.nuspec" ] }, @@ -11014,7 +10998,7 @@ "System.Reflection.Metadata/1.1.0": { "type": "package", "serviceable": true, - "sha512": "RLIE4sSt2zngMLuqM6YmxBH99mTumtT4DNZE4+msfEaInUP5iCLQT+BHPl+2cjSAP1pdALyAjLB8RtCB+WGGWQ==", + "sha512": "a8VsRm/B0Ik1o5FumSMWmpwbG7cvIIajAYhzTTy9VB9XItByJDQHGZkQTIAdsvVJ6MI5O3uH/lb0izgQDlDIWA==", "files": [ "lib/dotnet5.2/System.Reflection.Metadata.dll", "lib/dotnet5.2/System.Reflection.Metadata.xml",