Google date quey,

refactiring,
docpage

* Yavsc.sln:
* Web.csproj:
* YavscModel.csproj:
* OtherWebException.cs:
* ProjectInfo.cs:
* IValueProvider.cs:
* CalendarApi.cs:
* HomeController.cs:
* TemplateException.cs:
* WorkFlowController.cs:
* NpgsqlWorkflow.csproj:
* GoogleErrorMessage.cs:
* ITCPNpgsqlProvider.cs:
* NpgsqlContentProvider.cs:
* ITContentProvider.csproj:
* FrontOfficeApiController.cs:
* NpgsqlContentProvider.csproj: refactoring

* App.master:
* WebApiConfig.cs: New Web api configuration architecture

* SalesCatalog.csproj:
* XmlCatalogProvider.cs: using MVC to get the catalog xml filename 

* WorkFlowManager.cs:
* FrontOfficeController.cs:
* CatalogManager.cs: No more extra argument to get the catalog

* DateQuery.aspx:
* AskForADate.cs:
* GoogleController.cs: Google Date new query model

* style.css:
* BBCodeHelper.cs: Doc page responsive design

* Service.cs:
* SetPrice.cs: xml doc

* WebApiConfig.cs: refactioring
This commit is contained in:
Paul Schneider 2015-03-04 14:41:35 +01:00
commit 721b11eba3
29 changed files with 124 additions and 104 deletions

View file

@ -10,7 +10,7 @@ using System.Web;
using System.Linq;
using System.IO;
using System.Net;
using WorkFlowProvider;
using Yavsc;
using System.Web.Security;
using Yavsc.Model.WorkFlow;
using System.Reflection;
@ -52,7 +52,7 @@ namespace Yavsc.ApiControllers
[AcceptVerbs ("GET")]
public Catalog Catalog ()
{
Catalog c = CatalogManager.GetCatalog (Request.RequestUri.AbsolutePath);
Catalog c = CatalogManager.GetCatalog ();
return c;
}
@ -65,19 +65,19 @@ namespace Yavsc.ApiControllers
[AcceptVerbs ("GET")]
public ProductCategory GetProductCategorie (string brandName, string prodCategorie)
{
return CatalogManager.GetCatalog (Request.RequestUri.AbsolutePath).GetBrand (brandName).GetProductCategory (prodCategorie);
return CatalogManager.GetCatalog ().GetBrand (brandName).GetProductCategory (prodCategorie);
}
/// <summary>
/// Gets the estimate.
/// </summary>
/// <returns>The estimate.</returns>
/// <param name="Id">Estimate Id.</param>
/// <param name="id">Estimate Id.</param>
[Authorize]
[HttpGet]
public Estimate GetEstimate (long Id)
public Estimate GetEstimate (long id)
{
Estimate est = wfmgr.ContentProvider.GetEstimate (Id);
Estimate est = wfmgr.ContentProvider.GetEstimate (id);
return est;
}
@ -87,13 +87,13 @@ namespace Yavsc.ApiControllers
/// Gets the estim tex.
/// </summary>
/// <returns>The estim tex.</returns>
/// <param name="estimid">Estimid.</param>
/// <param name="id">Estimate id.</param>
[AcceptVerbs ("GET")]
public HttpResponseMessage EstimateToTex (long estimid)
public HttpResponseMessage EstimateToTex (long id)
{
string texest = null;
try {
texest = estimateToTex (estimid);
texest = estimateToTex (id);
} catch (TemplateException ex) {
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
new ObjectContent (typeof(string),
@ -110,7 +110,7 @@ namespace Yavsc.ApiControllers
}
if (texest == null)
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
new ObjectContent (typeof(string), "Not an estimation id:" + estimid,
new ObjectContent (typeof(string), "Not an estimation id:" + id,
new ErrorHtmlFormatter (HttpStatusCode.NotFound,
LocalizedText.Estimate_not_found))
};

View file

@ -8,7 +8,7 @@ using Yavsc.Controllers;
using System.Collections.Generic;
using Yavsc.Model;
using Yavsc.Model.WorkFlow;
using WorkFlowProvider;
using Yavsc;
using System.Web.Security;
using System.Threading;
using Yavsc.Model.FrontOffice;
@ -64,7 +64,8 @@ namespace Yavsc.Controllers
[Authorize]
public ActionResult Estimate (Estimate model, string submit)
{
ViewData ["WebApiBase"] = "http://" + Request.Url.Authority + "/api";
// Obsolete, set in master page
ViewData ["WebApiBase"] = "http://" + Request.Url.Authority + "/api";
ViewData ["WABASEWF"] = ViewData ["WebApiBase"] + "/WorkFlow";
if (submit == null) {
if (model.Id > 0) {
@ -112,7 +113,7 @@ namespace Yavsc.Controllers
public ActionResult Catalog ()
{
return View (
CatalogManager.GetCatalog (Request.Url.AbsolutePath)
CatalogManager.GetCatalog ()
);
}
@ -122,7 +123,7 @@ namespace Yavsc.Controllers
[AcceptVerbs ("GET")]
public ActionResult Brand (string id)
{
Catalog c = CatalogManager.GetCatalog (Request.Url.AbsolutePath);
Catalog c = CatalogManager.GetCatalog ();
ViewData ["BrandName"] = id;
return View (c.GetBrand (id));
}
@ -139,7 +140,7 @@ namespace Yavsc.Controllers
ViewData ["BrandId"] = brandid;
ViewData ["ProductCategoryId"] = pcid;
return View (
CatalogManager.GetCatalog (Request.Url.AbsolutePath).GetBrand (brandid).GetProductCategory (pcid)
CatalogManager.GetCatalog ().GetBrand (brandid).GetProductCategory (pcid)
);
}
@ -156,7 +157,7 @@ namespace Yavsc.Controllers
ViewData ["BrandName"] = id;
ViewData ["ProdCatRef"] = pc;
ViewData ["ProdRef"] = pref;
Catalog cat = CatalogManager.GetCatalog (Request.Url.AbsolutePath);
Catalog cat = CatalogManager.GetCatalog ();
if (cat == null) {
ViewData ["Message"] = "Catalog introuvable";
ViewData ["RefType"] = "Catalog";

View file

@ -288,14 +288,13 @@ namespace Yavsc.Controllers
public ActionResult DateQuery (AskForADate model)
{
if (ModelState.IsValid) {
if (model.MinDate < DateTime.Now) {
ModelState.AddModelError ("MinTime", "This first date must be in the future.");
return View (model);
}
if (model.MinDate > model.MaxDate) {
ModelState.AddModelError ("MinTime", "This first date must be lower than the second one.");
return View (model);
}
DateTime mindate = DateTime.Now;
if (model.PreferedDate < mindate)
model.PreferedDate = mindate;
if (model.MaxDate < mindate)
model.MaxDate = mindate.AddYears (1);
var muc = Membership.FindUsersByName (model.UserName);
if (muc.Count == 0) {
ModelState.AddModelError ("UserName", "Non existent user");
@ -309,22 +308,18 @@ namespace Yavsc.Controllers
return View (model);
}
DateTime mindate = model.MinDate;
mindate = mindate.AddHours (int.Parse (model.MinTime.Substring (0, 2)));
mindate = mindate.AddMinutes (int.Parse (model.MinTime.Substring (3, 2)));
DateTime maxdate = model.MaxDate;
maxdate = maxdate.AddHours (int.Parse (model.MaxTime.Substring (0, 2)));
maxdate = maxdate.AddMinutes (int.Parse (model.MaxTime.Substring (3, 2)));
CalendarApi c = new CalendarApi ();
CalendarEntryList res;
try {
res = c.GetCalendar (calid, mindate, maxdate, upr);
} catch (GoogleErrorException ex) {
} catch (OtherWebException ex) {
ViewData ["Title"] = ex.Title;
ViewData ["Content"] = ex.Content;
return View ("GoogleErrorMessage", ex);
}
return View (res);
}
return View (model);

View file

@ -13,7 +13,7 @@ using System.Resources;
using Yavsc.Model;
using Npgsql.Web;
using ITContentProvider;
using WorkFlowProvider;
using Yavsc;
using Npgsql.Web.Blog;
namespace Yavsc.Controllers

View file

@ -10,7 +10,7 @@ using System.Web;
using System.Linq;
using System.IO;
using System.Net;
using WorkFlowProvider;
using Yavsc;
using System.Web.Security;
using Yavsc.Model.WorkFlow;
using System.Reflection;

View file

@ -10,7 +10,7 @@ using System.Web;
using System.Linq;
using System.IO;
using System.Net;
using WorkFlowProvider;
using Yavsc;
using System.Web.Security;
using Yavsc.Model.WorkFlow;
using System.Reflection;

View file

@ -57,8 +57,8 @@ namespace Yavsc
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: WebApiConfig.UrlPrefix + "/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
routeTemplate: WebApiConfig.UrlPrefix + "/{controller}/{action}/{id}",
defaults: new { action="Index", id = RouteParameter.Optional }
);
}
}

View file

@ -4,7 +4,7 @@ using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.Security;
using WorkFlowProvider;
using Yavsc;
using Yavsc.Model.WorkFlow;
using System.Web.Http;
using System.Web.Http.Controllers;

View file

@ -55,8 +55,13 @@ namespace Yavsc.Helpers
tib.AddCssClass (BBCodeCaseClass);
string temp = tagUsage (t);
tib.InnerHtml = temp;
u.Add (string.Format ("{0} <div class=\"{2}\">{1}</div>", tib.ToString (), Parser.ToHtml (temp),BBCodeViewClass));
tib.InnerHtml = string.Format("[{0}]",t.Name);
u.Add (string.Format (
"{0} <div class=\"{2}\"><code>{3}</code>{1}</div>",
tib.ToString (),
Parser.ToHtml (temp),
BBCodeViewClass,
temp));
}
@ -65,6 +70,7 @@ namespace Yavsc.Helpers
}
static string tagUsage(BBTag t,string content=null)
{
StringBuilder sb = new StringBuilder ();
@ -200,6 +206,13 @@ namespace Yavsc.Helpers
static string TocContentTransformer (string instr)
{
StringBuilder header = new StringBuilder ();
TagBuilder bshd = new TagBuilder("div");
bshd.AddCssClass ("bshd");
header.AppendFormat ("<img src=\"{0}\" alt=\"[Show/Hide TOC]\" class=\"bsh\">\n",
"/Theme/dark/rect.png");
StringBuilder ttb = new StringBuilder ();
int m1=0, m2=0, m3=0;
foreach (string key in d.Keys) {
@ -254,7 +267,10 @@ namespace Yavsc.Helpers
}
TagBuilder aside = new TagBuilder ("aside");
aside.InnerHtml = ttb.ToString ();
return aside.ToString();
aside.AddCssClass ("bshpanel");
bshd.InnerHtml = header.ToString()+aside.ToString();
return bshd.ToString ();
}
static string DocPageContentTransformer (string instr)

View file

@ -29,6 +29,7 @@ using System.Text;
using Newtonsoft.Json;
using System.Web;
using System.Runtime.Serialization.Json;
using Yavsc.Model;
namespace Yavsc.Helpers.Google
{
@ -116,7 +117,7 @@ namespace Yavsc.Helpers.Google
}
} catch (WebException ex) {
webreq.Abort ();
throw new GoogleErrorException (ex);
throw new OtherWebException (ex);
}
webreq.Abort ();
return res;

View file

@ -23,6 +23,7 @@
<a href="<%=Request.Url.Scheme + "://" + Request.Url.Authority%>"><%= YavscHelpers.SiteName %></a>
</h1>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder>
<% if (ViewData["Error"]!=null) { %>
<div class="error">
@ -34,6 +35,7 @@
<%= Html.Encode(ViewData["Message"]) %>
</div>
<% } %>
</header>
<main>
@ -43,9 +45,13 @@
</main>
<aside>
<asp:ContentPlaceHolder ID="MASContent" runat="server">
</asp:ContentPlaceHolder>
<div id="login">
<% if (Membership.GetUser()==null) { %>
<%= Html.ActionLink( YavscHelpers.SiteName, "Index", "Home" ,null, new { @class="actionlink" } ) %>
@ -74,7 +80,7 @@
<% } %>
</footer>
<script type="text/javascript">
var apiBaseUrl = '@Url.Content(ProjectNameSpace.WebApiConfig.UrlPrefixRelative)';
var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
</script>
</body>
</html>

View file

@ -22,24 +22,20 @@ main {
margin:.5em;
}
aside {background-color: rgba(32,16,16,0.8);
.panel,.bshpanel,aside {
background-color: rgba(32,16,16,0.8);
padding: 0.5em; margin: 0.5em;
border-radius:5px; border: solid 1px #000060;
float: right;
}
.bsh { float: right; }
video,img {
max-width:100%;
max-height:75%;
position:relative;
}
.panel {
background-color: rgba(16,32,32,0.8);
padding: 1em; margin: 0.5em;
border-radius:25px; border: solid 1px #000060;
max-width: 17em;
max-height:30em; border:solid green 1px;}
footer {
position:fixed;
@ -176,9 +172,21 @@ padding-left: 20px;
body {background-color:white;color:black;}
header,footer,.postcomment,.actionlink,.metablog{ display:none;}
}
@media all and (min-width: 641px) {
.bshpanel { display:block; }
.bsh { display: none; }
}
@media all and (max-width: 640px) {
.bshpanel { display:none; }
.bsh { display: inline; }
.bshd:hover .bshpanel {
display: block;
}
.bshd:hover .bsh {
display: none;
}
footer img {
max-height: 1em;
}
@ -186,4 +194,7 @@ padding-left: 20px;
font-size: xx-small;
}
body { margin-bottom:1em; font-size: smaller; }
}
}

View file

@ -52,14 +52,6 @@ return Globalize.format( new Date(value), "t" );
<% using ( Html.BeginForm("DateQuery","Google") ) { %>
<p>Période de recherche:</p>
<p>
<%= Html.LabelFor(model=>model.MinDate) %>:<br>
Le <%= Html.TextBoxFor(model=>model.MinDate) %>
<%= Html.ValidationMessageFor(model=>model.MinDate) %>
à
<%= Html.TextBoxFor(model=>model.MinTime) %>
<%= Html.ValidationMessageFor(model=>model.MinTime) %>
</p>
<p>
<%= Html.LabelFor(model=>model.MaxDate) %>:<br>

View file

@ -191,7 +191,7 @@
<Compile Include="Formatters\RssFeedsFormatter.cs" />
<Compile Include="Controllers\PaypalApiController.cs" />
<Compile Include="Formatters\TexToPdfFormatter.cs" />
<Compile Include="WebApiConfig.cs" />
<Compile Include="Controllers\WebApiConfig.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Web.config" />
@ -723,9 +723,9 @@
<Project>{68F5B80A-616E-4C3C-91A0-828AA40000BD}</Project>
<Name>YavscModel</Name>
</ProjectReference>
<ProjectReference Include="..\WorkFlowProvider\NpgsqlWorkflow.csproj">
<ProjectReference Include="..\WorkFlowProvider\NpgsqlContentProvider.csproj">
<Project>{821FF72D-9F4B-4A2C-B95C-7B965291F119}</Project>
<Name>NpgsqlWorkflow</Name>
<Name>NpgsqlContentProvider</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>