Un bouton "Demander un devis"
* INominative.cs: Interface d'un objet destiné à un préstataire spécifié, par une propriété `PerformerName` * NominativeSimpleBookingQuery.cs: implémente l'interface INominative * packages.config: * packages.config: * packages.config: * ITContentProvider.csproj: * NpgsqlBlogProvider.csproj: * NpgsqlContentProvider.csproj: mise à niveau Npgsql * NpgsqlContentProvider.cs: stocke la classe de commande * AccountController.cs: implémente la methode de login de l'API * BasketController.cs: implémente la methode de recupération du panier * AccountController.cs: enléve un commaentaire obsolète * YavscHelpers.cs: * FrontOfficeController.cs: refabrication de l'ajout au panier * yavsc.user.js: enlève un message de debuggage js * Performer.ascx: formattage * Performers.aspx: implémente le bouton de demande de reservation * Yavsc.csproj: validate unobtrusive * packages.config: référence M$ Owin * UserFileSystemManager.cs: Fixe: Ne pas créer un dossier de destination si on a aucun fichier à recevoir. * Commande.cs: * Ajoute le nom du client dans l'objet commande * Factorise le positionnement des paramêtres * La commande est une instance du type spécifié à la commande, dans son paramêtre `type` * SimpleBookingQuery.cs: refabrication * LocalizedText.resx: * LocalizedText.fr.resx: traducations * UserNameBase.cs: implemente l'interface `IUserName` * IContentProvider.cs: doc xml * YavscModel.csproj: reference le nouveau code source * Web.config: retour à une version d'équère * IUserName.cs: Définit l'interface d'un objet associé à un utilisateur.
This commit is contained in:
parent
1cb3a692ef
commit
2a1301d93c
34 changed files with 409 additions and 77 deletions
|
|
@ -8,7 +8,6 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace Yavsc.Model.FrontOffice
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -28,6 +27,12 @@ namespace Yavsc.Model.FrontOffice
|
|||
/// <value>The identifier.</value>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the client.
|
||||
/// </summary>
|
||||
/// <value>The name of the client.</value>
|
||||
public string ClientName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the product reference.
|
||||
/// </summary>
|
||||
|
|
@ -50,30 +55,55 @@ namespace Yavsc.Model.FrontOffice
|
|||
return UserFileSystemManager.GetFiles (Id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Yavsc.Model.FrontOffice.Command"/> class.
|
||||
/// </summary>
|
||||
public Command()
|
||||
{
|
||||
}
|
||||
public void SetParameters(Dictionary<string,string> collection)
|
||||
{
|
||||
Parameters.Clear ();
|
||||
foreach (string key in collection.Keys) {
|
||||
if (key != "productref" && key != "type" && key != "clientname" ) {
|
||||
|
||||
Parameters.Add (key, collection [key]);
|
||||
foreach (var prop in this.GetType().GetRuntimeProperties())
|
||||
{
|
||||
if (prop.Name == key && prop.CanWrite) {
|
||||
System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(prop.PropertyType);
|
||||
prop.SetValue(this,tc.ConvertFromString(collection [key]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Froms the post.
|
||||
/// Creates a command from the http post request.
|
||||
/// This methods applies to one product reference,
|
||||
/// given in a required value "ref" in the given
|
||||
/// collection of name value couples.
|
||||
/// </summary>
|
||||
/// <param name="collection">Collection.</param>
|
||||
/// <param name="files">Files.</param>
|
||||
private void FromPost(NameValueCollection collection, NameObjectCollectionBase files)
|
||||
private void FromPost(Dictionary<string,string> collection, NameObjectCollectionBase files)
|
||||
{
|
||||
// string catref=collection["catref"]; // Catalog Url from which formdata has been built
|
||||
ProductRef=collection["ref"]; // Required product reference
|
||||
ProductRef = collection ["productref"];
|
||||
if (ProductRef == null)
|
||||
throw new InvalidOperationException (
|
||||
"A product reference cannot be blank at command time");
|
||||
ClientName = collection ["clientname"];
|
||||
if (ClientName == null)
|
||||
throw new InvalidOperationException (
|
||||
"A client name cannot be blank at command time");
|
||||
|
||||
CreationDate = DateTime.Now;
|
||||
Status = CommandStatus.Inserted;
|
||||
// stores the parameters:
|
||||
Parameters.Clear ();
|
||||
foreach (string key in collection.AllKeys) {
|
||||
if (key!="ref")
|
||||
Parameters.Add (key, collection [key]);
|
||||
}
|
||||
SetParameters(collection);
|
||||
WorkFlowManager.RegisterCommand (this); // gives a value to this.Id
|
||||
string strcmdid = Id.ToString ();
|
||||
UserFileSystemManager.Put(Path.Combine("commandes",strcmdid),files);
|
||||
|
|
@ -82,12 +112,22 @@ namespace Yavsc.Model.FrontOffice
|
|||
/// <summary>
|
||||
/// Creates a command using the specified collection
|
||||
/// as command parameters, handles the files upload.
|
||||
///
|
||||
/// Required values in the command parameters :
|
||||
///
|
||||
/// * ref: the product reference,
|
||||
/// * type: the command concrete class name.
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="collection">Collection.</param>
|
||||
/// <param name="files">Files.</param>
|
||||
public static Command CreateCommand (NameValueCollection collection, NameObjectCollectionBase files)
|
||||
public static Command CreateCommand (Dictionary<string,string> collection, NameObjectCollectionBase files)
|
||||
{
|
||||
var cmd = CreateCommand (collection ["type"]);
|
||||
string type = collection ["type"];
|
||||
if (type == null)
|
||||
throw new InvalidOperationException (
|
||||
"A command type cannot be blank");
|
||||
var cmd = CreateCommand (type);
|
||||
cmd.FromPost (collection, files);
|
||||
return cmd;
|
||||
}
|
||||
|
|
@ -100,9 +140,18 @@ namespace Yavsc.Model.FrontOffice
|
|||
public static Command CreateCommand (string className)
|
||||
{
|
||||
var type = Type.GetType (className);
|
||||
|
||||
if (type == null)
|
||||
throw new InvalidOperationException (
|
||||
"Cannot find the command class " + className);
|
||||
|
||||
if (!typeof(Command).IsAssignableFrom(type))
|
||||
throw new InvalidOperationException (
|
||||
"No command is assignable from a " + className);
|
||||
|
||||
ConstructorInfo ci = type.GetConstructor(new Type[]{});
|
||||
var cmd = ci.Invoke (new object[]{}) as Command;
|
||||
return cmd;
|
||||
var cmd = ci.Invoke (new object[]{ });
|
||||
return cmd as Command;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
yavscModel/FrontOffice/INominative.cs
Normal file
35
yavscModel/FrontOffice/INominative.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// INominative.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2015 GNU GPL
|
||||
//
|
||||
// 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.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Model.Skill;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using System.Linq;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
|
||||
namespace Yavsc.Model.FrontOffice
|
||||
{
|
||||
public interface INominative {
|
||||
string PerformerName { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
49
yavscModel/FrontOffice/NominativeSimpleBookingQuery.cs
Normal file
49
yavscModel/FrontOffice/NominativeSimpleBookingQuery.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// NominativeSimpleBookingQuery.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2015 GNU GPL
|
||||
//
|
||||
// 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.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Model.Skill;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using System.Linq;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
|
||||
namespace Yavsc.Model.FrontOffice
|
||||
{
|
||||
/// <summary>
|
||||
/// Nominative simple booking query.
|
||||
/// </summary>
|
||||
public class NominativeSimpleBookingQuery : SimpleBookingQuery, INominative {
|
||||
#region IUserName implementation
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the performer.
|
||||
/// </summary>
|
||||
/// <value>The name of the user.</value>
|
||||
public string PerformerName {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,9 +23,11 @@ using System.ComponentModel.DataAnnotations;
|
|||
using Yavsc.Model.Skill;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using System.Linq;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
|
||||
namespace Yavsc.Model.FrontOffice
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Simple booking query.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue