Merge from booking branch

This commit is contained in:
Paul Schneider 2015-11-17 22:22:59 +01:00
commit 9a2652739b
266 changed files with 12833 additions and 2337 deletions

View file

@ -33,7 +33,7 @@ namespace Yavsc.Model.Blogs
/// <summary>
/// Base post.
/// </summary>
public class BasePost {
public class BasePost: IRating {
/// <summary>
/// The identifier.
/// </summary>
@ -140,5 +140,25 @@ namespace Yavsc.Model.Blogs
/// </summary>
/// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
public bool Visible { get; set ; }
/// <summary>
/// Gets or sets the rate.
/// </summary>
/// <value>The rate.</value>
public int Rate { get; set; }
/// <summary>
/// Gets or sets the circles allowed to read this ticket.
/// An empty collection specifies a public post.
/// </summary>
/// <value>The circles.</value>
[Display(Name="Cercles autorisés")]
public long[] AllowedCircles { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
public string [] Tags { get; set ; }
}
}

View file

@ -37,6 +37,21 @@ namespace Yavsc.Model.Blogs
/// The intro.
/// </summary>
public string Intro;
public bool Truncated;
public BasePostInfo (BlogEntry be)
{
Title = be.Title;
Id = be.Id;
Posted = be.Posted;
Modified = be.Modified;
Intro = MarkdownHelper.MarkdownIntro (be.Content, out Truncated);
Photo = be.Photo;
Tags = be.Tags;
AllowedCircles = be.AllowedCircles;
Visible = be.Visible;
Rate = be.Rate;
}
}
}

View file

@ -11,22 +11,7 @@ namespace Yavsc.Model.Blogs
/// Blog entry.
/// </summary>
public class BlogEntry : BasePost {
/// <summary>
/// Gets or sets the circles allowed to read this ticket.
/// An empty collection specifies a public post.
/// </summary>
/// <value>The circles.</value>
[Display(Name="Cercles autorisés")]
public long[] AllowedCircles { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
public string [] Tags { get; set ; }
string content;
/// <summary>
@ -34,7 +19,6 @@ namespace Yavsc.Model.Blogs
/// </summary>
/// <value>The content.</value>
[DisplayName("Corps du billet")]
[Required(ErrorMessage = "S'il vous plait, saisissez un texte.")]
public string Content {
get {
return content;

View file

@ -84,19 +84,10 @@ namespace Yavsc.Model.Blogs
/// </summary>
public IEnumerable<IGrouping<string,BasePostInfo>> GroupByTitle ()
{
bool truncated;
return from be in this
orderby be.Posted descending
group
new BasePostInfo { Author = be.Author, Id = be.Id,
Posted = be.Posted, Modified = be.Modified,
Intro = MarkdownHelper.MarkdownIntro (be.Content, out truncated),
Visible = be.Visible,
Photo = be.Photo
}
by be.Title
into titlegroup
select titlegroup;
group new BasePostInfo(be) by be.Title
into titlegroup select titlegroup;
}
/// <summary>
@ -105,19 +96,10 @@ namespace Yavsc.Model.Blogs
/// <returns>The by user.</returns>
public IEnumerable<IGrouping<string,BasePostInfo>> GroupByUser ()
{
bool truncated;
return from be in this
orderby be.Posted descending
group
new BasePostInfo {
Title = be.Title,
Id = be.Id,
Posted = be.Posted,
Modified = be.Modified,
Intro = MarkdownHelper.MarkdownIntro (be.Content, out truncated),
Photo = be.Photo,
Visible = be.Visible
}
new BasePostInfo (be)
by be.Author
into usergroup
select usergroup;

View file

@ -1,35 +0,0 @@
using System;
using System.Configuration;
using System.Reflection;
using System.Collections.Specialized;
namespace Yavsc.Model.Blogs
{
/// <summary>
/// Blog helper.
/// </summary>
public static class BlogHelper
{
/// <summary>
/// Gets the provider.
/// </summary>
/// <returns>The provider.</returns>
public static BlogProvider GetProvider ()
{
DataProviderConfigurationSection config = ConfigurationManager.GetSection ("system.web/blog") as DataProviderConfigurationSection;
if (config == null)
throw new ConfigurationErrorsException("The configuration bloc for the blog provider was not found");
ProviderSettings celt =
config.Providers[config.DefaultProvider];
if (config == null)
throw new ConfigurationErrorsException("The default blog provider was not found");
ConstructorInfo ci = Type.GetType (celt.Type).GetConstructor (Type.EmptyTypes);
BlogProvider bp = ci.Invoke (Type.EmptyTypes) as BlogProvider;
bp.Initialize (celt.Name, celt.Parameters);
return bp;
}
}
}

View file

@ -12,11 +12,21 @@ using System.Collections.Generic;
namespace Yavsc.Model.Blogs
{
/// <summary>
/// Blog manager.
/// </summary>
public static class BlogManager
public static class BlogManager
{
static BlogProvider provider = null;
static BlogProvider Provider {
get {
if (provider == null)
provider = ManagerHelper.GetDefaultProvider<BlogProvider>
("system.web/blog");
return provider;
}
}
/// <summary>
/// Removes the comment.
/// </summary>
@ -39,20 +49,6 @@ namespace Yavsc.Model.Blogs
Provider.Comment (from, postid, content);
}
static BlogProvider provider;
/// <summary>
/// Gets the provider.
/// </summary>
/// <value>The provider.</value>
public static BlogProvider Provider {
get {
if (provider == null)
provider = BlogHelper.GetProvider ();
return provider;
}
}
/// <summary>
/// Gets the post.
/// </summary>
@ -99,7 +95,10 @@ namespace Yavsc.Model.Blogs
{
Provider.UpdatePost (postid, title, content, visible, cids);
}
public static void UpdatePost (BlogEntry be)
{
Provider.UpdatePost (be);
}
/// <summary>
/// Updates the post photo.
/// </summary>
@ -152,9 +151,22 @@ namespace Yavsc.Model.Blogs
}
Provider.RemoveTitle (username, title);
}
public static TagInfo GetTagInfo(string tagname)
/// <summary>
/// Gets the tag info.
/// </summary>
/// <returns>The tag info.</returns>
/// <param name="tagname">Tagname.</param>
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
public static TagInfo GetTagInfo(string tagname, int pageIndex=0, int pageSize=50)
{
return Provider.GetTagInfo (tagname);
var res = new TagInfo (tagname);
int recordCount = 0;
var posts = Provider.FindPost (null,tagname,FindBlogEntryFlags.MatchTag,pageIndex,pageSize,out recordCount);
res.Titles = posts.GroupByTitle ().ToArray();
res.Name = tagname;
// out int recordCount ,
return res;
}
/// <summary>
/// Lasts the posts.
@ -192,9 +204,9 @@ namespace Yavsc.Model.Blogs
}
public static void Note (long postid, int note)
public static void Rate (long postid, int rate)
{
Provider.Note (postid, note);
Provider.Rate (postid, rate);
}
/// <summary>

View file

@ -19,12 +19,6 @@ namespace Yavsc.Model.Blogs
/// <param name="postid">Postid.</param>
public abstract BlogEntry GetPost (long postid);
/// <summary>
/// Gets the tag info.
/// </summary>
/// <returns>The tag info.</returns>
/// <param name="tagname">Tagname.</param>
public abstract TagInfo GetTagInfo (string tagname);
/// <summary>
/// Gets the post collection from a given user and at a given title.
@ -50,8 +44,8 @@ namespace Yavsc.Model.Blogs
/// Note the specified postid and note.
/// </summary>
/// <param name="postid">Postid.</param>
/// <param name="note">Note.</param>
public abstract void Note (long postid, int note);
/// <param name="rate">rate.</param>
public abstract void Rate (long postid, int rate);
/// <summary>
@ -65,6 +59,13 @@ namespace Yavsc.Model.Blogs
/// <param name="allowedCircles">Allowed circles.</param>
public abstract void UpdatePost (long postid, string title, string content, bool visible, long[] allowedCircles);
/// <summary>
/// Updates the post.
/// </summary>
/// <param name="be">Be.</param>
public abstract void UpdatePost ( BlogEntry be );
/// <summary>
/// Finds a post.
/// </summary>

View file

@ -20,13 +20,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Yavsc.Model.Blogs
{
/// <summary>
/// Tag info.
/// </summary>
public abstract class TagInfo
public class TagInfo
{
string name;
/// <summary>
@ -54,7 +55,7 @@ namespace Yavsc.Model.Blogs
/// Gets the titles.
/// </summary>
/// <value>The titles.</value>
public abstract IEnumerable<BasePostInfo> Titles { get; }
public IEnumerable<IGrouping<string,BasePostInfo>> Titles { get; set; }
}
}