FIXME SR is private
This commit is contained in:
parent
8929cc9bfa
commit
123283f277
576 changed files with 75350 additions and 13070 deletions
|
|
@ -1,10 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Blog;
|
||||
|
||||
|
|
@ -36,14 +37,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BlogPost blog = _context.Blogspot.Single(m => m.Id == id);
|
||||
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(blog);
|
||||
|
|
@ -55,12 +56,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != blog.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(blog).State = EntityState.Modified;
|
||||
|
|
@ -73,7 +74,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!BlogExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -81,7 +82,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/BlogApi
|
||||
|
|
@ -90,7 +91,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Blogspot.Add(blog);
|
||||
|
|
@ -102,7 +103,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (BlogExists(blog.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -119,13 +120,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BlogPost blog = _context.Blogspot.Single(m => m.Id == id);
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Blogspot.Remove(blog);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Blog;
|
||||
namespace Yavsc.Controllers
|
||||
|
|
@ -32,14 +32,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BlogTag blogTag = await _context.TagsDomain.SingleAsync(m => m.PostId == id);
|
||||
|
||||
if (blogTag == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(blogTag);
|
||||
|
|
@ -51,12 +51,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != blogTag.PostId)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(blogTag).State = EntityState.Modified;
|
||||
|
|
@ -69,7 +69,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!BlogTagExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -77,7 +77,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/BlogTagsApi
|
||||
|
|
@ -86,7 +86,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.TagsDomain.Add(blogTag);
|
||||
|
|
@ -98,7 +98,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (BlogTagExists(blogTag.PostId))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -115,13 +115,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BlogTag blogTag = await _context.TagsDomain.SingleAsync(m => m.PostId == id);
|
||||
if (blogTag == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.TagsDomain.Remove(blogTag);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Blog;
|
||||
|
||||
|
|
@ -34,14 +31,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Comment comment = await _context.Comment.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (comment == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(comment);
|
||||
|
|
@ -53,12 +50,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != comment.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(comment).State = EntityState.Modified;
|
||||
|
|
@ -71,7 +68,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!CommentExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -79,7 +76,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/CommentsApi
|
||||
|
|
@ -106,7 +103,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (CommentExists(comment.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -122,13 +119,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Comment comment = await _context.Comment.SingleAsync(m => m.Id == id);
|
||||
if (comment == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
RemoveRecursive(comment);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
|
|
@ -63,11 +61,11 @@ namespace Yavsc.ApiControllers
|
|||
}
|
||||
if (pathex!=null) {
|
||||
_logger.LogError($"invalid sub path: '{subdir}'.");
|
||||
return HttpBadRequest(pathex);
|
||||
return BadRequest(pathex);
|
||||
}
|
||||
_logger.LogInformation($"Receiving files, saved in '{destDir}' (specified as '{subdir}').");
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = dbContext.Users.Single(
|
||||
u => u.Id == uid
|
||||
);
|
||||
|
|
@ -91,7 +89,7 @@ namespace Yavsc.ApiControllers
|
|||
[Authorize("AdministratorOnly")]
|
||||
public IActionResult AddQuota(string uname, int len)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = dbContext.Users.FirstOrDefault(
|
||||
u => u.UserName == uname
|
||||
);
|
||||
|
|
@ -107,7 +105,7 @@ namespace Yavsc.ApiControllers
|
|||
public IActionResult MoveFile([FromBody] RenameFileQuery query)
|
||||
{
|
||||
if (!ModelState.IsValid) return new BadRequestObjectResult(ModelState);
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = dbContext.Users.Single(
|
||||
u => u.Id == uid
|
||||
);
|
||||
|
|
@ -124,10 +122,10 @@ namespace Yavsc.ApiControllers
|
|||
if (!ModelState.IsValid) {
|
||||
var idvr = new ValidRemoteUserFilePathAttribute();
|
||||
|
||||
return this.HttpBadRequest(new { id = idvr.IsValid(query.id), to = idvr.IsValid(query.to), errors = ModelState });
|
||||
return this.BadRequest(new { id = idvr.IsValid(query.id), to = idvr.IsValid(query.to), errors = ModelState });
|
||||
}
|
||||
_logger.LogInformation($"Valid move query: {query.id} => {query.to}");
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = dbContext.Users.Single(
|
||||
u => u.Id == uid
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Attributes.Validation;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Messaging;
|
||||
using Yavsc.Services;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
|
|
@ -19,13 +16,16 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
private readonly ILogger logger;
|
||||
private readonly ILiveProcessor liveProcessor;
|
||||
private readonly IHubContext<ChatHub> hubContext;
|
||||
readonly ApplicationDbContext dbContext;
|
||||
|
||||
public FileSystemStreamController(ApplicationDbContext context, ILiveProcessor liveProcessor, ILoggerFactory loggerFactory)
|
||||
public FileSystemStreamController(ApplicationDbContext context, ILiveProcessor liveProcessor, ILoggerFactory loggerFactory,
|
||||
IHubContext<ChatHub> hubContext)
|
||||
{
|
||||
this.dbContext = context;
|
||||
this.logger = loggerFactory.CreateLogger<FileSystemStreamController>();
|
||||
this.liveProcessor = liveProcessor;
|
||||
this.hubContext = hubContext;
|
||||
}
|
||||
|
||||
[Authorize, Route("put/{filename}")]
|
||||
|
|
@ -33,20 +33,20 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
logger.LogInformation("Put : " + filename);
|
||||
if (!HttpContext.WebSockets.IsWebSocketRequest)
|
||||
return HttpBadRequest("not a web socket");
|
||||
return BadRequest("not a web socket");
|
||||
if (!HttpContext.User.Identity.IsAuthenticated)
|
||||
return new HttpUnauthorizedResult();
|
||||
return new UnauthorizedResult();
|
||||
var subdirs = filename.Split('/');
|
||||
var filePath = subdirs.Length > 1 ? string.Join("/", subdirs.Take(subdirs.Length-1)) : null;
|
||||
var shortFileName = subdirs[subdirs.Length-1];
|
||||
if (!shortFileName.IsValidShortFileName())
|
||||
{
|
||||
logger.LogInformation("invalid file name : " + filename);
|
||||
return HttpBadRequest("invalid file name");
|
||||
return BadRequest("invalid file name");
|
||||
}
|
||||
logger.LogInformation("validated: api/stream/Put: "+filename);
|
||||
var userName = User.GetUserName();
|
||||
var hubContext = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
|
||||
|
||||
string url = string.Format(
|
||||
"{0}/{1}/{2}",
|
||||
Startup.UserFilesOptions.RequestPath.ToUriComponent(),
|
||||
|
|
@ -54,7 +54,7 @@ namespace Yavsc.ApiControllers
|
|||
filename
|
||||
);
|
||||
|
||||
hubContext.Clients.All.addPublicStream(new PublicStreamInfo
|
||||
hubContext.Clients.All.SendAsync("addPublicStream", new PublicStreamInfo
|
||||
{
|
||||
sender = userName,
|
||||
url = url,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models.Blog;
|
||||
|
||||
[Produces("application/json")]
|
||||
|
|
@ -34,14 +35,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BlogTag postTag = _context.TagsDomain.Single(m => m.PostId == id);
|
||||
|
||||
if (postTag == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(postTag);
|
||||
|
|
@ -53,12 +54,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != postTag.PostId)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(postTag).State = EntityState.Modified;
|
||||
|
|
@ -71,7 +72,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!PostTagExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -79,7 +80,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/PostTagsApi
|
||||
|
|
@ -88,7 +89,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.TagsDomain.Add(postTag);
|
||||
|
|
@ -100,7 +101,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (PostTagExists(postTag.PostId))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -117,13 +118,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BlogTag postTag = _context.TagsDomain.Single(m => m.PostId == id);
|
||||
if (postTag == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.TagsDomain.Remove(postTag);
|
||||
|
|
@ -146,4 +147,4 @@ namespace Yavsc.Controllers
|
|||
return _context.TagsDomain.Count(e => e.PostId == id) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Data.Entity;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models.Relationship;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
[Produces("application/json")]
|
||||
[Route("api/TagsApi")]
|
||||
public class TagsApiController : Controller
|
||||
|
|
@ -37,14 +36,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Tag tag = _context.Tags.Single(m => m.Id == id);
|
||||
|
||||
if (tag == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(tag);
|
||||
|
|
@ -56,12 +55,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != tag.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(tag).State = EntityState.Modified;
|
||||
|
|
@ -75,7 +74,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!TagExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -83,7 +82,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/TagsApi
|
||||
|
|
@ -92,7 +91,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Tags.Add(tag);
|
||||
|
|
@ -104,7 +103,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (TagExists(tag.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -121,13 +120,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Tag tag = _context.Tags.Single(m => m.Id == id);
|
||||
if (tag == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Tags.Remove(tag);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
|
|
@ -37,14 +38,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Activity activity = await _context.Activities.SingleAsync(m => m.Code == id);
|
||||
|
||||
if (activity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
// Also return hidden ones
|
||||
// hidden doesn't mean disabled
|
||||
|
|
@ -57,12 +58,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != activity.Code)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(activity).State = EntityState.Modified;
|
||||
|
|
@ -75,7 +76,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ActivityExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -83,7 +84,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/ActivityApi
|
||||
|
|
@ -92,7 +93,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Activities.Add(activity);
|
||||
|
|
@ -104,7 +105,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ActivityExists(activity.Code))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -121,13 +122,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Activity activity = await _context.Activities.SingleAsync(m => m.Code == id);
|
||||
if (activity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Activities.Remove(activity);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,7 @@
|
|||
using System.IO;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Linq;
|
||||
using Microsoft.Data.Entity;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.ViewModels;
|
||||
|
|
@ -21,6 +13,8 @@ namespace Yavsc.ApiControllers
|
|||
|
||||
using Models.Messaging;
|
||||
using ViewModels.Auth;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
[Route("api/bill"), Authorize]
|
||||
public class BillingController : Controller
|
||||
|
|
@ -59,7 +53,7 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
var bill = await billingService.GetBillAsync(billingCode, id);
|
||||
|
||||
if (!await authorizationService.AuthorizeAsync(User, bill, new ViewRequirement()))
|
||||
if ( authorizationService.AuthorizeAsync(User, bill, new ViewRequirement()).IsFaulted)
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
|
|
@ -77,11 +71,11 @@ namespace Yavsc.ApiControllers
|
|||
|
||||
if (bill==null) {
|
||||
logger.LogCritical ( $"# not found !! {id} in {billingCode}");
|
||||
return this.HttpNotFound();
|
||||
return this.NotFound();
|
||||
}
|
||||
logger.LogVerbose(JsonConvert.SerializeObject(bill));
|
||||
logger.LogTrace(JsonConvert.SerializeObject(bill));
|
||||
|
||||
if (!await authorizationService.AuthorizeAsync(User, bill, new ViewRequirement()))
|
||||
if (!(await authorizationService.AuthorizeAsync(User, bill, new ViewRequirement())).Succeeded)
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
|
|
@ -96,7 +90,7 @@ namespace Yavsc.ApiControllers
|
|||
|
||||
if (bill==null) {
|
||||
logger.LogCritical ( $"# not found !! {id} in {billingCode}");
|
||||
return this.HttpNotFound();
|
||||
return this.NotFound();
|
||||
}
|
||||
logger.LogWarning("Got bill ack:"+bill.GetIsAcquitted().ToString());
|
||||
return ViewComponent("Bill",new object[] { billingCode, bill, OutputFormat.Pdf, true } );
|
||||
|
|
@ -112,7 +106,9 @@ namespace Yavsc.ApiControllers
|
|||
.FirstOrDefault(e=>e.Id == id);
|
||||
if (estimate == null)
|
||||
return new BadRequestResult();
|
||||
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||
if (!(await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement())).Succeeded)
|
||||
|
||||
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
|
|
@ -138,25 +134,26 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
// For authorization purpose
|
||||
var estimate = dbContext.Estimates.FirstOrDefault(e=>e.Id == id);
|
||||
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||
if (!(await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement())).Succeeded)
|
||||
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
|
||||
var filename = AbstractFileSystemHelpers.SignFileNameFormat("pro", billingCode, id);
|
||||
FileInfo fi = new FileInfo(Path.Combine(AbstractFileSystemHelpers.UserBillsDirName, filename));
|
||||
if (!fi.Exists) return HttpNotFound(new { Error = "Professional signature not found" });
|
||||
if (!fi.Exists) return NotFound(new { Error = "Professional signature not found" });
|
||||
return File(fi.OpenRead(), "application/x-pdf", filename); ;
|
||||
}
|
||||
|
||||
[HttpPost("clisign/{billingCode}/{id}")]
|
||||
public async Task<IActionResult> CliSign(string billingCode, long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var estimate = dbContext.Estimates.Include( e=>e.Query
|
||||
).Include(e=>e.Owner).Include(e=>e.Owner.Performer).Include(e=>e.Client)
|
||||
.FirstOrDefault( e=> e.Id == id && e.Query.ClientId == uid );
|
||||
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||
if (!(await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement())).Succeeded)
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
|
|
@ -173,14 +170,14 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
// For authorization purpose
|
||||
var estimate = dbContext.Estimates.FirstOrDefault(e=>e.Id == id);
|
||||
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||
if (!(await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement())).Succeeded)
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
|
||||
var filename = AbstractFileSystemHelpers.SignFileNameFormat("pro", billingCode, id);
|
||||
FileInfo fi = new FileInfo(Path.Combine(AbstractFileSystemHelpers.UserBillsDirName, filename));
|
||||
if (!fi.Exists) return HttpNotFound(new { Error = "Professional signature not found" });
|
||||
if (!fi.Exists) return NotFound(new { Error = "Professional signature not found" });
|
||||
return File(fi.OpenRead(), "application/x-pdf", filename); ;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
|
|
@ -14,6 +13,8 @@ namespace Yavsc.Controllers
|
|||
using Yavsc.Models.Workflow;
|
||||
using Yavsc.Models.Billing;
|
||||
using Yavsc.Abstract.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
[Produces("application/json")]
|
||||
[Route("api/bookquery"), Authorize(Roles = "Performer,Administrator")]
|
||||
|
|
@ -37,7 +38,7 @@ namespace Yavsc.Controllers
|
|||
[HttpGet]
|
||||
public IEnumerable<RdvQueryProviderInfo> GetCommands(long maxId=long.MaxValue)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var now = DateTime.Now;
|
||||
|
||||
var result = _context.RdvQueries.Include(c => c.Location).
|
||||
|
|
@ -69,15 +70,15 @@ namespace Yavsc.Controllers
|
|||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
RdvQuery bookQuery = _context.RdvQueries.Where(c => c.ClientId == uid || c.PerformerId == uid).Single(m => m.Id == id);
|
||||
|
||||
if (bookQuery == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(bookQuery);
|
||||
|
|
@ -89,16 +90,16 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != bookQuery.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (bookQuery.ClientId != uid)
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
|
||||
_context.Entry(bookQuery).State = EntityState.Modified;
|
||||
|
||||
|
|
@ -110,7 +111,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!BookQueryExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -118,7 +119,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/BookQueryApi
|
||||
|
|
@ -127,9 +128,9 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (bookQuery.ClientId != uid)
|
||||
{
|
||||
ModelState.AddModelError("ClientId", "You must be the client at creating a book query");
|
||||
|
|
@ -144,7 +145,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (BookQueryExists(bookQuery.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -161,16 +162,16 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
RdvQuery bookQuery = _context.RdvQueries.Single(m => m.Id == id);
|
||||
|
||||
if (bookQuery == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
if (bookQuery.ClientId != uid) return HttpNotFound();
|
||||
if (bookQuery.ClientId != uid) return NotFound();
|
||||
|
||||
_context.RdvQueries.Remove(bookQuery);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
|
@ -192,4 +193,4 @@ namespace Yavsc.Controllers
|
|||
return _context.RdvQueries.Count(e => e.Id == id) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Billing;
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ namespace Yavsc.Controllers
|
|||
if (ownerId == null) ownerId = User.GetUserId();
|
||||
else if (!UserIsAdminOrThis(ownerId)) // throw new Exception("Not authorized") ;
|
||||
// or just do nothing
|
||||
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
return new StatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
return Ok(_context.Estimates.Include(e => e.Bill).Where(e => e.OwnerId == ownerId));
|
||||
}
|
||||
// GET: api/Estimate/5
|
||||
|
|
@ -50,19 +51,19 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Estimate estimate = _context.Estimates.Include(e => e.Bill).Single(m => m.Id == id);
|
||||
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (UserIsAdminOrInThese(estimate.ClientId, estimate.OwnerId))
|
||||
return Ok(estimate);
|
||||
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
return new StatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
// PUT: api/Estimate/5
|
||||
|
|
@ -77,15 +78,15 @@ namespace Yavsc.Controllers
|
|||
|
||||
if (id != estimate.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
{
|
||||
if (uid != estimate.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId", "You can only modify your own estimates");
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +99,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!EstimateExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -113,7 +114,7 @@ namespace Yavsc.Controllers
|
|||
[HttpPost, Produces("application/json")]
|
||||
public IActionResult PostEstimate([FromBody] Estimate estimate)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (estimate.OwnerId == null) estimate.OwnerId = uid;
|
||||
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
|
|
@ -121,7 +122,7 @@ namespace Yavsc.Controllers
|
|||
if (uid != estimate.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId", "You can only create your own estimates");
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +131,7 @@ namespace Yavsc.Controllers
|
|||
var query = _context.RdvQueries.FirstOrDefault(q => q.Id == estimate.CommandId);
|
||||
if (query == null)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
query.ValidationDate = DateTime.Now;
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
|
@ -159,7 +160,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (EstimateExists(estimate.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -175,22 +176,22 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Estimate estimate = _context.Estimates.Include(e => e.Bill).Single(m => m.Id == id);
|
||||
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
{
|
||||
if (uid != estimate.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId", "You can only create your own estimates");
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
}
|
||||
_context.Estimates.Remove(estimate);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Billing;
|
||||
|
||||
|
|
@ -24,7 +22,7 @@ namespace Yavsc.Controllers
|
|||
[HttpGet]
|
||||
public IEnumerable<EstimateTemplate> GetEstimateTemplate()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return _context.EstimateTemplates.Where(x=>x.OwnerId==uid);
|
||||
}
|
||||
|
||||
|
|
@ -34,15 +32,15 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
EstimateTemplate estimateTemplate = _context.EstimateTemplates.Where(x=>x.OwnerId==uid).Single(m => m.Id == id);
|
||||
|
||||
if (estimateTemplate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(estimateTemplate);
|
||||
|
|
@ -54,17 +52,17 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != estimateTemplate.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (estimateTemplate.OwnerId!=uid)
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
return new StatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
|
||||
_context.Entry(estimateTemplate).State = EntityState.Modified;
|
||||
|
||||
|
|
@ -76,7 +74,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!EstimateTemplateExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -84,7 +82,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/EstimateTemplatesApi
|
||||
|
|
@ -93,7 +91,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
estimateTemplate.OwnerId=User.GetUserId();
|
||||
|
||||
|
|
@ -106,7 +104,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (EstimateTemplateExists(estimateTemplate.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -123,18 +121,18 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
EstimateTemplate estimateTemplate = _context.EstimateTemplates.Single(m => m.Id == id);
|
||||
if (estimateTemplate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (estimateTemplate.OwnerId!=uid)
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
return new StatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
|
||||
_context.EstimateTemplates.Remove(estimateTemplate);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
|
@ -156,4 +154,4 @@ namespace Yavsc.Controllers
|
|||
return _context.EstimateTemplates.Count(e => e.Id == id) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
|
|
@ -30,10 +30,10 @@ namespace Yavsc.ApiControllers
|
|||
[HttpPost("query/reject")]
|
||||
public IActionResult RejectQuery(string billingCode, long queryId)
|
||||
{
|
||||
if (billingCode == null) return HttpBadRequest("billingCode");
|
||||
if (queryId == 0) return HttpBadRequest("queryId");
|
||||
if (billingCode == null) return BadRequest("billingCode");
|
||||
if (queryId == 0) return BadRequest("queryId");
|
||||
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
|
||||
if (billing == null) return HttpBadRequest();
|
||||
if (billing == null) return BadRequest();
|
||||
billing.Rejected = true;
|
||||
billing.RejectedAt = DateTime.Now;
|
||||
dbContext.SaveChanges();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Services;
|
||||
|
|
@ -44,7 +43,7 @@ namespace Yavsc.Controllers
|
|||
ModelState.AddModelError("id","Specifier un identifiant de prestataire valide");
|
||||
}
|
||||
else {
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (uid != id) return new ChallengeResult();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Market;
|
||||
|
||||
|
|
@ -34,14 +31,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Product product = _context.Products.Single(m => m.Id == id);
|
||||
|
||||
if (product == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(product);
|
||||
|
|
@ -53,12 +50,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != product.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(product).State = EntityState.Modified;
|
||||
|
|
@ -71,7 +68,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ProductExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -79,7 +76,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/ProductApi
|
||||
|
|
@ -88,7 +85,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Products.Add(product);
|
||||
|
|
@ -100,7 +97,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ProductExists(product.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -117,13 +114,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Product product = _context.Products.Single(m => m.Id == id);
|
||||
if (product == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Products.Remove(product);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Messaging;
|
||||
|
||||
|
|
@ -26,7 +23,7 @@ namespace Yavsc.Controllers
|
|||
[HttpGet]
|
||||
public IEnumerable<DimissClicked> GetDimissClicked()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return _context.DimissClicked.Where(d=>d.UserId == uid);
|
||||
}
|
||||
|
||||
|
|
@ -47,19 +44,19 @@ namespace Yavsc.Controllers
|
|||
[HttpGet("{id}", Name = "GetDimissClicked")]
|
||||
public async Task<IActionResult> GetDimissClicked([FromRoute] string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != id) return new ChallengeResult();
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
DimissClicked dimissClicked = await _context.DimissClicked.SingleAsync(m => m.UserId == id);
|
||||
|
||||
if (dimissClicked == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(dimissClicked);
|
||||
|
|
@ -69,17 +66,17 @@ namespace Yavsc.Controllers
|
|||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutDimissClicked([FromRoute] string id, [FromBody] DimissClicked dimissClicked)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != id || uid != dimissClicked.UserId) return new ChallengeResult();
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != dimissClicked.UserId)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(dimissClicked).State = EntityState.Modified;
|
||||
|
|
@ -92,7 +89,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!DimissClickedExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -100,19 +97,19 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/DimissClicksApi
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostDimissClicked([FromBody] DimissClicked dimissClicked)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != dimissClicked.UserId) return new ChallengeResult();
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.DimissClicked.Add(dimissClicked);
|
||||
|
|
@ -124,7 +121,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (DimissClickedExists(dimissClicked.UserId))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -139,19 +136,19 @@ namespace Yavsc.Controllers
|
|||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteDimissClicked([FromRoute] string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (uid != id) return new ChallengeResult();
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
DimissClicked dimissClicked = await _context.DimissClicked.SingleAsync(m => m.UserId == id);
|
||||
if (dimissClicked == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.DimissClicked.Remove(dimissClicked);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
|
|
@ -34,14 +30,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BrusherProfile brusherProfile = await _context.BrusherProfile.SingleAsync(m => m.UserId == id);
|
||||
|
||||
if (brusherProfile == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(brusherProfile);
|
||||
|
|
@ -53,17 +49,17 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != brusherProfile.UserId)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
if (id != User.GetUserId())
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
_context.Entry(brusherProfile).State = EntityState.Modified;
|
||||
|
||||
|
|
@ -75,7 +71,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!BrusherProfileExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -83,7 +79,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/BursherProfilesApi
|
||||
|
|
@ -92,7 +88,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.BrusherProfile.Add(brusherProfile);
|
||||
|
|
@ -104,7 +100,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (BrusherProfileExists(brusherProfile.UserId))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -121,13 +117,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BrusherProfile brusherProfile = await _context.BrusherProfile.SingleAsync(m => m.UserId == id);
|
||||
if (brusherProfile == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.BrusherProfile.Remove(brusherProfile);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
|
||||
|
|
@ -16,14 +15,15 @@ namespace Yavsc.ApiControllers
|
|||
using Models.Haircut;
|
||||
using System.Threading.Tasks;
|
||||
using Helpers;
|
||||
using Microsoft.Data.Entity;
|
||||
using Models.Payment;
|
||||
using Newtonsoft.Json;
|
||||
using PayPal.PayPalAPIInterfaceService.Model;
|
||||
using Yavsc.Models.Haircut.Views;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
[Route("api/haircut")]
|
||||
[Route("api/haircut")][Authorize]
|
||||
public class HairCutController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -40,7 +40,9 @@ namespace Yavsc.ApiControllers
|
|||
// user, as a client
|
||||
public IActionResult Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
var now = DateTime.Now;
|
||||
var result = _context.HairCutQueries
|
||||
.Include(q => q.Prestation)
|
||||
|
|
@ -61,14 +63,14 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
HairCutQuery hairCutQuery = await _context.HairCutQueries.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (hairCutQuery == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(hairCutQuery);
|
||||
|
|
@ -80,12 +82,12 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != hairCutQuery.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(hairCutQuery).State = EntityState.Modified;
|
||||
|
|
@ -98,7 +100,7 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!HairCutQueryExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -106,20 +108,20 @@ namespace Yavsc.ApiControllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostQuery(HairCutQuery hairCutQuery)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return new BadRequestObjectResult(ModelState);
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.HairCutQueries.Add(hairCutQuery);
|
||||
|
|
@ -131,7 +133,7 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (HairCutQueryExists(hairCutQuery.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -159,13 +161,13 @@ namespace Yavsc.ApiControllers
|
|||
}
|
||||
catch (Exception ex) {
|
||||
_logger.LogError(ex.Message);
|
||||
return new HttpStatusCodeResult(500);
|
||||
return new StatusCodeResult(500);
|
||||
}
|
||||
|
||||
if (payment==null) {
|
||||
_logger.LogError("Error doing SetExpressCheckout, aborting.");
|
||||
_logger.LogError(JsonConvert.SerializeObject(Startup.PayPalSettings));
|
||||
return new HttpStatusCodeResult(500);
|
||||
return new StatusCodeResult(500);
|
||||
}
|
||||
switch (payment.Ack)
|
||||
{
|
||||
|
|
@ -195,13 +197,13 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
HairCutQuery hairCutQuery = await _context.HairCutQueries.SingleAsync(m => m.Id == id);
|
||||
if (hairCutQuery == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.HairCutQueries.Remove(hairCutQuery);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
|
|
@ -33,14 +29,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == id);
|
||||
|
||||
if (hyperLink == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(hyperLink);
|
||||
|
|
@ -52,12 +48,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != hyperLink.HRef)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(hyperLink).State = EntityState.Modified;
|
||||
|
|
@ -70,7 +66,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!HyperLinkExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -78,7 +74,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/HyperLinkApi
|
||||
|
|
@ -87,7 +83,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.HyperLink.Add(hyperLink);
|
||||
|
|
@ -99,7 +95,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (HyperLinkExists(hyperLink.HRef))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -116,13 +112,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == id);
|
||||
if (hyperLink == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.HyperLink.Remove(hyperLink);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Server.Models.IT.SourceCode;
|
||||
|
||||
|
|
@ -35,14 +31,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
GitRepositoryReference gitRepositoryReference = await _context.GitRepositoryReference.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (gitRepositoryReference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(gitRepositoryReference);
|
||||
|
|
@ -54,7 +50,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Entry(gitRepositoryReference).State = EntityState.Modified;
|
||||
|
|
@ -67,7 +63,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!GitRepositoryReferenceExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -75,7 +71,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/GitRefsApi
|
||||
|
|
@ -84,7 +80,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.GitRepositoryReference.Add(gitRepositoryReference);
|
||||
|
|
@ -96,7 +92,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (GitRepositoryReferenceExists(gitRepositoryReference.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -113,13 +109,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
GitRepositoryReference gitRepositoryReference = await _context.GitRepositoryReference.SingleAsync(m => m.Id == id);
|
||||
if (gitRepositoryReference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.GitRepositoryReference.Remove(gitRepositoryReference);
|
||||
|
|
@ -142,4 +138,4 @@ namespace Yavsc.Controllers
|
|||
return _context.GitRepositoryReference.Count(e => e.Id == id) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Server.Models.EMailing;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
|
@ -36,14 +31,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
MailingTemplate mailingTemplate = await _context.MailingTemplate.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (mailingTemplate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(mailingTemplate);
|
||||
|
|
@ -55,12 +50,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != mailingTemplate.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(mailingTemplate).State = EntityState.Modified;
|
||||
|
|
@ -73,7 +68,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!MailingTemplateExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -81,7 +76,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/MailingTemplateApi
|
||||
|
|
@ -90,7 +85,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.MailingTemplate.Add(mailingTemplate);
|
||||
|
|
@ -102,7 +97,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (MailingTemplateExists(mailingTemplate.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -119,13 +114,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
MailingTemplate mailingTemplate = await _context.MailingTemplate.SingleAsync(m => m.Id == id);
|
||||
if (mailingTemplate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.MailingTemplate.Remove(mailingTemplate);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical;
|
||||
|
||||
|
|
@ -33,14 +30,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
MusicalPreference musicalPreference = _context.MusicalPreference.Single(m => m.OwnerProfileId == id);
|
||||
|
||||
if (musicalPreference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(musicalPreference);
|
||||
|
|
@ -51,12 +48,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != musicalPreference.OwnerProfileId)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(musicalPreference).State = EntityState.Modified;
|
||||
|
|
@ -69,7 +66,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!MusicalPreferenceExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -77,7 +74,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/MusicalPreferencesApi
|
||||
|
|
@ -86,7 +83,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.MusicalPreference.Add(musicalPreference);
|
||||
|
|
@ -98,7 +95,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (MusicalPreferenceExists(musicalPreference.OwnerProfileId))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -115,13 +112,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
MusicalPreference musicalPreference = _context.MusicalPreference.Single(m => m.OwnerProfileId == id);
|
||||
if (musicalPreference == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.MusicalPreference.Remove(musicalPreference);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical;
|
||||
|
||||
|
|
@ -33,14 +30,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(musicalTendency);
|
||||
|
|
@ -52,12 +49,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != musicalTendency.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(musicalTendency).State = EntityState.Modified;
|
||||
|
|
@ -70,7 +67,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!MusicalTendencyExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -78,7 +75,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/MusicalTendenciesApi
|
||||
|
|
@ -87,7 +84,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.MusicalTendency.Add(musicalTendency);
|
||||
|
|
@ -99,7 +96,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (MusicalTendencyExists(musicalTendency.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -116,13 +113,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.MusicalTendency.Remove(musicalTendency);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
public class PodcastController : Controller
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Identity;
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ public class NativeConfidentialController : Controller
|
|||
public IActionResult Register(
|
||||
[FromBody] DeviceDeclaration declaration)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
|
|
@ -40,12 +41,15 @@ public class NativeConfidentialController : Controller
|
|||
declaration.LatestActivityUpdate = DateTime.Now;
|
||||
|
||||
_logger.LogInformation($"Registering device with id:{declaration.DeviceId} for {uid}");
|
||||
var alreadyRegisteredDevice = _context.DeviceDeclaration.FirstOrDefault(d => d.DeviceId == declaration.DeviceId);
|
||||
DeviceDeclaration? alreadyRegisteredDevice = _context.DeviceDeclaration.FirstOrDefault(d => d.DeviceId == declaration.DeviceId);
|
||||
var deviceAlreadyRegistered = (alreadyRegisteredDevice!=null);
|
||||
if (deviceAlreadyRegistered)
|
||||
if (alreadyRegisteredDevice==null)
|
||||
{
|
||||
_logger.LogInformation($"deviceAlreadyRegistered");
|
||||
// Override an exiting owner
|
||||
declaration.DeclarationDate = DateTime.Now;
|
||||
declaration.DeviceOwnerId = uid;
|
||||
_context.DeviceDeclaration.Add(declaration);
|
||||
}
|
||||
else {
|
||||
alreadyRegisteredDevice.DeviceOwnerId = uid;
|
||||
alreadyRegisteredDevice.Model = declaration.Model;
|
||||
alreadyRegisteredDevice.Platform = declaration.Platform;
|
||||
|
|
@ -53,18 +57,13 @@ public class NativeConfidentialController : Controller
|
|||
_context.Update(alreadyRegisteredDevice);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation($"new device");
|
||||
declaration.DeclarationDate = DateTime.Now;
|
||||
declaration.DeviceOwnerId = uid;
|
||||
_context.DeviceDeclaration.Add(declaration as DeviceDeclaration);
|
||||
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
}
|
||||
|
||||
var latestActivityUpdate = _context.Activities.Max(a=>a.DateModified);
|
||||
return Json(new {
|
||||
IsAnUpdate = deviceAlreadyRegistered,
|
||||
UpdateActivities = (latestActivityUpdate != declaration.LatestActivityUpdate)
|
||||
UpdateActivities = latestActivityUpdate != declaration.LatestActivityUpdate
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
|
|
@ -23,20 +24,20 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Models.Blog.BlogPost blogpost = _context.Blogspot.Single(x=>x.Id == id);
|
||||
|
||||
if (blogpost == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (blogpost.AuthorId!=uid)
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
|
||||
blogpost.Rate = rate;
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Access;
|
||||
|
||||
|
|
@ -34,22 +32,22 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
BlackListed blackListed = _context.BlackListed.Single(m => m.Id == id);
|
||||
if (blackListed == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
if (!CheckPermission(blackListed))
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
|
||||
return Ok(blackListed);
|
||||
}
|
||||
|
||||
private bool CheckPermission(BlackListed blackListed)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != blackListed.OwnerId)
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.FrontOfficeGroupName))
|
||||
|
|
@ -62,15 +60,15 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != blackListed.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
if (!CheckPermission(blackListed))
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
_context.Entry(blackListed).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
|
|
@ -81,7 +79,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!BlackListedExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -89,7 +87,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/BlackListApi
|
||||
|
|
@ -98,11 +96,11 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (!CheckPermission(blackListed))
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
|
||||
_context.BlackListed.Add(blackListed);
|
||||
try
|
||||
|
|
@ -113,7 +111,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (BlackListedExists(blackListed.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -130,17 +128,17 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
BlackListed blackListed = _context.BlackListed.Single(m => m.Id == id);
|
||||
if (blackListed == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (!CheckPermission(blackListed))
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
|
||||
_context.BlackListed.Remove(blackListed);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Access;
|
||||
|
||||
|
|
@ -34,15 +31,15 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
CircleAuthorizationToBlogPost circleAuthorizationToBlogPost = await _context.CircleAuthorizationToBlogPost.SingleAsync(
|
||||
m => m.CircleId == id && m.Allowed.OwnerId == uid );
|
||||
|
||||
if (circleAuthorizationToBlogPost == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(circleAuthorizationToBlogPost);
|
||||
|
|
@ -54,12 +51,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != circleAuthorizationToBlogPost.CircleId)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
if (!CheckOwner(circleAuthorizationToBlogPost.CircleId))
|
||||
|
|
@ -76,7 +73,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!CircleAuthorizationToBlogPostExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -84,12 +81,12 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
private bool CheckOwner (long circleId)
|
||||
{
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var circle = _context.Circle.First(c=>c.Id==circleId);
|
||||
_context.Entry(circle).State = EntityState.Detached;
|
||||
return (circle.OwnerId == uid);
|
||||
|
|
@ -100,7 +97,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
if (!CheckOwner(circleAuthorizationToBlogPost.CircleId))
|
||||
{
|
||||
|
|
@ -115,7 +112,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (CircleAuthorizationToBlogPostExists(circleAuthorizationToBlogPost.CircleId))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -132,9 +129,9 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
CircleAuthorizationToBlogPost circleAuthorizationToBlogPost = await _context.CircleAuthorizationToBlogPost.Include(
|
||||
a=>a.Allowed
|
||||
|
|
@ -142,7 +139,7 @@ namespace Yavsc.Controllers
|
|||
&& m.Allowed.OwnerId == uid);
|
||||
if (circleAuthorizationToBlogPost == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
_context.CircleAuthorizationToBlogPost.Remove(circleAuthorizationToBlogPost);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Data.Entity;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.ViewModels.Chat;
|
||||
using Yavsc.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
|
@ -72,12 +69,12 @@ namespace Yavsc.Controllers
|
|||
if (!ModelState.IsValid)
|
||||
// Miguel mech profiler
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var user = dbContext.ApplicationUser.Include(u => u.Connections).FirstOrDefault(u => u.UserName == userName);
|
||||
|
||||
if (user == null) return HttpNotFound();
|
||||
if (user == null) return NotFound();
|
||||
|
||||
return Ok(new ChatUserInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Chat;
|
||||
|
||||
|
|
@ -35,7 +31,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
ChatRoomAccess chatRoomAccess = await _context.ChatRoomAccess.SingleAsync(m => m.ChannelName == id);
|
||||
|
|
@ -44,16 +40,16 @@ namespace Yavsc.Controllers
|
|||
|
||||
if (chatRoomAccess == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != chatRoomAccess.UserId && uid != chatRoomAccess.Room.OwnerId
|
||||
&& ! User.IsInRole(Constants.AdminGroupName))
|
||||
|
||||
{
|
||||
ModelState.AddModelError("UserId","get refused");
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
return Ok(chatRoomAccess);
|
||||
|
|
@ -65,20 +61,20 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
if (id != chatRoomAccess.ChannelName)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
|
||||
if (uid != room.OwnerId && ! User.IsInRole(Constants.AdminGroupName))
|
||||
{
|
||||
ModelState.AddModelError("ChannelName", "access put refused");
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Entry(chatRoomAccess).State = EntityState.Modified;
|
||||
|
|
@ -91,7 +87,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ChatRoomAccessExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -99,7 +95,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/ChatRoomAccessApi
|
||||
|
|
@ -108,15 +104,15 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
if (room == null || (uid != room.OwnerId && ! User.IsInRole(Constants.AdminGroupName)))
|
||||
{
|
||||
ModelState.AddModelError("ChannelName", "access post refused");
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.ChatRoomAccess.Add(chatRoomAccess);
|
||||
|
|
@ -129,7 +125,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ChatRoomAccessExists(chatRoomAccess.ChannelName))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -146,21 +142,21 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
ChatRoomAccess chatRoomAccess = await _context.ChatRoomAccess.Include(acc => acc.Room).SingleAsync(m => m.ChannelName == id);
|
||||
if (chatRoomAccess == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
if (room == null || (uid != room.OwnerId && chatRoomAccess.UserId != uid && ! User.IsInRole(Constants.AdminGroupName)))
|
||||
{
|
||||
ModelState.AddModelError("UserId", "access drop refused");
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.ChatRoomAccess.Remove(chatRoomAccess);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Chat;
|
||||
|
||||
|
|
@ -34,14 +30,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
ChatRoom chatRoom = await _context.ChatRoom.SingleAsync(m => m.Name == id);
|
||||
|
||||
if (chatRoom == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(chatRoom);
|
||||
|
|
@ -53,17 +49,17 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != chatRoom.Name)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
if (User.GetUserId() != chatRoom.OwnerId )
|
||||
{
|
||||
return HttpBadRequest(new {error = "OwnerId"});
|
||||
return BadRequest(new {error = "OwnerId"});
|
||||
}
|
||||
|
||||
_context.Entry(chatRoom).State = EntityState.Modified;
|
||||
|
|
@ -76,7 +72,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ChatRoomExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -84,7 +80,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/ChatRoomApi
|
||||
|
|
@ -93,12 +89,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (User.GetUserId() != chatRoom.OwnerId )
|
||||
{
|
||||
return HttpBadRequest(new {error = "OwnerId"});
|
||||
return BadRequest(new {error = "OwnerId"});
|
||||
}
|
||||
|
||||
_context.ChatRoom.Add(chatRoom);
|
||||
|
|
@ -110,7 +106,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ChatRoomExists(chatRoom.Name))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -127,7 +123,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
ChatRoom chatRoom = await _context.ChatRoom.SingleAsync(m => m.Name == id);
|
||||
|
||||
|
|
@ -135,13 +131,13 @@ namespace Yavsc.Controllers
|
|||
|
||||
if (chatRoom == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (User.GetUserId() != chatRoom.OwnerId )
|
||||
{
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return HttpBadRequest(new {error = "OwnerId"});
|
||||
return BadRequest(new {error = "OwnerId"});
|
||||
}
|
||||
|
||||
_context.ChatRoom.Remove(chatRoom);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
|
|
@ -34,14 +30,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(circle);
|
||||
|
|
@ -53,12 +49,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != circle.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(circle).State = EntityState.Modified;
|
||||
|
|
@ -71,7 +67,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!CircleExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -79,7 +75,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/CircleApi
|
||||
|
|
@ -88,7 +84,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Circle.Add(circle);
|
||||
|
|
@ -100,7 +96,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (CircleExists(circle.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -117,13 +113,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Circle.Remove(circle);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Abstract.Identity;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
|
|
@ -32,12 +30,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != clientProviderInfo.UserId)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(clientProviderInfo).State = EntityState.Modified;
|
||||
|
|
@ -50,7 +48,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ClientProviderInfoExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -58,7 +56,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/ContactsApi
|
||||
|
|
@ -67,7 +65,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.ClientProviderInfo.Add(clientProviderInfo);
|
||||
|
|
@ -79,7 +77,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ClientProviderInfoExists(clientProviderInfo.UserId))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -96,13 +94,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
ClientProviderInfo clientProviderInfo = _context.ClientProviderInfo.Single(m => m.UserId == id);
|
||||
if (clientProviderInfo == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.ClientProviderInfo.Remove(clientProviderInfo);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Market;
|
||||
|
||||
|
|
@ -34,14 +31,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Service service = _context.Services.Single(m => m.Id == id);
|
||||
|
||||
if (service == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(service);
|
||||
|
|
@ -53,12 +50,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != service.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(service).State = EntityState.Modified;
|
||||
|
|
@ -71,7 +68,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ServiceExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -79,7 +76,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/ServiceApi
|
||||
|
|
@ -88,7 +85,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Services.Add(service);
|
||||
|
|
@ -100,7 +97,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ServiceExists(service.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -117,13 +114,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Service service = _context.Services.Single(m => m.Id == id);
|
||||
if (service == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Services.Remove(service);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.IT.Fixing;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
|
|
@ -73,14 +68,14 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (bug == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(bug);
|
||||
|
|
@ -92,12 +87,12 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != bug.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(bug).State = EntityState.Modified;
|
||||
|
|
@ -110,7 +105,7 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!BugExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -118,7 +113,7 @@ namespace Yavsc.ApiControllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/bug
|
||||
|
|
@ -127,7 +122,7 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Bug.Add(bug);
|
||||
|
|
@ -139,7 +134,7 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (BugExists(bug.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -156,13 +151,13 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bug == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Bug.Remove(bug);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -12,9 +12,8 @@ namespace Yavsc.WebApi.Controllers
|
|||
using ViewModels.Account;
|
||||
using Yavsc.Helpers;
|
||||
using System.Linq;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using Yavsc.Abstract.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
[Authorize(),Route("~/api/account")]
|
||||
public class ApiAccountController : Controller
|
||||
|
|
@ -132,12 +131,11 @@ namespace Yavsc.WebApi.Controllers
|
|||
if (User==null)
|
||||
return new BadRequestObjectResult(
|
||||
new { error = "user not found" });
|
||||
var uid = User.GetUserId();
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
|
||||
var userData = await _dbContext.Users
|
||||
.Include(u=>u.PostalAddress)
|
||||
.Include(u=>u.AccountBalance)
|
||||
.Include(u=>u.Roles)
|
||||
.FirstAsync(u=>u.Id == uid);
|
||||
|
||||
var user = new Yavsc.Models.Auth.Me(userData.Id, userData.UserName, userData.Email,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Abstract.Identity;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
|
|
@ -49,14 +50,14 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
ApplicationUser applicationUser = _context.Users.Include(u=>u.Roles).Include(u=>u.Logins).Include(u=>u.Claims).Single(m => m.Id == id);
|
||||
ApplicationUser applicationUser = _context.Users.Single(m => m.Id == id);
|
||||
|
||||
if (applicationUser == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(applicationUser);
|
||||
|
|
@ -68,12 +69,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != applicationUser.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(applicationUser).State = EntityState.Modified;
|
||||
|
|
@ -86,7 +87,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ApplicationUserExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -94,7 +95,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
return new StatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/ApplicationUserApi
|
||||
|
|
@ -103,7 +104,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Users.Add(applicationUser);
|
||||
|
|
@ -115,7 +116,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ApplicationUserExists(applicationUser.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
return new StatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -132,13 +133,13 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
ApplicationUser applicationUser = _context.Users.Single(m => m.Id == id);
|
||||
if (applicationUser == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Users.Remove(applicationUser);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Abstract.Identity;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
namespace Yavsc.ApiControllers.accounting
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue