diff --git a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs
index 54b92fb611..26140a611d 100644
--- a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs
@@ -63,9 +63,11 @@ namespace Umbraco.Core.Persistence.Repositories
public override Template Get(string id)
{
- if (!FileSystem.FileExists(id) && !_viewsFileSystem.FileExists(id))
+ string masterpageName = string.Concat(id, ".master");
+ string viewName = string.Concat(id, ".cshtml");
+ if (!FileSystem.FileExists(masterpageName) && !_viewsFileSystem.FileExists(viewName))
{
- throw new Exception(string.Format("The file {0} was not found", id));
+ throw new Exception(string.Format("The file with alias: '{0}' was not found", id));
}
string content = string.Empty;
@@ -74,28 +76,28 @@ namespace Umbraco.Core.Persistence.Repositories
DateTime updated = new DateTime();
string name = string.Empty;
- if(FileSystem.FileExists(id))
+ if (FileSystem.FileExists(masterpageName))
{
- var stream = FileSystem.OpenFile(id);
+ var stream = FileSystem.OpenFile(masterpageName);
byte[] bytes = new byte[stream.Length];
stream.Position = 0;
stream.Read(bytes, 0, (int)stream.Length);
content = Encoding.UTF8.GetString(bytes);
- path = FileSystem.GetRelativePath(id);
+ path = FileSystem.GetRelativePath(masterpageName);
created = FileSystem.GetCreated(path).UtcDateTime;
updated = FileSystem.GetLastModified(path).UtcDateTime;
name = new FileInfo(path).Name;
}
else
{
- var stream = _viewsFileSystem.OpenFile(id);
+ var stream = _viewsFileSystem.OpenFile(viewName);
byte[] bytes = new byte[stream.Length];
stream.Position = 0;
stream.Read(bytes, 0, (int)stream.Length);
content = Encoding.UTF8.GetString(bytes);
- path = _viewsFileSystem.GetRelativePath(id);
+ path = _viewsFileSystem.GetRelativePath(viewName);
created = FileSystem.GetCreated(path).UtcDateTime;
updated = FileSystem.GetLastModified(path).UtcDateTime;
name = new FileInfo(path).Name;
diff --git a/src/Umbraco.Web/Services/DataTypeService.cs b/src/Umbraco.Web/Services/DataTypeService.cs
index 8e71d16469..3ad650c2b2 100644
--- a/src/Umbraco.Web/Services/DataTypeService.cs
+++ b/src/Umbraco.Web/Services/DataTypeService.cs
@@ -121,7 +121,7 @@ namespace Umbraco.Web.Services
}
///
- /// Retrieves the IDataType specified by it's unique ID
+ /// Gets the specified by it's unique ID
///
/// Id of the DataType, which corresponds to the Guid Id of the control
/// object
@@ -131,7 +131,7 @@ namespace Umbraco.Web.Services
}
///
- /// Retrieve a complete list of all registered IDataType's
+ /// Gets a complete list of all registered 's
///
/// An enumerable list of objects
public IEnumerable GetAllDataTypes()
diff --git a/src/Umbraco.Web/Services/FileService.cs b/src/Umbraco.Web/Services/FileService.cs
new file mode 100644
index 0000000000..7470ec81c8
--- /dev/null
+++ b/src/Umbraco.Web/Services/FileService.cs
@@ -0,0 +1,196 @@
+using System.Collections.Generic;
+using Umbraco.Core.Models;
+using Umbraco.Core.Persistence;
+using Umbraco.Core.Persistence.Repositories;
+using Umbraco.Core.Persistence.UnitOfWork;
+
+namespace Umbraco.Web.Services
+{
+ public class FileService : IFileService
+ {
+ private readonly IUnitOfWorkProvider _provider;
+
+ public FileService() : this(new PetaPocoUnitOfWorkProvider())
+ {
+ }
+
+ public FileService(IUnitOfWorkProvider provider)
+ {
+ _provider = provider;
+ }
+
+ ///
+ /// Gets a list of all objects
+ ///
+ /// An enumerable list of objects
+ public IEnumerable GetStylesheets(params string[] names)
+ {
+ var unitOfWork = _provider.GetUnitOfWork();
+ var repository = RepositoryResolver.ResolveByType(unitOfWork);
+ return repository.GetAll(names);
+ }
+
+ ///
+ /// Gets a object by its name
+ ///
+ /// Name of the stylesheet incl. extension
+ /// A object
+ public Stylesheet GetStylesheetByName(string name)
+ {
+ var unitOfWork = _provider.GetUnitOfWork();
+ var repository = RepositoryResolver.ResolveByType(unitOfWork);
+ return repository.Get(name);
+ }
+
+ ///
+ /// Saves a
+ ///
+ /// to save
+ public void SaveStylesheet(Stylesheet stylesheet)
+ {
+ var unitOfWork = _provider.GetUnitOfWork();
+ var repository = RepositoryResolver.ResolveByType(unitOfWork);
+ repository.AddOrUpdate(stylesheet);
+ unitOfWork.Commit();
+ }
+
+ ///
+ /// Deletes a stylesheet by its name
+ ///
+ /// Name incl. extension of the Stylesheet to delete
+ public void DeleteStylesheet(string name)
+ {
+ var unitOfWork = _provider.GetUnitOfWork();
+ var repository = RepositoryResolver.ResolveByType(unitOfWork);
+ var stylesheet = repository.Get(name);
+ repository.Delete(stylesheet);
+ unitOfWork.Commit();
+ }
+
+ ///
+ /// Validates a
+ ///
+ /// to validate
+ /// True if Stylesheet is valid, otherwise false
+ public bool ValidateStylesheet(Stylesheet stylesheet)
+ {
+ return stylesheet.IsValid() && stylesheet.IsFileValidCss();
+ }
+
+ ///
+ /// Gets a list of all objects
+ ///
+ /// An enumerable list of objects
+ public IEnumerable