Fixes U4-1619 so MediaTypes are deleted the same way as DocumentTypes using the legacy api/backoffice.

This commit is contained in:
Morten Christensen
2013-02-06 09:43:53 -01:00
parent 32d36d66c9
commit 0853f8da85
2 changed files with 8 additions and 5 deletions

View File

@@ -358,7 +358,7 @@ namespace Umbraco.Core.Services
if (DeletingMediaType.IsRaisedEventCancelled(new DeleteEventArgs<IMediaType>(mediaType), this))
return;
_mediaService.DeleteMediaOfType(mediaType.Id);
_mediaService.DeleteMediaOfType(mediaType.Id, userId);
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaTypeRepository(uow))

View File

@@ -150,10 +150,13 @@ namespace umbraco.cms.businesslogic.media
if (!e.Cancel)
{
// delete all documents of this type
Media.DeleteFromType(this);
// Delete contentType
base.delete();
// check that no media types uses me as a master
if (GetAllAsList().Any(dt => dt.MasterContentTypes.Contains(this.Id)))
{
throw new ArgumentException("Can't delete a Media Type used as a Master Content Type. Please remove all references first!");
}
ApplicationContext.Current.Services.ContentTypeService.Delete(_mediaType);
FireAfterDelete(e);
}