/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Everest.Library;
using Everest.Library.Mvc;
using Everest.Library.Extjs;
using Everest.CmsServices.Services;
using Everest.Library.Data.Rule;
using Everest.CmsServices.Models;
using System.Web.Mvc;
namespace Everest.CmsServices.Controllers{
[PermissionFilter(Permission = FolderType.StaticCode)]
[ValidateInput(false)]
public class StaticCodeController : CmsExtController
{
#region IStandardActions Members
public System.Web.Mvc.ActionResult GetList(string application, string Name)
{
int start, limit;
EnsurePaging(out start, out limit);
StaticCodeService staticCodeService = UnityManager.Resolve<StaticCodeService>();
var staticCodes = staticCodeService.GetStaticCodes(application, Name, true);
staticCodes = OrderByRequest(staticCodes);
ExtJsonReaderObject gridReader = new ExtJsonReaderObject() { Rows = staticCodes.Skip(start).Take(limit), TotalCount = staticCodes.Count() };
return Json(gridReader);
}
public System.Web.Mvc.ActionResult GetDetail(string application, string name)
{
StaticCodeService staticCodeService = UnityManager.Resolve<StaticCodeService>();
var staticCode = staticCodeService.GetStaticCode(application, name);
return Json(new JsonResultData() { data = staticCode });
}
public System.Web.Mvc.ActionResult Submit(bool add, bool? closeForm, string application, string name, string body)
{
JsonResultData resultData = new JsonResultData() { closeForm = closeForm.Value };
StaticCodeService staticCodeService = UnityManager.Resolve<StaticCodeService>();
try
{
if (add)
{
staticCodeService.AddStaticCode(application, name, body);
}
else
{
var oldName = Request.Form["oldData.Name"];
staticCodeService.UpdateStaticCode(application, name, oldName, body);
}
if (closeForm.Value == false)
{
var staticCode = staticCodeService.GetStaticCode(application, name);
resultData.data = staticCode;
}
}
catch (RuleViolationException ruleException)
{
ruleException.Issues.UpdateResultDataWithViolations(resultData);
}
return Json(resultData);
}
public System.Web.Mvc.ActionResult Delete(string[] application, string[] name)
{
StaticCodeService staticCodeService = UnityManager.Resolve<StaticCodeService>();
for (int i = 0; i < application.Length; i++)
{
staticCodeService.DeleteStaticCode(application[i], name[i]);
}
return null;
}
#endregion
}
}
|