a5fcb46e04
Transaction updates
25 lines
633 B
C#
25 lines
633 B
C#
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using InventoryTraker.Web.ActionResults;
|
|
|
|
namespace InventoryTraker.Web.Controllers
|
|
{
|
|
public abstract class ControllerBase : Controller
|
|
{
|
|
public BetterJsonResult<T> BetterJson<T>(T model)
|
|
{
|
|
return new BetterJsonResult<T> {Data = model};
|
|
}
|
|
|
|
protected JsonResult PackageModelStateErrors()
|
|
{
|
|
var betterJsonResult = new BetterJsonResult();
|
|
foreach (var err in ModelState.Where(ms => ms.Value.Errors.Any()))
|
|
{
|
|
betterJsonResult.AddError(
|
|
err.Key + ": " + string.Join(", ", err.Value.Errors.Select(e => e.ErrorMessage)));
|
|
}
|
|
return betterJsonResult;
|
|
}
|
|
}
|
|
} |