/*
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.Collections.Generic;
namespace Everest.Library.Extjs{
public class FormError
{
public string id { get; set; }
public string msg { get; set; }
}
/// <summary>
/// use in load ext form's data format
/// </summary>
/// <typeparam name="T"></typeparam>
public class JsonResultData
{
/// <summary>
/// Gets or sets a value indicating whether this <see cref="FormResultData"/> is success.
/// depend on Ext.form.Action.Submit
/// </summary>
/// <value><c>true</c> if success; otherwise, <c>false</c>.</value>
public bool success { get; set; }
public bool closeForm { get; set; }
/// <summary>
/// Gets or sets the errors. see:extjs Ext.form.BasicForm.markInvalid and Ext.form.Action.Submit
/// </summary>
/// <value>The errors.</value>
public IList<FormError> errors { get; set; }
/// <summary>
/// Gets or sets the data.
/// </summary>
/// <value>The data.</value>
public object data { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="JsonResultData"/> class.
/// </summary>
public JsonResultData()
{
this.errors = new List<FormError>();
this.success = true;
closeForm = true;
}
public void AddError(string fieldName, string errorMessage)
{
success = false;
errors.Add(new FormError() { id = fieldName, msg = errorMessage });
}
private string exceptionMessage;
/// <summary>
/// Gets or sets the exception message.
/// </summary>
/// <value>The exception.</value>
public string message
{
get
{
return exceptionMessage;
}
set
{
if (!string.IsNullOrEmpty(value))
{
success = false;
}
else
{
success = true;
}
exceptionMessage = value;
}
}
private string _warning;
public string warning {
get
{
return _warning;
}
set
{
if (!string.IsNullOrEmpty(value))
{
success = false;
}
else
{
success = true;
}
_warning = value;
}
}
}
}
|