diff --git a/WorkFlowProvider/NpgsqlContentProvider.cs b/WorkFlowProvider/NpgsqlContentProvider.cs index 94dccea7..333535ab 100644 --- a/WorkFlowProvider/NpgsqlContentProvider.cs +++ b/WorkFlowProvider/NpgsqlContentProvider.cs @@ -66,11 +66,6 @@ namespace WorkFlowProvider throw new NotImplementedException (); } - public void UpdateWritting (Writting wr) - { - throw new NotImplementedException (); - } - public void SetWrittingStatus (long wrtid, int status, string username) { throw new NotImplementedException (); @@ -197,6 +192,30 @@ namespace WorkFlowProvider } } } + + + public void UpdateWritting (Writting wr) + { + using (NpgsqlConnection cnx = CreateConnection ()) { + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = + "update writtings set " + + "description = @desc, " + + "ucost = @ucost, " + + "count = @count, " + + "productid = @prdid " + + "where _id = @wrid"; + cmd.Parameters.Add ("@wrid", wr.Id); + cmd.Parameters.Add ("@desc", wr.Description); + cmd.Parameters.Add ("@ucost", wr.UnitaryCost); + cmd.Parameters.Add ("@prdid", wr.ProductReference); + cmd.Parameters.Add ("@count", wr.Count); + cnx.Open (); + cmd.ExecuteNonQuery (); + cnx.Close (); + } + } + } public void SetTitle (long estid, string newTitle) { diff --git a/WorkFlowProvider/WorkFlowProvider.csproj b/WorkFlowProvider/WorkFlowProvider.csproj index c8f6968e..7393fe8c 100644 --- a/WorkFlowProvider/WorkFlowProvider.csproj +++ b/WorkFlowProvider/WorkFlowProvider.csproj @@ -9,6 +9,7 @@ Library WorkFlowProvider WorkFlowProvider + v4.5 true diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs index f88eaf3c..2fa73ae1 100644 --- a/web/Controllers/FrontOfficeController.cs +++ b/web/Controllers/FrontOfficeController.cs @@ -21,9 +21,10 @@ namespace Yavsc.Controllers public class FrontOfficeController : Controller { [Authorize] - public ActionResult Estimate(Estimate model,string submit) + public ActionResult Estimate(Estimate model,string submit) { if (ModelState.IsValid) { + ViewData ["WebApiUrl"] = "http://"+ Request.Url.Authority + "/api/WorkFlow"; string username = HttpContext.User.Identity.Name; if (model.Id > 0) { Estimate f = WorkFlowManager.GetEstimate (model.Id); @@ -31,7 +32,6 @@ namespace Yavsc.Controllers ModelState.AddModelError ("Id", "Wrong Id"); return View (model); } - if (username != f.Owner) if (!Roles.IsUserInRole ("FrontOffice")) throw new UnauthorizedAccessException ("You're not allowed to view/modify this estimate"); diff --git a/web/Controllers/WorkFlowController.cs b/web/Controllers/WorkFlowController.cs index 57a9f0a4..fe2a306a 100644 --- a/web/Controllers/WorkFlowController.cs +++ b/web/Controllers/WorkFlowController.cs @@ -11,7 +11,6 @@ using System.Web.Security; namespace Yavsc.ApiControllers { - //[HttpControllerConfiguration(ActionValueBinder=typeof(Basic.MvcActionValueBinder))] public class WorkFlowController : ApiController { string adminRoleName="Admin"; @@ -39,10 +38,13 @@ namespace Yavsc.ApiControllers { WorkFlowManager.DropWritting (wrid); } - [HttpGet] + [Authorize] - public void UpdateWritting(Writting wr) + [AcceptVerbs("POST")] + public void UpdateWritting([FromBody] Writting wr) { + if (!ModelState.IsValid) + throw new Exception ("Modèle invalide"); WorkFlowManager.UpdateWritting (wr); } @@ -62,12 +64,13 @@ namespace Yavsc.ApiControllers return new { test=string.Format("Hello {0}!",username) }; } - [HttpGet] - [HttpPost] + + [AcceptVerbs("POST")] [Authorize] - public long Write (long estid, string desc, decimal ucost, int count, string productid) { + public long Write ([FromUri] long estid, [FromBody] Writting wr) { // TODO ensure estid owner matches the current one - return WorkFlowManager.Write(estid, desc, ucost, count, productid); + return WorkFlowManager.Write(estid, wr.Description, + wr.UnitaryCost, wr.Count, wr.ProductReference); } } } diff --git a/web/Global.asax.cs b/web/Global.asax.cs index 73321a12..f3f0e9eb 100644 --- a/web/Global.asax.cs +++ b/web/Global.asax.cs @@ -16,6 +16,10 @@ namespace Yavsc { routes.IgnoreRoute ("{resource}.axd/{*pathInfo}"); + routes.IgnoreRoute ("js/{*pathInfo}"); + routes.IgnoreRoute ("Theme/{*pathInfo}"); + routes.IgnoreRoute ("css/{*pathInfo}"); + routes.IgnoreRoute ("images/{*pathInfo}"); routes.MapRoute ( "Blog", diff --git a/web/Models/App.master b/web/Models/App.master index d76e89db..f15053c5 100644 --- a/web/Models/App.master +++ b/web/Models/App.master @@ -5,9 +5,11 @@ <% Page.Title += " - "+YavscHelpers.SiteName; %> + + - + diff --git a/web/Theme/blue/asc.gif b/web/Theme/blue/asc.gif new file mode 100644 index 00000000..74157867 Binary files /dev/null and b/web/Theme/blue/asc.gif differ diff --git a/web/Theme/blue/bg.gif b/web/Theme/blue/bg.gif new file mode 100644 index 00000000..fac668fc Binary files /dev/null and b/web/Theme/blue/bg.gif differ diff --git a/web/Theme/blue/desc.gif b/web/Theme/blue/desc.gif new file mode 100644 index 00000000..3b30b3c5 Binary files /dev/null and b/web/Theme/blue/desc.gif differ diff --git a/web/Theme/blue/style.css b/web/Theme/blue/style.css new file mode 100644 index 00000000..071b3cc0 --- /dev/null +++ b/web/Theme/blue/style.css @@ -0,0 +1,39 @@ +/* tables */ +table.tablesorter { + font-family:arial; + background-color: #CDCDCD; + margin:10px 0pt 15px; + font-size: 8pt; + width: 100%; + text-align: left; +} +table.tablesorter thead tr th, table.tablesorter tfoot tr th { + background-color: #e6EEEE; + border: 1px solid #FFF; + font-size: 8pt; + padding: 4px; +} +table.tablesorter thead tr .header { + background-image: url(bg.gif); + background-repeat: no-repeat; + background-position: center right; + cursor: pointer; +} +table.tablesorter tbody td { + color: #3D3D3D; + padding: 4px; + background-color: #FFF; + vertical-align: top; +} +table.tablesorter tbody tr.odd td { + background-color:#F0F0F6; +} +table.tablesorter thead tr .headerSortUp { + background-image: url(/Theme/blue/asc.gif); +} +table.tablesorter thead tr .headerSortDown { + background-image: url(/Theme/blue/desc.gif); +} +table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp { +background-color: #8dbdd8; +} diff --git a/web/Theme/dark/asc.gif b/web/Theme/dark/asc.gif new file mode 100644 index 00000000..74157867 Binary files /dev/null and b/web/Theme/dark/asc.gif differ diff --git a/web/Theme/dark/bg.gif b/web/Theme/dark/bg.gif new file mode 100644 index 00000000..fac668fc Binary files /dev/null and b/web/Theme/dark/bg.gif differ diff --git a/web/Theme/dark/desc.gif b/web/Theme/dark/desc.gif new file mode 100644 index 00000000..3b30b3c5 Binary files /dev/null and b/web/Theme/dark/desc.gif differ diff --git a/web/Theme/dark/style.css b/web/Theme/dark/style.css new file mode 100644 index 00000000..5fd7a115 --- /dev/null +++ b/web/Theme/dark/style.css @@ -0,0 +1,41 @@ +/* tables */ +table.tablesorter { + font-family:arial; + background-color: #333; + margin:10px 0pt 15px; + font-size: 8pt; + width: 100%; + text-align: left; +} +table.tablesorter thead tr th, table.tablesorter tfoot tr th { + background-color: rgba(0,0,0,0.5); + border: 1px solid #206; + font-size: 8pt; + padding: 4px; +} +table.tablesorter thead tr .header { + background-image: url(bg.gif); + background-repeat: no-repeat; + background-position: center right; + cursor: pointer; +} +table.tablesorter tbody td { + color: #ffa; + padding: 4px; + vertical-align: top; + background-color: #002; +} + +table.tablesorter .odd td { + background-color: #004; +} + +table.tablesorter thead tr .headerSortUp { + background-image: url(/Theme/dark/asc.gif); +} +table.tablesorter thead tr .headerSortDown { + background-image: url(/Theme/dark/desc.gif); +} +table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp { +background-color: #123; +} diff --git a/web/Theme/green/asc.png b/web/Theme/green/asc.png new file mode 100644 index 00000000..66e39cad Binary files /dev/null and b/web/Theme/green/asc.png differ diff --git a/web/Theme/green/bg.png b/web/Theme/green/bg.png new file mode 100644 index 00000000..ca837161 Binary files /dev/null and b/web/Theme/green/bg.png differ diff --git a/web/Theme/green/desc.png b/web/Theme/green/desc.png new file mode 100644 index 00000000..431f63ab Binary files /dev/null and b/web/Theme/green/desc.png differ diff --git a/web/Theme/green/style.css b/web/Theme/green/style.css new file mode 100644 index 00000000..8ea42b4b --- /dev/null +++ b/web/Theme/green/style.css @@ -0,0 +1,39 @@ +table.tablesorter { + font-size: 12px; + background-color: #4D4D4D; + width: 1024px; + border: 1px solid #000; +} +table.tablesorter th { + text-align: left; + padding: 5px; + background-color: #6E6E6E; +} +table.tablesorter td { + color: #FFF; + padding: 5px; +} +table.tablesorter .even { + background-color: #3D3D3D; +} +table.tablesorter .odd { + background-color: #6E6E6E; +} +table.tablesorter .header { + background-image: url(bg.png); + background-repeat: no-repeat; + border-left: 1px solid #FFF; + border-right: 1px solid #000; + border-top: 1px solid #FFF; + padding-left: 30px; + padding-top: 8px; + height: auto; +} +table.tablesorter .headerSortUp { + background-image: url(/Theme/green/asc.png); + background-repeat: no-repeat; +} +table.tablesorter .headerSortDown { + background-image: url(/Theme/green/desc.png); + background-repeat: no-repeat; +} \ No newline at end of file diff --git a/web/style.css b/web/Theme/style.css similarity index 100% rename from web/style.css rename to web/Theme/style.css diff --git a/web/Views/FrontOffice/Estimate.aspx b/web/Views/FrontOffice/Estimate.aspx index e1021939..c7ae75bd 100644 --- a/web/Views/FrontOffice/Estimate.aspx +++ b/web/Views/FrontOffice/Estimate.aspx @@ -1,8 +1,14 @@ <%@ Page Title="Devis" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %> - + + + + + + + <%= Html.ValidationSummary("Devis") %> <% using (Html.BeginForm("Estimate","FrontOffice")) { %> <%= Html.LabelFor(model => model.Title) %>:<%= Html.TextBox( "Title" ) %> @@ -22,25 +28,14 @@ <% } else { %> - - <% } %> -<% if (Model.Lines ==null || Model.Lines.Length == 0) { %> -Pas de ligne. -<% -} else { %> + + + -Id Description Product Reference Count @@ -48,9 +43,10 @@ -<% foreach (Writting wr in Model.Lines) { %> - -<%=wr.Id%> +<% int lc=0; + if (Model.Lines!=null) + foreach (Writting wr in Model.Lines) { lc++; %> +row" id="wr<%=wr.Id%>"> <%=wr.Description%> <%=wr.ProductReference%> <%=wr.Count%> @@ -60,13 +56,14 @@ - -<% } %> - <% } %> <% } %> + + + + - + - Description: - - Prix unitaire: - - Quantité: - - Référence du produit: - - + Description: + + Prix unitaire: + + Quantité: + + Référence du produit: + + + + - - + + - + diff --git a/web/Web.csproj b/web/Web.csproj index 6de340db..e263cb21 100644 --- a/web/Web.csproj +++ b/web/Web.csproj @@ -25,6 +25,11 @@ Yavsc true + + + + + none @@ -107,6 +112,10 @@ + + + + @@ -145,7 +154,6 @@ - @@ -204,6 +212,19 @@ + + + + + + + + + + + + + diff --git a/yavscModel/WorkFlow/Writting.cs b/yavscModel/WorkFlow/Writting.cs index 10c38073..2d18c21d 100644 --- a/yavscModel/WorkFlow/Writting.cs +++ b/yavscModel/WorkFlow/Writting.cs @@ -1,13 +1,43 @@ using System; +using System.ComponentModel.DataAnnotations; namespace Yavsc.Model.WorkFlow { + /// + /// A Writting. + /// Une ligne d'écriture dans un devis ou une facture + /// public class Writting { + /// + /// Gets or sets the identifier. + /// + /// The identifier. public long Id { get; set; } + /// + /// Gets or sets the unitary cost, per unit, or per hour ... + /// Who knows? + /// + /// The unitary cost. + [Required()] public decimal UnitaryCost { get; set; } + /// + /// Gets or sets the count. + /// + /// The count. + [Required()] public int Count { get; set; } + /// + /// Gets or sets the product reference. + /// + /// The product reference. + [Required()] public string ProductReference { get; set; } + /// + /// Gets or sets the description. + /// + /// The description. + [Required()] public string Description { get; set; } } }