* Estimate.aspx: from backoffice
* CatalogManager.cs: Uses GetDefaultProvider * Catalog.cs: the Catalog object now should support a unique id in the system : UID, exposed as one of its properties. * AccountController.cs: new static method te get an user profile by its name. * AdminController.cs: Uses the Yavsc.Admin namespace (refactoring) * Web.csproj: * BlogManager.cs: * BackOfficeController.cs: refactoring * BlogsController.cs: Fixes the Blog title * FrontOfficeController.cs: Changes on the go for the Command object * AddRole.aspx: minor syntax change * UserPosts.aspx: show the blog title * style.css: black transparent for the background of posts * Profile.cs: Method FromProfileBase became a constructor * Commande.cs: nothing * Estimate.aspx: moved to the frontoffice views * CatalogHelper.cs: Writting GetDefaultProvider
This commit is contained in:
parent
b5d19c5da6
commit
c22be7f6b5
17 changed files with 104 additions and 46 deletions
|
|
@ -12,13 +12,20 @@ namespace SalesCatalog
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class CatalogHelper
|
public static class CatalogHelper
|
||||||
{
|
{
|
||||||
public static CatalogProvider GetProvider ()
|
|
||||||
{
|
public static CatalogProvidersConfigurationSection Config {get; set; }
|
||||||
CatalogProvidersConfigurationSection config = ConfigurationManager.GetSection ("system.web/catalog") as CatalogProvidersConfigurationSection;
|
|
||||||
if (config == null)
|
public static void Load () {
|
||||||
|
if (Config != null)
|
||||||
|
return ;
|
||||||
|
Config = ConfigurationManager.GetSection ("system.web/catalog") as CatalogProvidersConfigurationSection;
|
||||||
|
if (Config == null)
|
||||||
throw new ConfigurationErrorsException("The configuration bloc for the catalog provider was not found");
|
throw new ConfigurationErrorsException("The configuration bloc for the catalog provider was not found");
|
||||||
CatalogProviderConfigurationElement celt =
|
foreach (CatalogProviderConfigurationElement e in Config.Providers) {
|
||||||
config.Providers.GetElement (config.DefaultProvider);
|
CreateProvider (e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static CatalogProvider CreateProvider(CatalogProviderConfigurationElement celt) {
|
||||||
if (celt == null)
|
if (celt == null)
|
||||||
throw new ConfigurationErrorsException("The default catalog provider was not found");
|
throw new ConfigurationErrorsException("The default catalog provider was not found");
|
||||||
Type catprtype = Type.GetType (celt.Type);
|
Type catprtype = Type.GetType (celt.Type);
|
||||||
|
|
@ -40,6 +47,14 @@ namespace SalesCatalog
|
||||||
cp.Initialize (celt.Name, c);
|
cp.Initialize (celt.Name, c);
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CatalogProvider GetDefaultProvider ()
|
||||||
|
{
|
||||||
|
CatalogProviderConfigurationElement celt =
|
||||||
|
Config.Providers.GetElement (Config.DefaultProvider);
|
||||||
|
|
||||||
|
return CreateProvider (celt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace SalesCatalog
|
||||||
{
|
{
|
||||||
public static Catalog GetCatalog ()
|
public static Catalog GetCatalog ()
|
||||||
{
|
{
|
||||||
CatalogProvider p = CatalogHelper.GetProvider ();
|
CatalogProvider p = CatalogHelper.GetDefaultProvider ();
|
||||||
return p.GetCatalog ();
|
return p.GetCatalog ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ namespace SalesCatalog.Model
|
||||||
/// Catalog.
|
/// Catalog.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Catalog {
|
public class Catalog {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the catalog unique identifier in the system.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The unique identifier.</value>
|
||||||
|
string UID { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the brands.
|
/// Gets or sets the brands.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,16 @@ namespace Yavsc.Controllers
|
||||||
return View ();
|
return View ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Profile GetProfile (string user)
|
||||||
|
{
|
||||||
|
return new Profile (ProfileBase.Create (user));
|
||||||
|
}
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public ActionResult Profile(Profile model)
|
public ActionResult Profile(Profile model)
|
||||||
{
|
{
|
||||||
ViewData ["UserName"] = Membership.GetUser ().UserName;
|
ViewData ["UserName"] = Membership.GetUser ().UserName;
|
||||||
model.FromProfileBase(HttpContext.Profile);
|
model = GetProfile ((string)ViewData ["UserName"]);
|
||||||
return View (model);
|
return View (model);
|
||||||
}
|
}
|
||||||
// TODO [ValidateAntiForgeryToken]
|
// TODO [ValidateAntiForgeryToken]
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,15 @@ using System.Web.Mvc.Ajax;
|
||||||
using System.Web.Security;
|
using System.Web.Security;
|
||||||
using Yavsc.Model.RolesAndMembers;
|
using Yavsc.Model.RolesAndMembers;
|
||||||
using Yavsc.Model.Admin;
|
using Yavsc.Model.Admin;
|
||||||
|
using Yavsc.Admin;
|
||||||
|
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Admin controller.
|
||||||
|
/// Only Admin members should be allowed to use it.
|
||||||
|
/// </summary>
|
||||||
public class AdminController : Controller
|
public class AdminController : Controller
|
||||||
{
|
{
|
||||||
[Authorize(Roles="Admin")]
|
[Authorize(Roles="Admin")]
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,10 @@ namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
public class BackOfficeController : Controller
|
public class BackOfficeController : Controller
|
||||||
{
|
{
|
||||||
public ActionResult Estimate()
|
[Authorize(Roles="Admin,Providers")]
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
{
|
{
|
||||||
|
return View ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ using Yavsc;
|
||||||
using Yavsc.Model;
|
using Yavsc.Model;
|
||||||
using Yavsc.Model.Blogs;
|
using Yavsc.Model.Blogs;
|
||||||
using Yavsc.ApiControllers;
|
using Yavsc.ApiControllers;
|
||||||
|
using Yavsc.Model.RolesAndMembers;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -82,7 +83,9 @@ namespace Yavsc.Controllers
|
||||||
if (u.UserName == user)
|
if (u.UserName == user)
|
||||||
sf |= FindBlogEntryFlags.MatchInvisible;
|
sf |= FindBlogEntryFlags.MatchInvisible;
|
||||||
BlogEntryCollection c = BlogManager.FindPost (user, sf, pageIndex, pageSize, out tr);
|
BlogEntryCollection c = BlogManager.FindPost (user, sf, pageIndex, pageSize, out tr);
|
||||||
ViewData ["BlogTitle"] = BlogTitle (user);
|
Profile bupr = AccountController.GetProfile (user);
|
||||||
|
ViewData ["BlogUserProfile"] = bupr;
|
||||||
|
ViewData ["BlogTitle"] = bupr.BlogTitle;
|
||||||
ViewData ["PageIndex"] = pageIndex;
|
ViewData ["PageIndex"] = pageIndex;
|
||||||
ViewData ["PageSize"] = pageSize;
|
ViewData ["PageSize"] = pageSize;
|
||||||
ViewData ["RecordCount"] = tr;
|
ViewData ["RecordCount"] = tr;
|
||||||
|
|
@ -109,16 +112,23 @@ namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
if (e == null)
|
if (e == null)
|
||||||
return View ("TitleNotFound");
|
return View ("TitleNotFound");
|
||||||
|
Profile pr = AccountController.GetProfile (e.UserName);
|
||||||
|
if (pr==null)
|
||||||
|
return View ("TitleNotFound");
|
||||||
|
ViewData ["BlogUserProfile"] = pr;
|
||||||
|
ViewData ["BlogTitle"] = pr.BlogTitle;
|
||||||
MembershipUser u = Membership.GetUser ();
|
MembershipUser u = Membership.GetUser ();
|
||||||
if (u != null)
|
if (u != null)
|
||||||
ViewData ["UserName"] = u.UserName;
|
ViewData ["UserName"] = u.UserName;
|
||||||
if (!e.Visible) {
|
if (!e.Visible || !pr.BlogVisible) {
|
||||||
if (u==null)
|
if (u==null)
|
||||||
return View ("TitleNotFound");
|
return View ("TitleNotFound");
|
||||||
else if (u.UserName!=e.UserName)
|
else {
|
||||||
|
if (u.UserName!=e.UserName)
|
||||||
|
if (!Roles.IsUserInRole(u.UserName,"Admin"))
|
||||||
return View ("TitleNotFound");
|
return View ("TitleNotFound");
|
||||||
}
|
}
|
||||||
ViewData ["BlogTitle"] = BlogTitle (e.UserName);
|
}
|
||||||
ViewData ["Comments"] = BlogManager.GetComments (e.Id);
|
ViewData ["Comments"] = BlogManager.GetComments (e.Id);
|
||||||
return View ("UserPost", e);
|
return View ("UserPost", e);
|
||||||
}
|
}
|
||||||
|
|
@ -183,7 +193,9 @@ namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
string user = Membership.GetUser ().UserName;
|
string user = Membership.GetUser ().UserName;
|
||||||
ViewData ["BlogTitle"] = this.BlogTitle (user);
|
Profile pr = new Profile (HttpContext.Profile);
|
||||||
|
|
||||||
|
ViewData ["BlogTitle"] = pr.BlogTitle;
|
||||||
ViewData ["UserName"] = user;
|
ViewData ["UserName"] = user;
|
||||||
if (model.UserName == null) {
|
if (model.UserName == null) {
|
||||||
model.UserName = user;
|
model.UserName = user;
|
||||||
|
|
@ -202,10 +214,6 @@ namespace Yavsc.Controllers
|
||||||
return View (model);
|
return View (model);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string BlogTitle (string user)
|
|
||||||
{
|
|
||||||
return string.Format ("{0}'s blog", user);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public ActionResult Comment (BlogEditCommentModel model) {
|
public ActionResult Comment (BlogEditCommentModel model) {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ using System.Web.Security;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Front office controller.
|
||||||
|
/// Access granted to all
|
||||||
|
/// </summary>
|
||||||
public class FrontOfficeController : Controller
|
public class FrontOfficeController : Controller
|
||||||
{
|
{
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|
@ -133,7 +137,7 @@ namespace Yavsc.Controllers
|
||||||
Session["Basket"]=new List<Commande>();
|
Session["Basket"]=new List<Commande>();
|
||||||
List<Commande> basket = Session["Basket"] as List<Commande>;
|
List<Commande> basket = Session["Basket"] as List<Commande>;
|
||||||
// Add specified product command to the basket,
|
// Add specified product command to the basket,
|
||||||
basket.Add(new Commande(collection));
|
basket.Add(new Commande(0,0,collection));
|
||||||
return View (collection);
|
return View (collection);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ViewData ["Message"] = "Exception:"+e.Message;
|
ViewData ["Message"] = "Exception:"+e.Message;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
|
||||||
<%= Html.ValidationSummary() %>
|
<%= Html.ValidationSummary() %>
|
||||||
<% using(Html.BeginForm("DoAddRole")) %>
|
<% using(Html.BeginForm("DoAddRole"))
|
||||||
<% { %>
|
{ %>
|
||||||
Nom du rôle :
|
Nom du rôle :
|
||||||
<%= Html.TextBox( "RoleName" ) %>
|
<%= Html.TextBox( "RoleName" ) %>
|
||||||
<%= Html.ValidationMessage("RoleName", "*") %><br/>
|
<%= Html.ValidationMessage("RoleName", "*") %><br/>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head runat="server">
|
|
||||||
<title></title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<%@ Page Title="Billets utilisateurs" Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEntryCollection>" MasterPageFile="~/Models/App.master"%>
|
<%@ Page Title="Billets utilisateurs" Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEntryCollection>" MasterPageFile="~/Models/App.master"%>
|
||||||
<%@ Register Assembly="Yavsc.WebControls" TagPrefix="yavsc" Namespace="Yavsc.WebControls" %>
|
<%@ Register Assembly="Yavsc.WebControls" TagPrefix="yavsc" Namespace="Yavsc.WebControls" %>
|
||||||
<asp:Content ContentPlaceHolderID="init" ID="init1" runat="server">
|
<asp:Content ContentPlaceHolderID="init" ID="init1" runat="server">
|
||||||
<% Title = ((string) ViewData["BlogTitle"])+" - "+YavscHelpers.SiteName ; %>
|
<% Title = ((string) ((Profile)ViewData["BlogUserProfile"]).BlogTitle)+" - "+YavscHelpers.SiteName ; %>
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ContentPlaceHolderID="overHeaderOne" ID="header1" runat="server">
|
<asp:Content ContentPlaceHolderID="overHeaderOne" ID="header1" runat="server">
|
||||||
<h1 class="blogtitle"><a href="/Blog/<%=ViewData["BlogUser"]%>">
|
<h1 class="blogtitle"><a href="/Blog/<%=ViewData["BlogUser"]%>">
|
||||||
|
|
|
||||||
19
web/Views/FrontOffice/Estimate.aspx
Normal file
19
web/Views/FrontOffice/Estimate.aspx
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %>
|
||||||
|
<!-- <asp:Content ContentPlaceHolderID="init" ID="initContent" runat="server">
|
||||||
|
</asp:Content>
|
||||||
|
<asp:Content ContentPlaceHolderID="overHeaderOne" ID="overHeaderOneContent" runat="server">
|
||||||
|
</asp:Content>
|
||||||
|
<asp:Content ContentPlaceHolderID="header" ID="headerContent" runat="server">
|
||||||
|
</asp:Content> -->
|
||||||
|
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||||
|
<% using (Html.BeginForm("Estimate")) { %>
|
||||||
|
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
</asp:Content>
|
||||||
|
<!--
|
||||||
|
<asp:Content ContentPlaceHolderID="MASContent" ID="MASContentContent" runat="server">
|
||||||
|
</asp:Content>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -188,13 +188,13 @@
|
||||||
<Content Include="Views\Admin\RemoveRoleQuery.aspx" />
|
<Content Include="Views\Admin\RemoveRoleQuery.aspx" />
|
||||||
<Content Include="Views\Admin\RemoveUserQuery.aspx" />
|
<Content Include="Views\Admin\RemoveUserQuery.aspx" />
|
||||||
<Content Include="Views\Admin\RoleList.aspx" />
|
<Content Include="Views\Admin\RoleList.aspx" />
|
||||||
<Content Include="Views\BackOffice\Estimate.aspx" />
|
|
||||||
<Content Include="Views\Admin\CreateBackup.aspx" />
|
<Content Include="Views\Admin\CreateBackup.aspx" />
|
||||||
<Content Include="Views\Admin\BackupCreated.aspx" />
|
<Content Include="Views\Admin\BackupCreated.aspx" />
|
||||||
<Content Include="Views\Admin\Backups.aspx" />
|
<Content Include="Views\Admin\Backups.aspx" />
|
||||||
<Content Include="Views\Admin\Restore.aspx" />
|
<Content Include="Views\Admin\Restore.aspx" />
|
||||||
<Content Include="Views\Admin\Restored.aspx" />
|
<Content Include="Views\Admin\Restored.aspx" />
|
||||||
<Content Include="Views\Admin\Index.aspx" />
|
<Content Include="Views\Admin\Index.aspx" />
|
||||||
|
<Content Include="Views\FrontOffice\Estimate.aspx" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ label {
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
.blogpost {
|
.blogpost {
|
||||||
background-color: rgba(32,32,32,0.3);
|
background-color: rgba(0,0,0,0.5);
|
||||||
}
|
}
|
||||||
.editblog {
|
.editblog {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using Yavsc.Model.Blogs;
|
using Yavsc.Model.Blogs;
|
||||||
|
using Yavsc.Model.RolesAndMembers;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
|
||||||
namespace Yavsc.Model.Blogs
|
namespace Yavsc.Model.Blogs
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,11 @@ namespace Yavsc.Model.RolesAndMembers
|
||||||
[DisplayName("Titre du blog")]
|
[DisplayName("Titre du blog")]
|
||||||
public string BlogTitle { get; set; }
|
public string BlogTitle { get; set; }
|
||||||
|
|
||||||
public void FromProfileBase(ProfileBase profile)
|
public Profile():base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Profile(ProfileBase profile)
|
||||||
{
|
{
|
||||||
object b = profile.GetPropertyValue ("BlogVisible");
|
object b = profile.GetPropertyValue ("BlogVisible");
|
||||||
BlogVisible = (b is DBNull) ? true : (bool)b;
|
BlogVisible = (b is DBNull) ? true : (bool)b;
|
||||||
|
|
@ -53,10 +57,8 @@ namespace Yavsc.Model.RolesAndMembers
|
||||||
s = profile.GetPropertyValue("ZipCode");
|
s = profile.GetPropertyValue("ZipCode");
|
||||||
ZipCode = (s is DBNull)?null:(string)s;
|
ZipCode = (s is DBNull)?null:(string)s;
|
||||||
|
|
||||||
|
|
||||||
s = profile.GetPropertyValue ("WebSite");
|
s = profile.GetPropertyValue ("WebSite");
|
||||||
WebSite = (s is DBNull) ? null : (string)s;
|
WebSite = (s is DBNull) ? null : (string)s;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,17 @@ using SalesCatalog;
|
||||||
using SalesCatalog.Model;
|
using SalesCatalog.Model;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
|
||||||
|
|
||||||
namespace Yavsc.Model.WorkFlow
|
namespace Yavsc.Model.WorkFlow
|
||||||
{
|
{
|
||||||
public class Commande
|
public class Commande
|
||||||
{
|
{
|
||||||
public Commande(NameValueCollection collection)
|
public DateTime CreationDate { get; set; }
|
||||||
|
long Id { get; set; }
|
||||||
|
public Commande(long catid, long pref, NameValueCollection collection)
|
||||||
{
|
{
|
||||||
|
CreationDate = DateTime.Now;
|
||||||
|
//TODO save it and get the id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue