diff --git a/Yavsc/Controllers/CommandController.cs b/Yavsc/Controllers/CommandController.cs index 3a1e5883..01cddb47 100644 --- a/Yavsc/Controllers/CommandController.cs +++ b/Yavsc/Controllers/CommandController.cs @@ -96,7 +96,7 @@ namespace Yavsc.Controllers ); var pro = _context.Performers.Include( x => x.Performer).FirstOrDefault( - x => x.PerfomerId == id + x => x.PerformerId == id ); if (pro == null) return HttpNotFound(); @@ -107,7 +107,7 @@ namespace Yavsc.Controllers return View(new BookQuery(new Location(),DateTime.Now.AddHours(4)) { PerformerProfile = pro, - PerformerId = pro.PerfomerId, + PerformerId = pro.PerformerId, ClientId = userid, Client = user }); @@ -129,7 +129,7 @@ namespace Yavsc.Controllers u => u.Performer ).Include( u => u.Performer.Devices) .FirstOrDefault( - x => x.PerfomerId == command.PerformerId + x => x.PerformerId == command.PerformerId ); command.PerformerProfile = pro; var user = await _userManager.FindByIdAsync( diff --git a/Yavsc/Controllers/EstimateController.cs b/Yavsc/Controllers/EstimateController.cs index cd2c240c..4b41411b 100644 --- a/Yavsc/Controllers/EstimateController.cs +++ b/Yavsc/Controllers/EstimateController.cs @@ -37,7 +37,7 @@ namespace Yavsc.Controllers return HttpNotFound(); } - RDVEstimate estimate = _context.Estimates + Estimate estimate = _context.Estimates .Include(e => e.Query) .Include(e => e.Query.PerformerProfile) .Include(e => e.Query.PerformerProfile.Performer) @@ -61,7 +61,7 @@ namespace Yavsc.Controllers // POST: Estimate/Create [HttpPost] [ValidateAntiForgeryToken] - public IActionResult Create(RDVEstimate estimate, + public IActionResult Create(Estimate estimate, ICollection newGraphics, ICollection newFiles ) @@ -75,7 +75,7 @@ namespace Yavsc.Controllers var perfomerProfile = _context.Performers .Include( perpr => perpr.Performer).FirstOrDefault( - x=>x.PerfomerId == estimate.Query.PerformerId + x=>x.PerformerId == estimate.Query.PerformerId ); var command = _context.BookQueries.FirstOrDefault( cmd => cmd.Id == estimate.CommandId @@ -115,7 +115,7 @@ namespace Yavsc.Controllers return HttpNotFound(); } - RDVEstimate estimate = _context.Estimates.Single(m => m.Id == id); + Estimate estimate = _context.Estimates.Single(m => m.Id == id); if (estimate == null) { return HttpNotFound(); @@ -127,7 +127,7 @@ namespace Yavsc.Controllers // POST: Estimate/Edit/5 [HttpPost] [ValidateAntiForgeryToken] - public IActionResult Edit(RDVEstimate estimate) + public IActionResult Edit(Estimate estimate) { if (ModelState.IsValid) { @@ -147,7 +147,7 @@ namespace Yavsc.Controllers return HttpNotFound(); } - RDVEstimate estimate = _context.Estimates.Single(m => m.Id == id); + Estimate estimate = _context.Estimates.Single(m => m.Id == id); if (estimate == null) { return HttpNotFound(); @@ -161,7 +161,7 @@ namespace Yavsc.Controllers [ValidateAntiForgeryToken] public IActionResult DeleteConfirmed(long id) { - RDVEstimate estimate = _context.Estimates.Single(m => m.Id == id); + Estimate estimate = _context.Estimates.Single(m => m.Id == id); _context.Estimates.Remove(estimate); _context.SaveChanges(); return RedirectToAction("Index"); diff --git a/Yavsc/Controllers/ManageController.cs b/Yavsc/Controllers/ManageController.cs index 89cbcff7..42b05d62 100644 --- a/Yavsc/Controllers/ManageController.cs +++ b/Yavsc/Controllers/ManageController.cs @@ -102,9 +102,9 @@ namespace Yavsc.Controllers HasDedicatedCalendar = !string.IsNullOrEmpty(user.DedicatedGoogleCalendar), Roles = await _userManager.GetRolesAsync (user) }; - if (_dbContext.Performers.Any(x => x.PerfomerId == user.Id)) + if (_dbContext.Performers.Any(x => x.PerformerId == user.Id)) { - var code = _dbContext.Performers.First(x => x.PerfomerId == user.Id).ActivityCode; + var code = _dbContext.Performers.First(x => x.PerformerId == user.Id).ActivityCode; model.Activity = _dbContext.Activities.First(x => x.Code == code); } return View(model); @@ -461,52 +461,57 @@ namespace Yavsc.Controllers { var user = GetCurrentUserAsync().Result; var uid = user.Id; - bool existing = _dbContext.Performers.Any(x => x.PerfomerId == uid); + bool existing = _dbContext.Performers.Any(x => x.PerformerId == uid); ViewBag.Activities = _dbContext.ActivityItems(null); ViewBag.GoogleSettings = _googleSettings; if (existing) { - var currentProfile = _dbContext.Performers.Include(x => x.OrganisationAddress) - .First(x => x.PerfomerId == uid); + var currentProfile = _dbContext.Performers.Include(x => x.OrganizationAddress) + .First(x => x.PerformerId == uid); string currentCode = currentProfile.ActivityCode; return View(currentProfile); } return View(new PerformerProfile { - PerfomerId = user.Id, - OrganisationAddress = new Location() + PerformerId = user.Id, + OrganizationAddress = new Location() }); } [HttpPost] - [ValidateAntiForgeryToken, Authorize] + [Authorize] public async Task SetActivity(PerformerProfile model) { var user = GetCurrentUserAsync().Result; var uid = user.Id; - - if (ModelState.IsValid) - { - var taskCheck = await _cchecker.CheckAsync(model.SIREN); - if (!taskCheck.success) { - ModelState.AddModelError( - "SIREN", - _SR["Invalid company number"]+" ("+taskCheck.errorCode+")" - ); - _logger.LogWarning("Invalid company number, using key:"+_cinfoSettings.ApiKey); + try {  + if (ModelState.IsValid) + { + var taskCheck = await _cchecker.CheckAsync(model.SIREN); + if (!taskCheck.success) { + ModelState.AddModelError( + "SIREN", + _SR["Invalid company number"]+" ("+taskCheck.errorCode+")" + ); + _logger.LogWarning("Invalid company number, using key:"+_cinfoSettings.ApiKey); + } } } + catch (Exception ex) + { + _logger.LogError(ex.Message); + } if (ModelState.IsValid) { - if (uid == model.PerfomerId) + if (uid == model.PerformerId) { - bool addrexists = _dbContext.Map.Any(x => model.OrganisationAddress.Id == x.Id); + bool addrexists = _dbContext.Map.Any(x => model.OrganizationAddress.Id == x.Id); if (!addrexists) { - _dbContext.Map.Add(model.OrganisationAddress); + _dbContext.Map.Add(model.OrganizationAddress); } - bool existing = _dbContext.Performers.Any(x => x.PerfomerId == uid); + bool existing = _dbContext.Performers.Any(x => x.PerformerId == uid); if (existing) { _dbContext.Update(model); @@ -518,7 +523,7 @@ namespace Yavsc.Controllers return RedirectToAction(nameof(Index), new { Message = message }); } - else ModelState.AddModelError(string.Empty, "Acces denied"); + else ModelState.AddModelError(string.Empty, $"Access denied ({uid} vs {model.PerformerId})"); } ViewBag.GoogleSettings = _googleSettings; ViewBag.Activities = _dbContext.ActivityItems(model.ActivityCode); @@ -530,11 +535,11 @@ namespace Yavsc.Controllers { var user = GetCurrentUserAsync().Result; var uid = user.Id; - bool existing = _dbContext.Performers.Any(x => x.PerfomerId == uid); + bool existing = _dbContext.Performers.Any(x => x.PerformerId == uid); if (existing) { _dbContext.Performers.Remove( - _dbContext.Performers.First(x => x.PerfomerId == uid) + _dbContext.Performers.First(x => x.PerformerId == uid) ); _dbContext.SaveChanges(); }