WIP
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
|
||||
@ -25,7 +25,8 @@
|
||||
<DefineConstants>TRACE;DEBUG;DEV</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet />
|
||||
<CodeAnalysisRuleSet>
|
||||
</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -34,7 +35,8 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet />
|
||||
<CodeAnalysisRuleSet>
|
||||
</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
@ -46,7 +48,6 @@
|
||||
<Compile Include="Converters\Behaviors\IntegerEntryBehavior.cs" />
|
||||
<Compile Include="Converters\Behaviors\EditorMaxLengthValidator.cs" />
|
||||
<Compile Include="Converters\Behaviors\DecimalValidatorBehavior.cs" />
|
||||
<Compile Include="Converters\Behaviors\MarkdownViewLengthValidator.cs" />
|
||||
<Compile Include="Converters\Behaviors\PickerBehavior.cs" />
|
||||
<Compile Include="Converters\Behaviors\RegexValidatorBehavior.cs" />
|
||||
<Compile Include="Converters\Behaviors\StarBehavior.cs" />
|
||||
@ -232,6 +233,7 @@
|
||||
<Compile Include="Views\UserListView.xaml.cs">
|
||||
<DependentUpon>UserListView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Converters\Behaviors\MarkdownViewLengthValidator.Cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="App.xaml">
|
||||
@ -501,12 +503,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\YavscLib\YavscLib.csproj">
|
||||
<Project>{67f9d3a8-f71e-4428-913f-c37ae82cdb24}</Project>
|
||||
<Name>YavscLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Images\Chat\talk.png" />
|
||||
</ItemGroup>
|
||||
|
17
BookAStar/BookAStar/BookAStar.sln
Normal file
17
BookAStar/BookAStar/BookAStar.sln
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookAStar", "BookAStar.csproj", "{A0815650-0A0A-47B0-8826-771F0E1AD137}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A0815650-0A0A-47B0-8826-771F0E1AD137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A0815650-0A0A-47B0-8826-771F0E1AD137}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A0815650-0A0A-47B0-8826-771F0E1AD137}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A0815650-0A0A-47B0-8826-771F0E1AD137}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -12,8 +12,9 @@ namespace Yavsc.WebApi.Controllers
|
||||
using ViewModels.Account;
|
||||
using Models.Auth;
|
||||
using Yavsc.Helpers;
|
||||
using System;
|
||||
|
||||
[Authorize,Route("~/api/account")]
|
||||
[Authorize,Route("~/api/account"),Obsolete]
|
||||
public class ApiAccountController : Controller
|
||||
{
|
||||
|
||||
|
@ -10,7 +10,6 @@ using Microsoft.Extensions.Logging;
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System;
|
||||
using Yavsc.Model;
|
||||
using Yavsc.Models.Messaging;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Booking;
|
||||
|
148
Yavsc/ApiControllers/CircleApiController.cs
Normal file
148
Yavsc/ApiControllers/CircleApiController.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/cirle")]
|
||||
public class CircleApiController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CircleApiController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/CircleApi
|
||||
[HttpGet]
|
||||
public IEnumerable<Circle> GetCircle()
|
||||
{
|
||||
return _context.Circle;
|
||||
}
|
||||
|
||||
// GET: api/CircleApi/5
|
||||
[HttpGet("{id}", Name = "GetCircle")]
|
||||
public async Task<IActionResult> GetCircle([FromRoute] long id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return Ok(circle);
|
||||
}
|
||||
|
||||
// PUT: api/CircleApi/5
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutCircle([FromRoute] long id, [FromBody] Circle circle)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != circle.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(circle).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!CircleExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/CircleApi
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostCircle([FromBody] Circle circle)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.Circle.Add(circle);
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateException)
|
||||
{
|
||||
if (CircleExists(circle.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return CreatedAtRoute("GetCircle", new { id = circle.Id }, circle);
|
||||
}
|
||||
|
||||
// DELETE: api/CircleApi/5
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteCircle([FromRoute] long id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
_context.Circle.Remove(circle);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Ok(circle);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_context.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private bool CircleExists(long id)
|
||||
{
|
||||
return _context.Circle.Count(e => e.Id == id) > 0;
|
||||
}
|
||||
}
|
||||
}
|
148
Yavsc/ApiControllers/CircleMemberApiController.cs
Normal file
148
Yavsc/ApiControllers/CircleMemberApiController.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/circlemember")]
|
||||
public class CircleMemberApiController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CircleMemberApiController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: api/CircleMemberApi
|
||||
[HttpGet]
|
||||
public IEnumerable<CircleMember> GetCircleMembers()
|
||||
{
|
||||
return _context.CircleMembers;
|
||||
}
|
||||
|
||||
// GET: api/CircleMemberApi/5
|
||||
[HttpGet("{id}", Name = "GetCircleMember")]
|
||||
public async Task<IActionResult> GetCircleMember([FromRoute] long id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return Ok(circleMember);
|
||||
}
|
||||
|
||||
// PUT: api/CircleMemberApi/5
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutCircleMember([FromRoute] long id, [FromBody] CircleMember circleMember)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != circleMember.Id)
|
||||
{
|
||||
return HttpBadRequest();
|
||||
}
|
||||
|
||||
_context.Entry(circleMember).State = EntityState.Modified;
|
||||
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!CircleMemberExists(id))
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
// POST: api/CircleMemberApi
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostCircleMember([FromBody] CircleMember circleMember)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
_context.CircleMembers.Add(circleMember);
|
||||
try
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateException)
|
||||
{
|
||||
if (CircleMemberExists(circleMember.Id))
|
||||
{
|
||||
return new HttpStatusCodeResult(StatusCodes.Status409Conflict);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return CreatedAtRoute("GetCircleMember", new { id = circleMember.Id }, circleMember);
|
||||
}
|
||||
|
||||
// DELETE: api/CircleMemberApi/5
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteCircleMember([FromRoute] long id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.Id == id);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
_context.CircleMembers.Remove(circleMember);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Ok(circleMember);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_context.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private bool CircleMemberExists(long id)
|
||||
{
|
||||
return _context.CircleMembers.Count(e => e.Id == id) > 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ namespace Yavsc.ApiControllers
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yavsc.Services;
|
||||
using Yavsc.Models.Messaging;
|
||||
using Yavsc.ViewModels;
|
||||
|
||||
[Route("api/pdfestimate"), Authorize]
|
||||
public class PdfEstimateController : Controller
|
||||
|
@ -3,10 +3,12 @@ using System.Linq;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Models;
|
||||
using Models.Relationship;
|
||||
|
||||
[Produces("application/json")]
|
||||
[Route("~/api/PostTagsApi")]
|
||||
public class PostTagsApiController : Controller
|
||||
|
@ -7,6 +7,7 @@ using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Models.Relationship;
|
||||
[Produces("application/json")]
|
||||
[Route("api/TagsApi")]
|
||||
public class TagsApiController : Controller
|
||||
|
@ -1,10 +1,13 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[ServiceFilter(typeof(LanguageActionFilter))]
|
||||
public class CircleController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
@ -15,26 +18,26 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
|
||||
// GET: Circle
|
||||
public IActionResult Index()
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(_context.CircleMembers.ToList());
|
||||
return View(await _context.Circle.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Circle/Details/5
|
||||
public IActionResult Details(long? id)
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CircleMember circleMember = _context.CircleMembers.Single(m => m.Id == id);
|
||||
if (circleMember == null)
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Create
|
||||
@ -46,73 +49,73 @@ namespace Yavsc.Controllers
|
||||
// POST: Circle/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(CircleMember circleMember)
|
||||
public async Task<IActionResult> Create(Circle circle)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.CircleMembers.Add(circleMember);
|
||||
_context.SaveChanges();
|
||||
_context.Circle.Add(circle);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(circleMember);
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CircleMember circleMember = _context.CircleMembers.Single(m => m.Id == id);
|
||||
if (circleMember == null)
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(circleMember);
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// POST: Circle/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(CircleMember circleMember)
|
||||
public async Task<IActionResult> Edit(Circle circle)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(circleMember);
|
||||
_context.SaveChanges();
|
||||
_context.Update(circle);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(circleMember);
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CircleMember circleMember = _context.CircleMembers.Single(m => m.Id == id);
|
||||
if (circleMember == null)
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// POST: Circle/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CircleMember circleMember = _context.CircleMembers.Single(m => m.Id == id);
|
||||
_context.CircleMembers.Remove(circleMember);
|
||||
_context.SaveChanges();
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
_context.Circle.Remove(circle);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
|
122
Yavsc/Controllers/CircleMemberController.cs
Normal file
122
Yavsc/Controllers/CircleMemberController.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CircleMemberController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CircleMemberController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: CircleMember
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.CircleMembers.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: CircleMember/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.Id == id);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMember/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: CircleMember/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(CircleMember circleMember)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.CircleMembers.Add(circleMember);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMember/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.Id == id);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// POST: CircleMember/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(CircleMember circleMember)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(circleMember);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMember/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.Id == id);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// POST: CircleMember/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.Id == id);
|
||||
_context.CircleMembers.Remove(circleMember);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ using Yavsc.Services;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Models.Relationship;
|
||||
|
||||
[ServiceFilter(typeof(LanguageActionFilter))]
|
||||
public class CommandController : Controller
|
||||
{
|
||||
|
@ -13,6 +13,7 @@ using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Billing;
|
||||
using Yavsc.Models.Booking;
|
||||
using Yavsc.ViewModels;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
@ -23,6 +23,8 @@ using Yavsc.Models.Identity;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Models.Relationship;
|
||||
|
||||
[Authorize, ServiceFilter(typeof(LanguageActionFilter))]
|
||||
public class ManageController : Controller
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Yavsc.Model.societe.com;
|
||||
|
||||
namespace Yavsc.Helpers
|
||||
{
|
||||
using Models.societe.com;
|
||||
public static class ComapnyInfoHelpers {
|
||||
public static async Task<CompanyInfoMessage> CheckSiren(this HttpClient web,
|
||||
string siren, CompanyInfoSettings api)
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
namespace Yavsc.Interfaces
|
||||
{
|
||||
using Yavsc.Models.Messaging;
|
||||
using Models.Relationship;
|
||||
using Models.Messaging;
|
||||
public interface IBookQueryData
|
||||
{
|
||||
ClientProviderInfo Client { get; set; }
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -243,5 +243,7 @@ namespace Yavsc.Models
|
||||
AddTimestamps();
|
||||
return await base.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public DbSet<Circle> Circle { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using Yavsc.Models.Market;
|
||||
|
||||
namespace Yavsc.Models.Booking
|
||||
{
|
||||
using Models.Relationship;
|
||||
/// <summary>
|
||||
/// A date, between two persons
|
||||
/// </summary>
|
||||
|
||||
public class RendezVous: Service {
|
||||
// Haut les mains.
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
namespace Yavsc.Models.Calendar
|
||||
{
|
||||
using Models.Relationship;
|
||||
/// <summary>
|
||||
/// Position and keyphrase.
|
||||
/// </summary>
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Yavsc.Model.Forms
|
||||
namespace Yavsc.Models.Forms
|
||||
{
|
||||
using Interfaces;
|
||||
|
||||
|
@ -3,13 +3,14 @@ using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Models.Identity;
|
||||
using Yavsc.Models.Chat;
|
||||
using Yavsc.Models.Bank;
|
||||
using Yavsc.Models.Access;
|
||||
|
||||
namespace Yavsc.Models
|
||||
{
|
||||
using Models.Relationship;
|
||||
using Models.Identity;
|
||||
using Models.Chat;
|
||||
using Models.Bank;
|
||||
using Models.Access;
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
namespace Yavsc.Models.Messaging
|
||||
{
|
||||
using Yavsc.Model;
|
||||
|
||||
//
|
||||
// BookQueryEvent.cs
|
||||
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Yavsc.Model
|
||||
namespace Yavsc.Models
|
||||
{
|
||||
using Models.Messaging;
|
||||
using Models.Relationship;
|
||||
|
||||
public class BookQueryProviderInfo
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Yavsc.Models.Messaging
|
||||
{
|
||||
using Models.Relationship;
|
||||
/// <summary>
|
||||
/// Event pub.
|
||||
/// </summary>
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace Yavsc.Models.Messaging
|
||||
{
|
||||
using Models.Relationship;
|
||||
public class ClientProviderInfo
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
|
@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Yavsc.Models
|
||||
namespace Yavsc.Models.Relationship
|
||||
{
|
||||
public partial class Circle {
|
||||
[Key, DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Yavsc.Models
|
||||
namespace Yavsc.Models.Relationship
|
||||
{
|
||||
|
||||
public partial class CircleMember
|
||||
|
@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Yavsc.Models
|
||||
namespace Yavsc.Models.Relationship
|
||||
{
|
||||
public class Contact
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Yavsc
|
||||
namespace Yavsc.Models.Relationship
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Yavsc.Models
|
||||
namespace Yavsc.Models.Relationship
|
||||
{
|
||||
public partial class PostTag
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Yavsc.Models
|
||||
namespace Yavsc.Models.Relationship
|
||||
{
|
||||
public partial class Tag
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Yavsc.Models.Workflow
|
||||
{
|
||||
using Models.Relationship;
|
||||
|
||||
public class PerformerProfile {
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Yavsc.Model.societe.com
|
||||
namespace Yavsc.Models.societe.com
|
||||
{
|
||||
|
||||
public class CompanyInfoMessage
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Model.societe.com;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
using Models.societe.com;
|
||||
public class SIRENChecker
|
||||
{
|
||||
private CompanyInfoSettings _settings;
|
||||
|
@ -6,6 +6,7 @@ using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.StaticFiles;
|
||||
using Yavsc.ViewModels;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
|
||||
namespace Yavsc
|
||||
|
@ -26,7 +26,7 @@ using Microsoft.Net.Http.Headers;
|
||||
using Yavsc.Formatters;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
using Yavsc.ViewModels.Auth.Handlers;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
|
@ -1,133 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Booking;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
|
||||
namespace Yavsc {
|
||||
|
||||
public class FileSpotInfo : IAuthorizationRequirement
|
||||
{
|
||||
public DirectoryInfo PathInfo { get; private set; }
|
||||
public FileSpotInfo(string path, Blog b) {
|
||||
PathInfo = new DirectoryInfo(path);
|
||||
AuthorId = b.AuthorId;
|
||||
BlogEntryId = b.Id;
|
||||
}
|
||||
public string AuthorId { get; private set; }
|
||||
public long BlogEntryId { get; private set; }
|
||||
|
||||
}
|
||||
public class ViewRequirement : IAuthorizationRequirement
|
||||
{
|
||||
public ViewRequirement()
|
||||
{
|
||||
}
|
||||
}
|
||||
public class BlogEditHandler : AuthorizationHandler<EditRequirement, Blog>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, EditRequirement requirement, Blog resource)
|
||||
{
|
||||
if (context.User.IsInRole(Constants.BlogModeratorGroupName))
|
||||
context.Succeed(requirement);
|
||||
else if (context.User.Identity.IsAuthenticated)
|
||||
if (resource.AuthorId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
public class PostUserFileHandler : AuthorizationHandler<EditRequirement, FileSpotInfo>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, EditRequirement requirement, FileSpotInfo resource)
|
||||
{
|
||||
if (context.User.IsInRole(Constants.BlogModeratorGroupName)
|
||||
|| context.User.IsInRole(Constants.AdminGroupName))
|
||||
context.Succeed(requirement);
|
||||
if (!context.User.Identity.IsAuthenticated)
|
||||
context.Fail();
|
||||
if (resource.AuthorId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
else context.Fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ViewFileHandler : AuthorizationHandler<ViewRequirement, ViewFileContext>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, ViewRequirement requirement, ViewFileContext fileContext)
|
||||
{
|
||||
// TODO file access rules
|
||||
if (fileContext.Path.StartsWith("/pub/"))
|
||||
context.Succeed(requirement);
|
||||
else {
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CommandViewHandler : AuthorizationHandler<ViewRequirement, BookQuery>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, ViewRequirement requirement, BookQuery resource)
|
||||
{
|
||||
if (context.User.IsInRole("FrontOffice"))
|
||||
context.Succeed(requirement);
|
||||
else if (context.User.Identity.IsAuthenticated)
|
||||
if (resource.ClientId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
else if (resource.PerformerId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
public class CommandEditHandler : AuthorizationHandler<EditRequirement, BookQuery>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, EditRequirement requirement, BookQuery resource)
|
||||
{
|
||||
if (context.User.IsInRole("FrontOffice"))
|
||||
context.Succeed(requirement);
|
||||
else if (context.User.Identity.IsAuthenticated)
|
||||
if (resource.ClientId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
public class HasTemporaryPassHandler : AuthorizationHandler<PrivateChatEntryRequirement>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, PrivateChatEntryRequirement requirement)
|
||||
{
|
||||
if (!context.User.HasClaim(c => c.Type == "TemporaryBadgeExpiry" &&
|
||||
c.Issuer == Startup.Authority))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var temporaryBadgeExpiry =
|
||||
Convert.ToDateTime(context.User.FindFirst(
|
||||
c => c.Type == "TemporaryBadgeExpiry" &&
|
||||
c.Issuer == Startup.Authority).Value);
|
||||
|
||||
if (temporaryBadgeExpiry > DateTime.Now)
|
||||
{
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class HasBadgeHandler : AuthorizationHandler<PrivateChatEntryRequirement>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, PrivateChatEntryRequirement requirement)
|
||||
{
|
||||
if (!context.User.HasClaim(c => c.Type == "BadgeNumber" &&
|
||||
c.Issuer == Startup.Authority))
|
||||
{
|
||||
return;
|
||||
}
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
24
Yavsc/ViewModels/Auth/FileSpotInfo.cs
Normal file
24
Yavsc/ViewModels/Auth/FileSpotInfo.cs
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc {
|
||||
|
||||
public class FileSpotInfo : IAuthorizationRequirement
|
||||
{
|
||||
public DirectoryInfo PathInfo { get; private set; }
|
||||
public FileSpotInfo(string path, Blog b) {
|
||||
PathInfo = new DirectoryInfo(path);
|
||||
AuthorId = b.AuthorId;
|
||||
BlogEntryId = b.Id;
|
||||
}
|
||||
public string AuthorId { get; private set; }
|
||||
public long BlogEntryId { get; private set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
public class BlogEditHandler : AuthorizationHandler<EditRequirement, Blog>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, EditRequirement requirement, Blog resource)
|
@ -2,7 +2,7 @@ using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
public class BlogViewHandler : AuthorizationHandler<ViewRequirement, Blog>
|
||||
{
|
19
Yavsc/ViewModels/Auth/Handlers/CommandEditHandler.cs
Normal file
19
Yavsc/ViewModels/Auth/Handlers/CommandEditHandler.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
using Models.Booking;
|
||||
public class CommandEditHandler : AuthorizationHandler<EditRequirement, BookQuery>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, EditRequirement requirement, BookQuery resource)
|
||||
{
|
||||
if (context.User.IsInRole("FrontOffice"))
|
||||
context.Succeed(requirement);
|
||||
else if (context.User.Identity.IsAuthenticated)
|
||||
if (resource.ClientId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
21
Yavsc/ViewModels/Auth/Handlers/CommandViewHandler.cs
Normal file
21
Yavsc/ViewModels/Auth/Handlers/CommandViewHandler.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
using Models.Booking;
|
||||
public class CommandViewHandler : AuthorizationHandler<ViewRequirement, BookQuery>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, ViewRequirement requirement, BookQuery resource)
|
||||
{
|
||||
if (context.User.IsInRole("FrontOffice"))
|
||||
context.Succeed(requirement);
|
||||
else if (context.User.Identity.IsAuthenticated)
|
||||
if (resource.ClientId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
else if (resource.PerformerId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Models.Billing;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
public class EstimateViewHandler : AuthorizationHandler<ViewRequirement, Estimate>
|
||||
{
|
17
Yavsc/ViewModels/Auth/Handlers/HasBadgeHandler.cs
Normal file
17
Yavsc/ViewModels/Auth/Handlers/HasBadgeHandler.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
public class HasBadgeHandler : AuthorizationHandler<PrivateChatEntryRequirement>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, PrivateChatEntryRequirement requirement)
|
||||
{
|
||||
if (!context.User.HasClaim(c => c.Type == "BadgeNumber" &&
|
||||
c.Issuer == Startup.Authority))
|
||||
{
|
||||
return;
|
||||
}
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
}
|
||||
}
|
27
Yavsc/ViewModels/Auth/Handlers/HasTemporaryPassHandler.cs
Normal file
27
Yavsc/ViewModels/Auth/Handlers/HasTemporaryPassHandler.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
public class HasTemporaryPassHandler : AuthorizationHandler<PrivateChatEntryRequirement>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, PrivateChatEntryRequirement requirement)
|
||||
{
|
||||
if (!context.User.HasClaim(c => c.Type == "TemporaryBadgeExpiry" &&
|
||||
c.Issuer == Startup.Authority))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var temporaryBadgeExpiry =
|
||||
Convert.ToDateTime(context.User.FindFirst(
|
||||
c => c.Type == "TemporaryBadgeExpiry" &&
|
||||
c.Issuer == Startup.Authority).Value);
|
||||
|
||||
if (temporaryBadgeExpiry > DateTime.Now)
|
||||
{
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
Yavsc/ViewModels/Auth/Handlers/PostUserFileHandler.cs
Normal file
21
Yavsc/ViewModels/Auth/Handlers/PostUserFileHandler.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
public class PostUserFileHandler : AuthorizationHandler<EditRequirement, FileSpotInfo>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, EditRequirement requirement, FileSpotInfo resource)
|
||||
{
|
||||
if (context.User.IsInRole(Constants.BlogModeratorGroupName)
|
||||
|| context.User.IsInRole(Constants.AdminGroupName))
|
||||
context.Succeed(requirement);
|
||||
if (!context.User.Identity.IsAuthenticated)
|
||||
context.Fail();
|
||||
if (resource.AuthorId == context.User.GetUserId())
|
||||
context.Succeed(requirement);
|
||||
else context.Fail();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
17
Yavsc/ViewModels/Auth/Handlers/ViewFileHandler.cs
Normal file
17
Yavsc/ViewModels/Auth/Handlers/ViewFileHandler.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels.Auth.Handlers
|
||||
{
|
||||
public class ViewFileHandler : AuthorizationHandler<ViewRequirement, ViewFileContext>
|
||||
{
|
||||
protected override void Handle(AuthorizationContext context, ViewRequirement requirement, ViewFileContext fileContext)
|
||||
{
|
||||
// TODO file access rules
|
||||
if (fileContext.Path.StartsWith("/pub/"))
|
||||
context.Succeed(requirement);
|
||||
else {
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Yavsc/ViewModels/ViewRequirement.cs
Normal file
11
Yavsc/ViewModels/ViewRequirement.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Microsoft.AspNet.Authorization;
|
||||
|
||||
namespace Yavsc.ViewModels
|
||||
{
|
||||
public class ViewRequirement : IAuthorizationRequirement
|
||||
{
|
||||
public ViewRequirement()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
@model Yavsc.Models.CircleMember
|
||||
@model Yavsc.Models.Relationship.Circle
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
@ -8,9 +8,23 @@
|
||||
|
||||
<form asp-action="Create">
|
||||
<div class="form-horizontal">
|
||||
<h4>CircleMember</h4>
|
||||
<h4>Circle</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Name" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="OwnerId" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="OwnerId" class="form-control" />
|
||||
<span asp-validation-for="OwnerId" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
@model Yavsc.Models.CircleMember
|
||||
@model Yavsc.Models.Relationship.Circle
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
@ -8,9 +8,21 @@
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>CircleMember</h4>
|
||||
<h4>Circle</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Name)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.OwnerId)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.OwnerId)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
|
@ -1,4 +1,4 @@
|
||||
@model Yavsc.Models.CircleMember
|
||||
@model Yavsc.Models.Relationship.Circle
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
@ -7,9 +7,21 @@
|
||||
<h2>Details</h2>
|
||||
|
||||
<div>
|
||||
<h4>CircleMember</h4>
|
||||
<h4>Circle</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Name)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.OwnerId)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.OwnerId)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
|
@ -1,4 +1,4 @@
|
||||
@model Yavsc.Models.CircleMember
|
||||
@model Yavsc.Models.Relationship.Circle
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
@ -8,10 +8,24 @@
|
||||
|
||||
<form asp-action="Edit">
|
||||
<div class="form-horizontal">
|
||||
<h4>CircleMember</h4>
|
||||
<h4>Circle</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Name" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="OwnerId" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="OwnerId" class="form-control" />
|
||||
<span asp-validation-for="OwnerId" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Save" class="btn btn-default" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
@model IEnumerable<Yavsc.Models.CircleMember>
|
||||
@model IEnumerable<Yavsc.Models.Relationship.Circle>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
@ -11,11 +11,23 @@
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.OwnerId)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.OwnerId)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
|
25
Yavsc/Views/CircleMember/Create.cshtml
Normal file
25
Yavsc/Views/CircleMember/Create.cshtml
Normal file
@ -0,0 +1,25 @@
|
||||
@model Yavsc.Models.Relationship.CircleMember
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h2>Create</h2>
|
||||
|
||||
<form asp-action="Create">
|
||||
<div class="form-horizontal">
|
||||
<h4>CircleMember</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
22
Yavsc/Views/CircleMember/Delete.cshtml
Normal file
22
Yavsc/Views/CircleMember/Delete.cshtml
Normal file
@ -0,0 +1,22 @@
|
||||
@model Yavsc.Models.Relationship.CircleMember
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h2>Delete</h2>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>CircleMember</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
<div class="form-actions no-color">
|
||||
<input type="submit" value="Delete" class="btn btn-default" /> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
18
Yavsc/Views/CircleMember/Details.cshtml
Normal file
18
Yavsc/Views/CircleMember/Details.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@model Yavsc.Models.Relationship.CircleMember
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h2>Details</h2>
|
||||
|
||||
<div>
|
||||
<h4>CircleMember</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</p>
|
26
Yavsc/Views/CircleMember/Edit.cshtml
Normal file
26
Yavsc/Views/CircleMember/Edit.cshtml
Normal file
@ -0,0 +1,26 @@
|
||||
@model Yavsc.Models.Relationship.CircleMember
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
|
||||
<h2>Edit</h2>
|
||||
|
||||
<form asp-action="Edit">
|
||||
<div class="form-horizontal">
|
||||
<h4>CircleMember</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Save" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
26
Yavsc/Views/CircleMember/Index.cshtml
Normal file
26
Yavsc/Views/CircleMember/Index.cshtml
Normal file
@ -0,0 +1,26 @@
|
||||
@model IEnumerable<Yavsc.Models.Relationship.CircleMember>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h2>Index</h2>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
dnx gen controller -outDir ApiControllers -api -dc ApplicationDbContext -m "$1" -name "$2ApiController"
|
||||
dnx gen controller -async -outDir ApiControllers -api -dc ApplicationDbContext -m "$1" -name "$2ApiController"
|
||||
|
||||
# dnx gen controller -outDir Controllers -dc ApplicationDbContext -udl -m {model} -name {name}Controller
|
||||
|
||||
|
8
Yavsc/contrib/genController.sh
Executable file
8
Yavsc/contrib/genController.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
dnx gen controller -async -udl -outDir Controllers -dc ApplicationDbContext -m "$1" -name "$2Controller"
|
||||
|
||||
# dnx gen controller -outDir Controllers -dc ApplicationDbContext -udl -m {model} -name {name}Controller
|
||||
|
||||
|
||||
# dnx gen controller -outDir Controllers -dc ApplicationDbContext -udl -m Yavsc.Models.Booking.MusicianSettings -name InstrumentationController -async -scripts
|
Reference in New Issue
Block a user