* Basket.aspx: refactoring
* NpgsqlContentProvider.cs: fixing the command parameters deserialisation * NpgsqlWorkflow.csproj: prehaps not needed new references * FrontOfficeController.cs: code formatting * Command.aspx: a link to the basket * Commande.cs: In order the deserialize from Json
This commit is contained in:
@ -7,8 +7,11 @@ using Yavsc.Model.WorkFlow;
|
||||
using System.Configuration.Provider;
|
||||
using System.Collections.Generic;
|
||||
using Yavsc.Model.FrontOffice;
|
||||
using Newtonsoft.Json;
|
||||
using System.Web.Security;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace WorkFlowProvider
|
||||
{
|
||||
@ -25,13 +28,16 @@ namespace WorkFlowProvider
|
||||
public long RegisterCommand (Command com)
|
||||
{
|
||||
long id;
|
||||
|
||||
using (NpgsqlConnection cnx = CreateConnection ()) {
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText =
|
||||
"insert into commandes (prdref,creation,params) values (@pref,@creat,@prs) returning id";
|
||||
"insert into commandes (prdref,creation,params,clientname,applicationname) values (@pref,@creat,@prms,@cli,@app) returning id";
|
||||
cmd.Parameters.Add ("@pref", com.ProductRef);
|
||||
cmd.Parameters.Add ("@creat", com.CreationDate);
|
||||
cmd.Parameters.Add ("@prs", JsonConvert.SerializeObject(com.Parameters));
|
||||
cmd.Parameters.Add ("@prms", JsonConvert.SerializeObject(com.Parameters));
|
||||
cmd.Parameters.Add ("@cli", Membership.GetUser().UserName);
|
||||
cmd.Parameters.Add ("@app", ApplicationName);
|
||||
cnx.Open ();
|
||||
com.Id = id = (long)cmd.ExecuteScalar ();
|
||||
}
|
||||
@ -57,7 +63,7 @@ namespace WorkFlowProvider
|
||||
using (NpgsqlConnection cnx = CreateConnection ()) {
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText =
|
||||
"select id,prdref,creation,params from commandes where @user = clientname and applicationname = @app";
|
||||
"select id,creation,prdref,params from commandes where @user = clientname and applicationname = @app";
|
||||
cmd.Parameters.Add ("@user", username);
|
||||
cmd.Parameters.Add ("@app", this.ApplicationName);
|
||||
cnx.Open ();
|
||||
@ -67,7 +73,10 @@ namespace WorkFlowProvider
|
||||
ycmd.Id = rdr.GetInt64(0);
|
||||
ycmd.CreationDate = rdr.GetDateTime(1);
|
||||
ycmd.ProductRef = rdr.GetString(2);
|
||||
ycmd.Parameters = JsonConvert.DeserializeObject(rdr.GetString(3)) as StringDictionary;
|
||||
|
||||
object prms = JsonConvert.DeserializeObject<Dictionary<string,string>>(rdr.GetString (3));
|
||||
ycmd.Parameters = prms as Dictionary<string,string> ;
|
||||
|
||||
cmds.Add (ycmd);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,8 @@
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
@ -186,10 +186,9 @@ namespace Yavsc.Controllers
|
||||
[Authorize]
|
||||
public ActionResult Basket ()
|
||||
{
|
||||
return View (wfmgr.GetCommands(Membership.GetUser().UserName));
|
||||
return View (wfmgr.GetCommands (Membership.GetUser ().UserName));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Command the specified collection.
|
||||
/// </summary>
|
||||
|
@ -1,14 +1,15 @@
|
||||
<%@ Page Title="Basket" Language="C#" Inherits="System.Web.Mvc.ViewPage<Basket>" MasterPageFile="~/Models/App.master" %>
|
||||
<%@ Page Title="Basket" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<CommandSet>" %>
|
||||
|
||||
|
||||
<asp:Content ContentPlaceHolderID="init" ID="init1" runat="server">
|
||||
<% Title = Title +" "+ Model.Count+" article(s)"; %>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
|
||||
<asp:Content ContentPlaceHolderID="MainContent" ID="mainContent" runat="server">
|
||||
|
||||
<% if (Model.Count>0) { %>
|
||||
<ul>
|
||||
<% foreach (Commande cmd in Model.Values) { %>
|
||||
<% foreach (Command cmd in Model.Values) { %>
|
||||
<li>
|
||||
<%= cmd.Id %>
|
||||
<%= cmd.CreationDate %>
|
||||
@ -16,11 +17,22 @@
|
||||
<%= cmd.Status %>
|
||||
<%= cmd.ProductRef %>
|
||||
<ul>
|
||||
<% foreach (string key in cmd.Parameters.Keys) { %>
|
||||
<% if (cmd.Parameters!=null)
|
||||
foreach (string key in cmd.Parameters.Keys) { %>
|
||||
<li><%=key%>: <%=cmd.Parameters[key]%></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<% } %>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="MASContentContent" ContentPlaceHolderID="MASContent" runat="server">
|
||||
<ul><li>
|
||||
<%= Html.ActionLink("Catalog","Catalog" ) %>
|
||||
</li><li>
|
||||
<%= Html.ActionLink("Estimates","Estimates" ) %>
|
||||
</li></ul>
|
||||
</asp:Content>
|
@ -1,6 +1,7 @@
|
||||
<%@ Page Title="Commande" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<FormCollection>" %>
|
||||
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
|
||||
<%= Html.ActionLink("Votre panier","Basket","FrontOffice" ) %>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="MASContentContent" ContentPlaceHolderID="MASContent" runat="server">
|
||||
|
@ -4,6 +4,7 @@ using System.Collections.Specialized;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using Yavsc.Model.FileSystem;
|
||||
using System.Web;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace Yavsc.Model.FrontOffice
|
||||
@ -40,7 +41,7 @@ namespace Yavsc.Model.FrontOffice
|
||||
/// <summary>
|
||||
/// The parameters.
|
||||
/// </summary>
|
||||
public StringDictionary Parameters = new StringDictionary();
|
||||
public Dictionary<string,string> Parameters = new Dictionary<string,string> ();
|
||||
|
||||
FileInfoCollection Files {
|
||||
get {
|
||||
|
Reference in New Issue
Block a user