From 40add7b99057b5bc1917df2c918568ba6faf2857 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 28 May 2017 00:42:27 +0200 Subject: [PATCH] compilation warnings --- .../ApiControllers/FileSystemApiController.cs | 35 ++++++++++++++++--- .../Controllers/Generic/SettingsController.cs | 5 ++- Yavsc/Helpers/FileSystemHelpers.cs | 9 ++++- Yavsc/Interfaces/ICircleMember.cs | 4 +-- .../20170526020220_rdvPayment.Designer.cs | 1 - Yavsc/Models/Billing/Estimate.cs | 1 - Yavsc/Models/Blog/Blog.cs | 1 - Yavsc/Models/HairCut/BrusherProfile.cs | 1 - .../Models/HairCut/Views/HaircutQueryInfo.cs | 1 - Yavsc/Models/IT/Modeling/Code.cs | 1 - Yavsc/Models/IT/Modeling/Letter.cs | 2 -- Yavsc/Models/Musical/Profiles/DjSettings.cs | 1 - .../Musical/Profiles/GeneralSettings.cs | 1 - .../Musical/Profiles/Instrumentation.cs | 1 - Yavsc/Startup/Startup.Workflow.cs | 5 ++- Yavsc/Startup/Startup.cs | 1 - .../CirclesControlViewComponent.cs | 7 ++-- .../Relationship/CirclesViewModel.cs | 2 -- 18 files changed, 46 insertions(+), 33 deletions(-) diff --git a/Yavsc/ApiControllers/FileSystemApiController.cs b/Yavsc/ApiControllers/FileSystemApiController.cs index 1c97da774..0007931f5 100644 --- a/Yavsc/ApiControllers/FileSystemApiController.cs +++ b/Yavsc/ApiControllers/FileSystemApiController.cs @@ -9,6 +9,7 @@ using Yavsc.Models; namespace Yavsc.ApiControllers { + using System.Threading.Tasks; using Yavsc.Exceptions; public class FSQuotaException : Exception { @@ -43,16 +44,20 @@ namespace Yavsc.ApiControllers return Ok(files); } - [HttpPost] public IEnumerable Post(string subdir="") { string root = null; + + InvalidPathException pathex = null; try { - root = User.InitPostToFileSystem(subdir); - } catch (InvalidPathException) {} - if (root==null) - yield return new BadRequestObjectResult(new { error= "InvalidPathException" }); + root = User.InitPostToFileSystem(subdir); + } catch (InvalidPathException ex) { + pathex = ex; + } + if (pathex!=null) + yield return new BadRequestObjectResult(pathex); + var user = dbContext.Users.Single( u => u.Id == User.GetUserId() ); @@ -64,5 +69,25 @@ namespace Yavsc.ApiControllers yield return Ok(item); }; } + + [HttpDelete] + public async Task Delete (string id) + { + var user = dbContext.Users.Single( + u => u.Id == User.GetUserId() + ); + InvalidPathException pathex = null; + string root = null; + try { + root = User.InitPostToFileSystem(id); + } catch (InvalidPathException ex) { + pathex = ex; + } + if (pathex!=null) + return new BadRequestObjectResult(pathex); + user.DeleteUserFile(id); + await dbContext.SaveChangesAsync(User.GetUserId()); + return Ok(new { deleted=id }); + } } } diff --git a/Yavsc/Controllers/Generic/SettingsController.cs b/Yavsc/Controllers/Generic/SettingsController.cs index cd5206103..8c1ee258e 100644 --- a/Yavsc/Controllers/Generic/SettingsController.cs +++ b/Yavsc/Controllers/Generic/SettingsController.cs @@ -3,12 +3,11 @@ using System.Threading.Tasks; using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Mvc; using Microsoft.Data.Entity; -using Yavsc.Exceptions; -using Yavsc.Models; -using Yavsc; namespace Yavsc.Controllers.Generic { + using Exceptions; + using Models; [Authorize] public abstract class SettingsController : Controller where TSettings : class, ISpecializationSettings, new() { diff --git a/Yavsc/Helpers/FileSystemHelpers.cs b/Yavsc/Helpers/FileSystemHelpers.cs index 11af45fff..6ab7872d7 100644 --- a/Yavsc/Helpers/FileSystemHelpers.cs +++ b/Yavsc/Helpers/FileSystemHelpers.cs @@ -65,7 +65,14 @@ namespace Yavsc.Helpers return root; } - + public static void DeleteUserFile(this ApplicationUser user, string fileName) + { + var root = Path.Combine(Startup.UserFilesDirName, user.UserName); + var fi = new FileInfo(Path.Combine(root, fileName)); + if (!fi.Exists) return ; + fi.Delete(); + user.DiskUsage -= fi.Length; + } public static FileRecievedInfo ReceiveUserFile(this ApplicationUser user, string root, IFormFile f) { long usage = user.DiskUsage; diff --git a/Yavsc/Interfaces/ICircleMember.cs b/Yavsc/Interfaces/ICircleMember.cs index 741bd136d..49ff920ac 100644 --- a/Yavsc/Interfaces/ICircleMember.cs +++ b/Yavsc/Interfaces/ICircleMember.cs @@ -1,6 +1,4 @@ -using Yavsc; - -namespace Yavsc.Interfaces +namespace Yavsc.Interfaces { public interface ICircleMember: IIdentified { diff --git a/Yavsc/Migrations/20170526020220_rdvPayment.Designer.cs b/Yavsc/Migrations/20170526020220_rdvPayment.Designer.cs index fb77a426a..612305aef 100644 --- a/Yavsc/Migrations/20170526020220_rdvPayment.Designer.cs +++ b/Yavsc/Migrations/20170526020220_rdvPayment.Designer.cs @@ -1,7 +1,6 @@ using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; -using Microsoft.Data.Entity.Metadata; using Microsoft.Data.Entity.Migrations; using Yavsc.Models; diff --git a/Yavsc/Models/Billing/Estimate.cs b/Yavsc/Models/Billing/Estimate.cs index 06bbaf4bd..a159a817c 100644 --- a/Yavsc/Models/Billing/Estimate.cs +++ b/Yavsc/Models/Billing/Estimate.cs @@ -9,7 +9,6 @@ namespace Yavsc.Models.Billing { using Models.Workflow; using Newtonsoft.Json; - using Yavsc.Workflow; public partial class Estimate : IEstimate { diff --git a/Yavsc/Models/Blog/Blog.cs b/Yavsc/Models/Blog/Blog.cs index 0bdf72d34..64b4fefbc 100644 --- a/Yavsc/Models/Blog/Blog.cs +++ b/Yavsc/Models/Blog/Blog.cs @@ -5,7 +5,6 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using Newtonsoft.Json; using Yavsc.Models.Access; -using Yavsc; namespace Yavsc.Models { diff --git a/Yavsc/Models/HairCut/BrusherProfile.cs b/Yavsc/Models/HairCut/BrusherProfile.cs index f663c9cc4..ec13bfdcb 100644 --- a/Yavsc/Models/HairCut/BrusherProfile.cs +++ b/Yavsc/Models/HairCut/BrusherProfile.cs @@ -2,7 +2,6 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; using Yavsc.Models.Workflow; -using Yavsc; namespace Yavsc.Models.Haircut { diff --git a/Yavsc/Models/HairCut/Views/HaircutQueryInfo.cs b/Yavsc/Models/HairCut/Views/HaircutQueryInfo.cs index ed1f270e9..0b3b7f489 100644 --- a/Yavsc/Models/HairCut/Views/HaircutQueryInfo.cs +++ b/Yavsc/Models/HairCut/Views/HaircutQueryInfo.cs @@ -2,7 +2,6 @@ using System; using System.ComponentModel.DataAnnotations; using Yavsc.Models.Auth; using Yavsc.Models.Relationship; -using Yavsc; namespace Yavsc.Models.Haircut.Views { diff --git a/Yavsc/Models/IT/Modeling/Code.cs b/Yavsc/Models/IT/Modeling/Code.cs index 1c9cb9b3e..378421b89 100644 --- a/Yavsc/Models/IT/Modeling/Code.cs +++ b/Yavsc/Models/IT/Modeling/Code.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using Yavsc; namespace Yavsc.Models.IT.Modeling { diff --git a/Yavsc/Models/IT/Modeling/Letter.cs b/Yavsc/Models/IT/Modeling/Letter.cs index d75195894..525c0eec9 100644 --- a/Yavsc/Models/IT/Modeling/Letter.cs +++ b/Yavsc/Models/IT/Modeling/Letter.cs @@ -1,6 +1,4 @@ -using Yavsc; - namespace Yavsc.Models.IT.Modeling { public abstract class Letter : ILetter diff --git a/Yavsc/Models/Musical/Profiles/DjSettings.cs b/Yavsc/Models/Musical/Profiles/DjSettings.cs index b53ba54c0..40a3fcefd 100644 --- a/Yavsc/Models/Musical/Profiles/DjSettings.cs +++ b/Yavsc/Models/Musical/Profiles/DjSettings.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using Yavsc; namespace Yavsc.Models.Musical.Profiles { diff --git a/Yavsc/Models/Musical/Profiles/GeneralSettings.cs b/Yavsc/Models/Musical/Profiles/GeneralSettings.cs index 64a4a3d4c..a038f53c0 100644 --- a/Yavsc/Models/Musical/Profiles/GeneralSettings.cs +++ b/Yavsc/Models/Musical/Profiles/GeneralSettings.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using Yavsc; namespace Yavsc.Models.Musical.Profiles { diff --git a/Yavsc/Models/Musical/Profiles/Instrumentation.cs b/Yavsc/Models/Musical/Profiles/Instrumentation.cs index d51d25e11..ae91898d4 100644 --- a/Yavsc/Models/Musical/Profiles/Instrumentation.cs +++ b/Yavsc/Models/Musical/Profiles/Instrumentation.cs @@ -1,6 +1,5 @@ using System.ComponentModel.DataAnnotations.Schema; using Yavsc.Models.Workflow; -using Yavsc; namespace Yavsc.Models.Musical.Profiles { diff --git a/Yavsc/Startup/Startup.Workflow.cs b/Yavsc/Startup/Startup.Workflow.cs index 1c5c9bb4e..c0faf7b7d 100644 --- a/Yavsc/Startup/Startup.Workflow.cs +++ b/Yavsc/Startup/Startup.Workflow.cs @@ -4,12 +4,11 @@ using System.Linq; using System.Reflection; using Microsoft.AspNet.Builder; using Microsoft.Extensions.Logging; -using Yavsc.Exceptions; -using Yavsc.Models; -using Yavsc; namespace Yavsc { + using Exceptions; + using Models; public partial class Startup { /// diff --git a/Yavsc/Startup/Startup.cs b/Yavsc/Startup/Startup.cs index b9a8c1a69..09650e1b2 100755 --- a/Yavsc/Startup/Startup.cs +++ b/Yavsc/Startup/Startup.cs @@ -28,7 +28,6 @@ namespace Yavsc using System.Net; using Formatters; using Models; - using Newtonsoft.Json; using PayPal.Manager; using Services; using ViewModels.Auth.Handlers; diff --git a/Yavsc/ViewComponents/CirclesControlViewComponent.cs b/Yavsc/ViewComponents/CirclesControlViewComponent.cs index f1acabed5..5ba02628a 100644 --- a/Yavsc/ViewComponents/CirclesControlViewComponent.cs +++ b/Yavsc/ViewComponents/CirclesControlViewComponent.cs @@ -1,13 +1,12 @@ using System.Linq; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.Rendering; -using Yavsc.Models; -using Yavsc.ViewModels.Controls; -using Yavsc.ViewModels.Relationship; -using Yavsc; namespace Yavsc.ViewComponents { + using Models; + using ViewModels.Controls; + using ViewModels.Relationship; public class CirclesControlViewComponent : ViewComponent { ApplicationDbContext dbContext; diff --git a/Yavsc/ViewModels/Relationship/CirclesViewModel.cs b/Yavsc/ViewModels/Relationship/CirclesViewModel.cs index 1020541f9..2a476c16e 100644 --- a/Yavsc/ViewModels/Relationship/CirclesViewModel.cs +++ b/Yavsc/ViewModels/Relationship/CirclesViewModel.cs @@ -1,5 +1,3 @@ -using Yavsc; - namespace Yavsc.ViewModels.Relationship { public class CirclesViewModel