* Profile.aspx: * MyProfile.aspx: * AccountController.cs: renamed the Profile method to "MyProfile", could avoid issue at migrating to MVC5 * favicon.png: favicon now displays a ~"Yavsc" * BlogManager.cs: * BlogsApiController.cs: The authorisation for removing a post is now implemented at Manager's side * BlogsController.cs: Removes this odd call to a static method from the Api controller * CalendarApi.cs: * GoogleController.cs: no more json output for the calls to the Google Api * WorkFlowController.cs: sorted using clauses * Basket.cs: * Commande.cs: * EstimToPdfFormatter.cs: * Brand.cs: adds xml doc * RssFeedsFormatter.cs: modifies xml doc * TexToPdfFormatter.cs: refactoring * Global.asax.cs: Document formatting * BBCodeHelper.cs: encapsulates the url display from the BBCode in starting and closing characters : "<>" * OAuth2.cs: * SimpleJsonPostMethod.cs: using System.Runtime.Serialization.Json instead of Newtonsof.Json * App.master: updating the favicon * RegistrationPending.aspx: fixes the returnUrl usage * AssemblyInfo.aspx: better explanation for this list * Web.config: tried to migrate to MVC5 (using NuGets) * Estim.cs: * ChangePasswordModel.cs: adds xmldoc * BasketController.cs: * BlogProvidersConfigurationSection.cs: cosmetic change * GoogleErrorMessage.cs: - adds xml docs - renders ctor from JsonReaderException obsolete * MvcActionValueBinder.cs: not used * web.config: no more used, gave it up to migrate to MVC5
72 lines
1.9 KiB
C#
72 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.Http;
|
|
using Npgsql.Web.Blog;
|
|
using Yavsc.Model.Blogs;
|
|
|
|
namespace Yavsc.ApiControllers
|
|
{
|
|
/// <summary>
|
|
/// Blogs API controller.
|
|
/// </summary>
|
|
public class BlogsApiController : ApiController
|
|
{
|
|
private const string adminRoleName = "Admin";
|
|
|
|
/// <summary>
|
|
/// Initialize the specified controllerContext.
|
|
/// </summary>
|
|
/// <param name="controllerContext">Controller context.</param>
|
|
protected override void Initialize (System.Web.Http.Controllers.HttpControllerContext controllerContext)
|
|
{
|
|
base.Initialize (controllerContext);
|
|
if (!Roles.RoleExists (adminRoleName)) {
|
|
Roles.CreateRole (adminRoleName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tag the specified postid and tag.
|
|
/// </summary>
|
|
/// <param name="postid">Postid.</param>
|
|
/// <param name="tag">Tag.</param>
|
|
public long Tag (long postid,string tag) {
|
|
BlogEntry e = BlogManager.GetPost (postid);
|
|
if (!Roles.IsUserInRole ("Admin")) {
|
|
string rguser = Membership.GetUser ().UserName;
|
|
if (rguser != e.UserName) {
|
|
throw new AccessViolationException (
|
|
string.Format (
|
|
"Vous n'avez pas le droit de tagger des billets du Blog de {0}",
|
|
e.UserName));
|
|
}
|
|
}
|
|
return BlogManager.Tag (postid, tag);
|
|
}
|
|
/// <summary>
|
|
/// Removes the post.
|
|
/// </summary>
|
|
/// <param name="user">User.</param>
|
|
/// <param name="title">Title.</param>
|
|
public void RemovePost(string user, string title) {
|
|
BlogEntry e = BlogManager.GetPost (user, title);
|
|
if (e == null) {
|
|
throw new KeyNotFoundException (
|
|
string.Format("Aucun post portant le titre \"{0}\" pour l'utilisateur {1}",
|
|
title, user));
|
|
}
|
|
BlogManager.RemovePost (user, title);
|
|
}
|
|
/// <summary>
|
|
/// Removes the tag.
|
|
/// </summary>
|
|
/// <param name="tagid">Tagid.</param>
|
|
public void RemoveTag(long tagid) {
|
|
throw new NotImplementedException ();
|
|
}
|
|
}
|
|
}
|
|
|