using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Everest.CmsServices.Models;
using Everest.CmsServices.Services;
using Everest.Library;
using Everest.Library.ExtensionMethod;
using Sphorium.WebDAV.Server.Framework.BaseClasses;
using Sphorium.WebDAV.Server.Framework.Resources;
namespace Everest.CmsServices.Rfc.WebDAV{
public sealed class DavDelete : DavDeleteBase
{
public DavDelete()
{
this.ProcessDavRequest += new DavProcessEventHandler(DavDelete_ProcessDavRequest);
}
private void DavDelete_ProcessDavRequest(object sender, EventArgs e)
{
WebDavUrlData urlData = new WebDavUrlData(WebDavHelper.GetRawHostUrl(HttpApplication.Request), RelativeRequestPath);
if (urlData.UrlType != WebDavUrlType.Content)
{
base.AbortRequest(DavDeleteResponseCode.Locked);
}
else
{
IEverestCmsDataContext dataContext = EverestCmsEntities.GetDataContext();
var content = dataContext.QueryContent(urlData.Application, urlData.ContentKey).FirstOrDefault();
if (content != null)
{
BinaryContentService binaryContentService = UnityManager.Resolve<BinaryContentService>();
binaryContentService.Delete(content.UUID, WebDavHelper.GetUserName(this.HttpApplication));
}
}
}
}
}
|