diff --git a/web/ApiControllers/CalendarController.cs b/web/ApiControllers/CalendarController.cs index 0c7152ee..0825e015 100644 --- a/web/ApiControllers/CalendarController.cs +++ b/web/ApiControllers/CalendarController.cs @@ -26,6 +26,7 @@ using System.Web.Security; using Yavsc.Model.Google; using Yavsc.Helpers; using System.Web.Profile; +using Yavsc.Model.Circles; namespace Yavsc.ApiControllers diff --git a/web/ApiControllers/CircleController.cs b/web/ApiControllers/CircleController.cs index 46abea47..5a994c78 100644 --- a/web/ApiControllers/CircleController.cs +++ b/web/ApiControllers/CircleController.cs @@ -20,6 +20,10 @@ // along with this program. If not, see . using System; using System.Web.Http; +using Yavsc.Model.RolesAndMembers; +using System.Collections.Generic; +using Yavsc.Model.Circles; +using System.Web.Security; namespace Yavsc.ApiControllers { @@ -32,26 +36,44 @@ namespace Yavsc.ApiControllers /// Add the specified id and users. /// /// Identifier. + /// Title. /// Users. + [Authorize] public void Add(string id, string [] users) { - throw new NotImplementedException (); + string user = Membership.GetUser ().UserName; + CircleManager.DefaultProvider.Add (user, id, users); } /// /// Delete the specified id. /// /// Identifier. - public void Delete(string id) + [Authorize] public void Delete(string id) { - throw new NotImplementedException (); + string user = Membership.GetUser ().UserName; + CircleManager.DefaultProvider.Delete (user, id); } + /// /// Get the specified id. /// /// Identifier. - public string[] Get(string id) + [Authorize] + public Circle Get(string id) + { + string user = Membership.GetUser ().UserName; + return CircleManager.DefaultProvider.Get (user, id); + } + + + /// + /// List this instance. + /// + [Authorize] + public CircleInfoCollection List() { - throw new NotImplementedException (); + string user = Membership.GetUser ().UserName; + return CircleManager.DefaultProvider.List (); } } } diff --git a/web/ChangeLog b/web/ChangeLog index 19764ce9..f2571238 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,16 @@ +2015-06-10 Paul Schneider + + * CalendarController.cs: refactoring + + * CircleController.cs: implements with default circle provider + + * FrontOfficeController.cs: throws descriptive exception + message at searching for a catalog + + * Catalog.aspx: Fixes links on product categories + + * ProductCategory.aspx: Fixes links on products + 2015-06-09 Paul Schneider * Edit.aspx: A Page Title diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs index 836201d5..9a5d08b7 100644 --- a/web/Controllers/FrontOfficeController.cs +++ b/web/Controllers/FrontOfficeController.cs @@ -153,9 +153,17 @@ namespace Yavsc.Controllers { ViewData ["BrandId"] = brandid; ViewData ["ProductCategoryId"] = pcid; - return View ( - CatalogManager.GetCatalog ().GetBrand (brandid).GetProductCategory (pcid) - ); + + var cat = CatalogManager.GetCatalog (); + if (cat == null) + throw new Exception ("No catalog"); + var brand = cat.GetBrand (brandid); + if (brand == null) + throw new Exception ("Not a brand id: "+brandid); + var pcat = brand.GetProductCategory (pcid); + if (pcat == null) + throw new Exception ("Not a product category id in this brand: " + pcid); + return View (pcat); } /// diff --git a/web/Views/FrontOffice/Catalog.aspx b/web/Views/FrontOffice/Catalog.aspx index 4d897125..4c1be629 100644 --- a/web/Views/FrontOffice/Catalog.aspx +++ b/web/Views/FrontOffice/Catalog.aspx @@ -6,7 +6,7 @@

<%= Html.Encode( b.Slogan ) %>

<% foreach (ProductCategory pc in b.Categories ) { %>
-

<%= Html.ActionLink( pc.Name, "ProductCategory", new { id = b.Name, pc = pc.Reference }, new { @class="actionlink" } ) %>

+

<%= Html.ActionLink( pc.Name, "ProductCategory", new { brandid= b.Name, pcid = pc.Reference }, new { @class="actionlink" } ) %>

<% foreach (Product p in pc.Products ) { %> diff --git a/web/Views/FrontOffice/ProductCategory.aspx b/web/Views/FrontOffice/ProductCategory.aspx index 39969bd8..de875d71 100644 --- a/web/Views/FrontOffice/ProductCategory.aspx +++ b/web/Views/FrontOffice/ProductCategory.aspx @@ -3,7 +3,7 @@ <% foreach (Product p in Model.Products ) { %> -

<%= Html.ActionLink( p.Name, "Product", new { id = ViewData["BrandName"], pc = Model.Reference , pref = p.Reference }, new { @class="actionlink" } ) %>

+

<%= Html.ActionLink( p.Name, "Product", new { id = ViewData["BrandId"], pc = Model.Reference , pref = p.Reference }, new { @class="actionlink" } ) %>

<%= p.Description %> diff --git a/yavscModel/Calendar/EventPub.cs b/yavscModel/Calendar/EventPub.cs index b3bebdfd..9ef1b145 100644 --- a/yavscModel/Calendar/EventPub.cs +++ b/yavscModel/Calendar/EventPub.cs @@ -24,6 +24,7 @@ using System.ComponentModel.DataAnnotations; using Yavsc.ApiControllers.Calendar.Model; using Yavsc.Model; using Yavsc.Model.RolesAndMembers; +using Yavsc.Model.Circles; namespace Yavsc.ApiControllers.Calendar.Model { diff --git a/yavscModel/ChangeLog b/yavscModel/ChangeLog index 65d238ab..455d1db6 100644 --- a/yavscModel/ChangeLog +++ b/yavscModel/ChangeLog @@ -1,3 +1,17 @@ +2015-06-10 Paul Schneider + + * Circle.cs: + * CircleInfo.cs: + * CircleInfoCollection.cs: cleans imports + + * CircleManager.cs: implements a circle manager + + * CircleProvider.cs: Defines a default Circle provider + + * EventPub.cs: refactoring + + * YavscModel.csproj: Includes Circle provider definitions + 2015-06-09 Paul Schneider * LocalizedText.resx: diff --git a/yavscModel/RolesAndMemebers/Circle.cs b/yavscModel/Circles/Circle.cs similarity index 86% rename from yavscModel/RolesAndMemebers/Circle.cs rename to yavscModel/Circles/Circle.cs index cfd05eff..4cc5e326 100644 --- a/yavscModel/RolesAndMemebers/Circle.cs +++ b/yavscModel/Circles/Circle.cs @@ -19,17 +19,21 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . using System; -using System.Web.Http; -using System.ComponentModel.DataAnnotations; using System.Collections.Generic; -namespace Yavsc.Model.RolesAndMembers +namespace Yavsc.Model.Circles { + ///

/// Circle. /// public class Circle { + /// + /// Gets or sets the identifier. + /// + /// The identifier. + public long Id { get; set; } /// /// Gets or sets the title. /// @@ -45,7 +49,7 @@ namespace Yavsc.Model.RolesAndMembers /// /// Union the specified that. /// - /// That. + /// Those circle about to be merged. public static string [] Union (Circle []those) { List content = new List(); diff --git a/yavscModel/Circles/CircleInfo.cs b/yavscModel/Circles/CircleInfo.cs new file mode 100644 index 00000000..410ddc83 --- /dev/null +++ b/yavscModel/Circles/CircleInfo.cs @@ -0,0 +1,42 @@ +// +// CircleInfo.cs +// +// Author: +// Paul Schneider +// +// 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 . + +using System; +using System.ComponentModel.DataAnnotations; + +namespace Yavsc.Model.Circles +{ + + /// + /// Circle info. + /// + public class CircleInfo + { + long Id { get; set; } + string Title { get; set; } + CircleInfo(Circle c) + { + Id = c.Id; + Title = c.Title; + } + } + +} diff --git a/yavscModel/Circles/CircleInfoCollection.cs b/yavscModel/Circles/CircleInfoCollection.cs new file mode 100644 index 00000000..fd72868e --- /dev/null +++ b/yavscModel/Circles/CircleInfoCollection.cs @@ -0,0 +1,35 @@ +// +// CircleInfoCollection.cs +// +// Author: +// Paul Schneider +// +// 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 . + +using System; +using System.Collections.Generic; + +namespace Yavsc.Model.Circles +{ + + /// + /// Circle info collection. + /// + public class CircleInfoCollection : List + { + } + +} diff --git a/yavscModel/Circles/CircleManager.cs b/yavscModel/Circles/CircleManager.cs new file mode 100644 index 00000000..f349829b --- /dev/null +++ b/yavscModel/Circles/CircleManager.cs @@ -0,0 +1,115 @@ +// +// CircleManager.cs +// +// Author: +// Paul Schneider +// +// 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 . +using System; +using System.Security.Permissions; +using System.Configuration; +using System.Collections.Specialized; +using System.Collections; +using System.Reflection; + +namespace Yavsc.Model.Circles +{ + /// + /// Circle manager. + /// + public class CircleManager + { + /// + /// Initializes a new instance of the class. + /// + public CircleManager () + { + } + private static CircleProvider defaultProvider=null; + /// + /// Gets the default provider. + /// + /// The default provider. + public static CircleProvider DefaultProvider { + get { + if (defaultProvider == null) + GetProviderSettings (); + return defaultProvider; + } + } + + [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] + private static void GetProviderSettings() + { + System.Configuration.Configuration config = + ConfigurationManager.OpenExeConfiguration( + ConfigurationUserLevel.None); + + ProtectedConfigurationSection pSection = + config.GetSection("circleProviders") + as ProtectedConfigurationSection; + + + ProviderSettingsCollection providerSettings = + pSection.Providers; + if (pSection.DefaultProvider != null) { + ConstructorInfo ci = Type.GetType (providerSettings [pSection.DefaultProvider].Type).GetConstructor (Type.EmptyTypes); + defaultProvider = ci.Invoke (Type.EmptyTypes) as CircleProvider; + } + /* + + foreach (ProviderSettings pSettings in + providerSettings) + + + { + + + Console.WriteLine( + "Provider settings name: {0}", + pSettings.Name); + + + Console.WriteLine( + "Provider settings type: {0}", + pSettings.Type); + + NameValueCollection parameters = + pSettings.Parameters; + + IEnumerator pEnum = + parameters.GetEnumerator(); + + int i = 0; + while (pEnum.MoveNext()) + { + string pLength = + parameters[i].Length.ToString(); + Console.WriteLine( + "Provider ssettings: {0} has {1} parameters", + pSettings.Name, pLength); + + } + + + } + */ + + } + + } +} + diff --git a/yavscModel/Circles/CircleProvider.cs b/yavscModel/Circles/CircleProvider.cs new file mode 100644 index 00000000..cebabb32 --- /dev/null +++ b/yavscModel/Circles/CircleProvider.cs @@ -0,0 +1,75 @@ +// +// CircleManager.cs +// +// Author: +// Paul Schneider +// +// 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 . +using System; +using System.Security.Permissions; +using System.Configuration; +using System.Collections.Specialized; +using System.Collections; +using System.Reflection; +using System.Configuration.Provider; + +namespace Yavsc.Model.Circles +{ + /// + /// Circle provider. + /// + public class CircleProvider: ProviderBase + { + /// + /// Add the specified title and users. + /// + /// Title. + /// Users. + public void Add(string owner, string title, string [] users) + { + throw new NotImplementedException (); + } + /// + /// Delete the specified id. + /// + /// Title. + public void Delete(string owner, string title) + { + throw new NotImplementedException (); + } + + /// + /// Get the specified id. + /// + /// Title. + public Circle Get(string owner, string title) + { + throw new NotImplementedException (); + } + + + /// + /// List this instance. + /// + public CircleInfoCollection List() + { + throw new NotImplementedException (); + } + + } + +} + diff --git a/yavscModel/YavscModel.csproj b/yavscModel/YavscModel.csproj index 1a2d4c17..c6f1866f 100644 --- a/yavscModel/YavscModel.csproj +++ b/yavscModel/YavscModel.csproj @@ -36,11 +36,11 @@ - + @@ -155,10 +155,14 @@ - + + + + + @@ -172,6 +176,7 @@ +