diff --git a/Yavsc/ApiControllers/FileSystemApiController.cs b/Yavsc/ApiControllers/FileSystemApiController.cs index 1c97da77..0007931f 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 cd520610..8c1ee258 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 11af45ff..6ab7872d 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 741bd136..49ff920a 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 fb77a426..612305ae 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 06bbaf4b..a159a817 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 0bdf72d3..64b4fefb 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 f663c9cc..ec13bfdc 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 ed1f270e..0b3b7f48 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 1c9cb9b3..378421b8 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 d7519589..525c0eec 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 b53ba54c..40a3fcef 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 64a4a3d4..a038f53c 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 d51d25e1..ae91898d 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 1c5c9bb4..c0faf7b7 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 b9a8c1a6..09650e1b 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 f1acabed..5ba02628 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 1020541f..2a476c16 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