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:
parent
7b0dd0c1e2
commit
721b11eba3
29 changed files with 124 additions and 104 deletions
|
|
@ -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))
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
66
web/Controllers/WebApiConfig.cs
Normal file
66
web/Controllers/WebApiConfig.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
//
|
||||
// WebApiConfig.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paulschneider@free.fr>
|
||||
//
|
||||
// Copyright (c) 2015 Paul Schneider
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Yavsc.Formatters;
|
||||
using Yavsc.Model.FrontOffice;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
/// <summary>
|
||||
/// Web API config.
|
||||
/// </summary>
|
||||
public static class WebApiConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the URL prefix.
|
||||
/// </summary>
|
||||
/// <value>The URL prefix.</value>
|
||||
public static string UrlPrefix { get { return "api"; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the URL prefix relative.
|
||||
/// </summary>
|
||||
/// <value>The URL prefix relative.</value>
|
||||
public static string UrlPrefixRelative { get { return "~/api"; } }
|
||||
|
||||
/// <summary>
|
||||
/// Register the specified config.
|
||||
/// </summary>
|
||||
/// <param name="config">Config.</param>
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: WebApiConfig.UrlPrefix + "/{controller}/{action}/{id}",
|
||||
defaults: new { action="Index", id = RouteParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue