Files
Umbraco-CMS/components/umbraco.webservices/StylesheetService.asmx.cs
Shandem f6d0d043b5 DO NOT DOWNLOAD. DOWNLOAT LATEST STABLE FROM RELEASE TAB
Created 4.1.0 branch

[TFS Changeset #55082]
2009-06-19 07:39:16 +00:00

144 lines
3.9 KiB
C#

using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using umbraco.cms.businesslogic.web;
using umbraco.cms;
using umbraco;
using System.Collections.Generic;
namespace umbraco.webservices.stylesheets
{
/// <summary>
/// Summary description for StylesheetService
/// </summary>
[WebService(Namespace = "http://umbraco.org/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class stylesheetService : BaseWebService
{
override public Services Service
{
get
{
return Services.StylesheetService;
}
}
[WebMethod]
public int create(stylesheetCarrier carrier, string username, string password)
{
Authenticate(username, password);
umbraco.BusinessLogic.User user = GetUser(username, password);
StyleSheet stylesheet = StyleSheet.MakeNew(user, carrier.Name, (carrier.Name + ".css"), carrier.Content );
stylesheet.saveCssToFile();
return stylesheet.Id;
}
[WebMethod]
public stylesheetCarrier read(int id, string username, string password)
{
Authenticate(username, password);
StyleSheet stylesheet;
try
{
stylesheet = new StyleSheet(id);
}
catch (Exception)
{
throw new Exception("Could not load stylesheet with id: " + id + ", not found");
}
if (stylesheet == null)
throw new Exception("Could not load stylesheet with id: " + id + ", not found");
return createCarrier(stylesheet);
}
[WebMethod]
public List<stylesheetCarrier> readList(string username, string password)
{
Authenticate(username, password);
List<stylesheetCarrier> stylesheets = new List<stylesheetCarrier>();
StyleSheet[] foundstylesheets = StyleSheet.GetAll();
foreach (StyleSheet stylesheet in foundstylesheets)
{
stylesheets.Add(createCarrier(stylesheet));
}
return stylesheets;
}
[WebMethod]
public void update(stylesheetCarrier carrier, string username, string password)
{
Authenticate(username, password);
StyleSheet stylesheet = null;
try
{
stylesheet = new StyleSheet(carrier.Id);
}
catch
{}
if (stylesheet == null)
throw new Exception("Could not load stylesheet with id: " + carrier.Id );
stylesheet.Content = carrier.Content;
stylesheet.saveCssToFile();
}
private stylesheetCarrier createCarrier(StyleSheet stylesheet)
{
stylesheetCarrier carrier = new stylesheetCarrier();
carrier.Id = stylesheet.Id;
carrier.Name = stylesheet.Text;
carrier.Content = stylesheet.Content;
return carrier;
}
public class stylesheetCarrier
{
private int id;
private string name;
private string content;
public int Id
{
get { return id; }
set { id = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public string Content
{
get { return content; }
set { content = value; }
}
}
}
}