Merge from booking branch
This commit is contained in:
parent
25906d0227
commit
9a2652739b
266 changed files with 12833 additions and 2337 deletions
|
|
@ -104,5 +104,13 @@ namespace Yavsc.ApiControllers
|
|||
if (user != null && ModelState.IsValid)
|
||||
Url.SendActivationMessage (user);
|
||||
}
|
||||
|
||||
[ValidateAjax]
|
||||
[Authorize(Roles="Admin")]
|
||||
public void AddUserToRole(UserRole model)
|
||||
{
|
||||
Roles.AddUserToRole (model.UserName, model.Role);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ using System.Diagnostics;
|
|||
using Yavsc.Formatters;
|
||||
using Yavsc.Model;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -143,19 +146,45 @@ namespace Yavsc.ApiControllers
|
|||
/// <summary>
|
||||
/// Create the specified blog entry.
|
||||
/// </summary>
|
||||
/// <param name="bp">Bp.</param>
|
||||
/// <param name="be">Bp.</param>
|
||||
[Authorize, HttpPost]
|
||||
public long Create (BasePost bp)
|
||||
public long Post (BlogEntry be)
|
||||
{
|
||||
return BlogManager.Post (User.Identity.Name, bp.Title, "", bp.Visible, null);
|
||||
if (be.Id == 0)
|
||||
return BlogManager.Post (User.Identity.Name, be.Title,
|
||||
be.Content, be.Visible,be.AllowedCircles );
|
||||
else
|
||||
BlogManager.UpdatePost (be);
|
||||
return 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// Blog entry rating.
|
||||
/// </summary>
|
||||
public class BlogEntryRating {
|
||||
/// <summary>
|
||||
/// Gets or sets the post identifier.
|
||||
/// </summary>
|
||||
/// <value>The post identifier.</value>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the rate.
|
||||
/// </summary>
|
||||
/// <value>The rate.</value>
|
||||
public int Rate { get; set; }
|
||||
}
|
||||
|
||||
[Authorize, HttpPost]
|
||||
public void Note (long id, int note)
|
||||
/// <summary>
|
||||
/// Rate the specified model.
|
||||
/// </summary>
|
||||
/// <param name="model">Model.</param>
|
||||
[Authorize(Roles="Moderator"), HttpPost, ValidateAjax]
|
||||
public void Rate (BlogEntryRating model)
|
||||
{
|
||||
if (note < 0 || note > 100)
|
||||
throw new ArgumentException ("0<=note<=100");
|
||||
BlogManager.Note (id, note);
|
||||
if (model.Rate < 0 || model.Rate > 100)
|
||||
ModelState.AddModelError ("Rate", "0<=Rate<=100");
|
||||
else {
|
||||
BlogManager.Rate (model.Id, model.Rate);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Searchs the file.
|
||||
|
|
@ -176,7 +205,7 @@ namespace Yavsc.ApiControllers
|
|||
[Authorize, HttpPost, ValidateAjaxAttribute]
|
||||
public void SetPhoto(long id, [FromBody] string photo)
|
||||
{
|
||||
BlogManager.Provider.UpdatePostPhoto (id, photo);
|
||||
BlogManager.UpdatePostPhoto (id, photo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Yavsc.ApiControllers
|
|||
/// <summary>
|
||||
/// Front office controller.
|
||||
/// </summary>
|
||||
public class FrontOfficeController : ApiController
|
||||
public class FrontOfficeController : YavscController
|
||||
{
|
||||
/// <summary>
|
||||
/// The wfmgr.
|
||||
|
|
|
|||
|
|
@ -23,8 +23,14 @@ using System.Web.Http;
|
|||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
/// <summary>
|
||||
/// GCM controller.
|
||||
/// </summary>
|
||||
public class GCMController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Yavsc.ApiControllers.GCMController"/> class.
|
||||
/// </summary>
|
||||
public GCMController ()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,15 +25,27 @@ using System.Web.Profile;
|
|||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Yavsc controller.
|
||||
/// </summary>
|
||||
public class YavscController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Yavsc.ApiControllers.YavscController"/> class.
|
||||
/// </summary>
|
||||
public YavscController ()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Auth.
|
||||
/// </summary>
|
||||
public class Auth {
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the cookies.
|
||||
/// </summary>
|
||||
/// <param name="model">Model.</param>
|
||||
public void AllowCookies (Auth model)
|
||||
{
|
||||
// TODO check Auth when existing
|
||||
|
|
@ -43,7 +55,10 @@ namespace Yavsc.ApiControllers
|
|||
pr.Save ();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defaults the response.
|
||||
/// </summary>
|
||||
/// <returns>The response.</returns>
|
||||
protected HttpResponseMessage DefaultResponse()
|
||||
{
|
||||
return ModelState.IsValid ?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue