92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
10 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Web;
|
||
|
using System.Web.Security;
|
||
10 years ago
|
using System.Web.Http;
|
||
10 years ago
|
using Yavsc.Model.WorkFlow;
|
||
10 years ago
|
using System.Collections.Specialized;
|
||
10 years ago
|
using Yavsc.Model.FrontOffice;
|
||
10 years ago
|
|
||
10 years ago
|
namespace Yavsc.ApiControllers
|
||
10 years ago
|
{
|
||
10 years ago
|
/// <summary>
|
||
|
/// Basket controller.
|
||
10 years ago
|
/// Maintains a collection of articles
|
||
|
/// qualified with name value pairs
|
||
10 years ago
|
/// </summary>
|
||
9 years ago
|
public class BasketController : ApiController
|
||
10 years ago
|
{
|
||
10 years ago
|
/// <summary>
|
||
|
/// The wfmgr.
|
||
|
/// </summary>
|
||
10 years ago
|
protected WorkFlowManager wfmgr = null;
|
||
10 years ago
|
|
||
10 years ago
|
/// <summary>
|
||
|
/// Initialize the specified controllerContext.
|
||
|
/// </summary>
|
||
|
/// <param name="controllerContext">Controller context.</param>
|
||
10 years ago
|
protected override void Initialize (System.Web.Http.Controllers.HttpControllerContext controllerContext)
|
||
|
{
|
||
|
base.Initialize (controllerContext);
|
||
|
wfmgr = new WorkFlowManager ();
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/// <summary>
|
||
|
/// Gets the current basket, creates a new one, if it doesn't exist.
|
||
|
/// </summary>
|
||
|
/// <value>The current basket.</value>
|
||
10 years ago
|
protected CommandSet CurrentBasket {
|
||
10 years ago
|
get {
|
||
10 years ago
|
CommandSet b = wfmgr.GetCommands (Membership.GetUser ().UserName);
|
||
|
if (b == null) b = new CommandSet ();
|
||
10 years ago
|
return b;
|
||
|
}
|
||
|
}
|
||
|
|
||
10 years ago
|
/// <summary>
|
||
|
/// Create the specified basket item using specified command parameters.
|
||
|
/// </summary>
|
||
|
/// <param name="cmdParams">Command parameters.</param>
|
||
10 years ago
|
[Authorize]
|
||
10 years ago
|
public long Create(NameValueCollection cmdParams)
|
||
|
{
|
||
10 years ago
|
// HttpContext.Current.Request.Files
|
||
10 years ago
|
Command cmd = new Command(cmdParams, HttpContext.Current.Request.Files);
|
||
10 years ago
|
CurrentBasket.Add (cmd);
|
||
|
return cmd.Id;
|
||
10 years ago
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Read the specified basket item.
|
||
|
/// </summary>
|
||
|
/// <param name="itemid">Itemid.</param>
|
||
10 years ago
|
[Authorize]
|
||
10 years ago
|
Command Read(long itemid){
|
||
10 years ago
|
return CurrentBasket[itemid];
|
||
10 years ago
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Update the specified item parameter using the specified value.
|
||
|
/// </summary>
|
||
|
/// <param name="itemid">Item identifier.</param>
|
||
|
/// <param name="param">Parameter name.</param>
|
||
|
/// <param name="value">Value.</param>
|
||
10 years ago
|
[Authorize]
|
||
|
public void UpdateParam(long itemid, string param, string value)
|
||
10 years ago
|
{
|
||
10 years ago
|
CurrentBasket [itemid].Parameters [param] = value;
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/// <summary>
|
||
|
/// Delete the specified item.
|
||
|
/// </summary>
|
||
|
/// <param name="itemid">Item identifier.</param>
|
||
10 years ago
|
[Authorize]
|
||
10 years ago
|
public void Delete(long itemid)
|
||
|
{
|
||
10 years ago
|
CurrentBasket.Remove (itemid);
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
}
|
||
|
}
|