This commit is contained in:
Darren Wright 2020-04-09 20:17:29 +01:00
Родитель a3afb508a5
Коммит 18e9dda4e5
103 изменённых файлов: 41949 добавлений и 0 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -348,3 +348,4 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
Project.Zap/appsettings.Development.json

Просмотреть файл

@ -0,0 +1,9 @@
namespace Project.Zap.Library.Models
{
public class Address
{
public string City { get; set; }
public string ZipOrPostCode { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,15 @@
using System;
using System.Text.Json.Serialization;
namespace Project.Zap.Library.Models
{
public class Employee
{
[JsonPropertyName("id")]
public string id { get; set; } = Guid.NewGuid().ToString();
public string EmployeeId { get; set; }
public string PartnerOrgId { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Project.Zap.Library.Models
{
public class Organization
{
[JsonPropertyName("id")]
public string id { get; set; } = Guid.NewGuid().ToString();
public string Name { get; set; }
public StoreTypes StoreType { get; set; }
public List<string> ManagerEmails { get; set; }
public List<Store> Stores { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,15 @@
using System;
using System.Text.Json.Serialization;
namespace Project.Zap.Library.Models
{
public class PartnerOrganization
{
[JsonPropertyName("id")]
public string id { get; set; } = Guid.NewGuid().ToString();
public string Name { get; set; }
public string RegistrationCode { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,26 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Text.Json.Serialization;
namespace Project.Zap.Library.Models
{
public class Shift
{
[JsonPropertyName("id")]
public string id { get; set; } = Guid.NewGuid().ToString();
public string StoreName { get; set; }
[DisplayFormat(DataFormatString = "{yyyy-MM-ddTHH:mm}")]
public DateTime Start { get; set; }
public DateTime End { get; set; }
public string WorkType { get; set; }
public bool Allocated { get; set; }
public string EmployeeId { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,11 @@
namespace Project.Zap.Library.Models
{
public class Store
{
public string Name { get; set; }
public Address Address { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,9 @@
namespace Project.Zap.Library.Models
{
public enum StoreTypes
{
Open,
Closed
}
}

Просмотреть файл

@ -0,0 +1,10 @@
namespace Project.Zap.Library.Models
{
public class User
{
public string DisplayName { get; set; }
public string Email { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.7.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,50 @@
using Microsoft.Azure.Cosmos;
using Project.Zap.Library.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Project.Zap.Library.Services
{
public class EmployeeRepository : IRepository<Employee>
{
private readonly Container cosmosContainer;
public EmployeeRepository(Database cosmosDatabase)
{
this.cosmosContainer = cosmosDatabase.CreateContainerIfNotExistsAsync("employees", "/EmployeeId").Result;
}
public async Task Add(Employee item)
{
await this.cosmosContainer.CreateItemAsync<Employee>(item);
}
public Task Delete(Expression<Func<Employee, bool>> query)
{
throw new NotImplementedException();
}
public Employee Get(string id)
{
throw new NotImplementedException();
}
public IEnumerable<Employee> Get(Expression<Func<Employee, bool>> query)
{
return this.cosmosContainer.GetItemLinqQueryable<Employee>(true).Where(query).AsEnumerable();
}
public Task<IEnumerable<Employee>> Get()
{
throw new NotImplementedException();
}
public Task<Employee> Update(Employee item)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Project.Zap.Library.Services
{
public interface IRepository<T>
{
T Get(string id);
IEnumerable<T> Get(Expression<Func<T, bool>> query);
Task<IEnumerable<T>> Get();
Task Add(T item);
Task <T> Update(T item);
Task Delete(Expression<Func<T, bool>> query);
}
}

Просмотреть файл

@ -0,0 +1,58 @@
using Microsoft.Azure.Cosmos;
using Project.Zap.Library.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Project.Zap.Library.Services
{
public class OrganizationRepository : IRepository<Organization>
{
private Container cosmosContainer;
public OrganizationRepository(Database cosmosDatabase)
{
this.cosmosContainer = cosmosDatabase.CreateContainerIfNotExistsAsync("organization", "/Name").Result;
}
public async Task Add(Organization item)
{
await this.cosmosContainer.CreateItemAsync(item, new PartitionKey(item.Name));
}
public Task Delete(Expression<Func<Organization, bool>> query)
{
throw new NotImplementedException();
}
public Organization Get(string id)
{
throw new System.NotImplementedException();
}
public Task<IEnumerable<Organization>> Get()
{
return Task.FromResult(this.cosmosContainer.GetItemLinqQueryable<Organization>(true).Where(x => x.StoreType == StoreTypes.Open).AsEnumerable());
}
public IEnumerable<Organization> Get(Expression<Func<Organization, bool>> query)
{
throw new NotImplementedException();
}
public async Task<Organization> Update(Organization item)
{
ItemResponse<Organization> current = await this.cosmosContainer.ReadItemAsync<Organization>(item.id, new PartitionKey(item.Name));
current.Resource.Stores = new List<Store>();
foreach(Store store in item.Stores)
{
current.Resource.Stores.Add(store);
}
return await this.cosmosContainer.ReplaceItemAsync<Organization>(current.Resource, current.Resource.id, new PartitionKey(current.Resource.Name));
}
}
}

Просмотреть файл

@ -0,0 +1,55 @@
using Microsoft.Azure.Cosmos;
using Project.Zap.Library.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Project.Zap.Library.Services
{
public class PartnerRepository : IRepository<PartnerOrganization>
{
private readonly Container cosmosContainer;
public PartnerRepository(Database cosmosDatabase)
{
this.cosmosContainer = cosmosDatabase.CreateContainerIfNotExistsAsync("partner", "/Name").Result;
}
public async Task Add(PartnerOrganization item)
{
await this.cosmosContainer.CreateItemAsync<PartnerOrganization>(item, new PartitionKey(item.Name));
}
public async Task Delete(Expression<Func<PartnerOrganization, bool>> query)
{
IEnumerable<dynamic> results = this.cosmosContainer.GetItemLinqQueryable<PartnerOrganization>(true).Where(query).Select(x => new { id = x.id, Name = x.Name }).AsEnumerable();
foreach(dynamic result in results)
{
await this.cosmosContainer.DeleteItemAsync<PartnerOrganization>(result.id, new PartitionKey(result.Name));
}
}
public PartnerOrganization Get(string id)
{
throw new NotImplementedException();
}
public IEnumerable<PartnerOrganization> Get(Expression<Func<PartnerOrganization, bool>> query)
{
IEnumerable<PartnerOrganization> partners = this.cosmosContainer.GetItemLinqQueryable<PartnerOrganization>(true).Where(query);
return partners;
}
public Task<IEnumerable<PartnerOrganization>> Get()
{
return Task.FromResult(this.cosmosContainer.GetItemLinqQueryable<PartnerOrganization>(true).AsEnumerable());
}
public Task<PartnerOrganization> Update(PartnerOrganization item)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,74 @@
using Microsoft.Azure.Cosmos;
using Project.Zap.Library.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Project.Zap.Library.Services
{
public class ShiftRepository : IRepository<Shift>
{
private readonly Container cosmosContainer;
public ShiftRepository(Database cosmosDatabase)
{
this.cosmosContainer = cosmosDatabase.CreateContainerIfNotExistsAsync("shifts", "/StoreName").Result;
}
public async Task Add(Shift item)
{
await this.cosmosContainer.CreateItemAsync<Shift>(item, new PartitionKey(item.StoreName));
}
public async Task Delete(Expression<Func<Shift, bool>> query)
{
IEnumerable<Shift> shifts = this.cosmosContainer.GetItemLinqQueryable<Shift>(true).Where(query);
foreach (Shift item in shifts)
{
await this.cosmosContainer.DeleteItemAsync<Shift>(item.id, new PartitionKey(item.StoreName));
}
}
public Shift Get(string id)
{
throw new System.NotImplementedException();
}
public async Task<IEnumerable<Shift>> Get()
{
var query = this.cosmosContainer.GetItemQueryIterator<Shift>(new QueryDefinition("SELECT * FROM c"));
List<Shift> results = new List<Shift>();
while (query.HasMoreResults)
{
var response = await query.ReadNextAsync();
results.AddRange(response.ToList());
}
return results;
}
public IEnumerable<Shift> Get(Expression<Func<Shift, bool>> query)
{
IEnumerable<Shift> storeShifts = this.cosmosContainer.GetItemLinqQueryable<Shift>(true).Where(query);
return storeShifts;
}
public async Task<Shift> Update(Shift item)
{
Shift current = await this.cosmosContainer.ReadItemAsync<Shift>(item.id, new PartitionKey(item.StoreName));
current.EmployeeId = item.EmployeeId;
current.Allocated = item.Allocated;
current.Start = item.Start;
current.End = item.End;
current.WorkType = item.WorkType;
return await this.cosmosContainer.ReplaceItemAsync<Shift>(current, current.id, new PartitionKey(current.StoreName));
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NSubstitute" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Project.Zap\Project.Zap.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,50 @@
using Microsoft.AspNetCore.Http;
using NSubstitute;
using Project.Zap.Controllers;
using Project.Zap.Library.Models;
using Project.Zap.Library.Services;
using Project.Zap.Models;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace Project.Zap.Tests
{
public class ShiftManagementControllerTests
{
[Fact]
public async Task UploadShifts_CsvFile_AddShifts()
{
// Arrange
IRepository<Shift> shiftRepository = Substitute.For<IRepository<Shift>>();
IRepository<Organization> organizationRepository = Substitute.For<IRepository<Organization>>();
Microsoft.Graph.IGraphServiceClient graphServiceClient = Substitute.For<Microsoft.Graph.IGraphServiceClient>();
ShiftController controller = new ShiftController(shiftRepository, organizationRepository, graphServiceClient);
FileUploadViewModel viewModel = new FileUploadViewModel { StoreName = "Contoso" };
string content = "Start, End, Type\n2020-04-10T09:00,2020-04-10T17:00,Shelf Stacker\n2020-04-10T10:00,2020-04-10T18:00,Tills";
byte[] contentBytes = Encoding.UTF8.GetBytes(content);
viewModel.FormFile = new FormFile(new MemoryStream(contentBytes), 0, contentBytes.Length, null, "shifts.csv")
{
Headers = new HeaderDictionary(),
ContentType = "csv"
};
// Act
await controller.UploadShifts(viewModel);
#pragma warning disable 4014
// Assert
shiftRepository.Received(1).Add(Arg.Is<Shift>(x => x.Start == DateTime.Parse("2020-04-10T09:00")));
shiftRepository.Received(1).Add(Arg.Is<Shift>(x => x.Start == DateTime.Parse("2020-04-10T10:00")));
#pragma warning restore 4014
}
}
}

37
Project.Zap.sln Normal file
Просмотреть файл

@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29924.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Project.Zap", "Project.Zap\Project.Zap.csproj", "{5E807CCE-D22B-4181-891F-B4E0BADEF6A2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Project.Zap.Library", "Project.Zap.Library\Project.Zap.Library.csproj", "{718B2509-DBF0-47B8-A7B1-503319992F34}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project.Zap.Tests", "Project.Zap.Tests\Project.Zap.Tests.csproj", "{D6C5C72B-5AE7-43AB-8C59-62EE983ADE7C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5E807CCE-D22B-4181-891F-B4E0BADEF6A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E807CCE-D22B-4181-891F-B4E0BADEF6A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E807CCE-D22B-4181-891F-B4E0BADEF6A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E807CCE-D22B-4181-891F-B4E0BADEF6A2}.Release|Any CPU.Build.0 = Release|Any CPU
{718B2509-DBF0-47B8-A7B1-503319992F34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{718B2509-DBF0-47B8-A7B1-503319992F34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{718B2509-DBF0-47B8-A7B1-503319992F34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{718B2509-DBF0-47B8-A7B1-503319992F34}.Release|Any CPU.Build.0 = Release|Any CPU
{D6C5C72B-5AE7-43AB-8C59-62EE983ADE7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6C5C72B-5AE7-43AB-8C59-62EE983ADE7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6C5C72B-5AE7-43AB-8C59-62EE983ADE7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6C5C72B-5AE7-43AB-8C59-62EE983ADE7C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EFB07535-7BFA-4996-9B8B-49A47620B752}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Project.Zap.Controllers
{
[Authorize]
public class DataRequestController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

Просмотреть файл

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Project.Zap.Models;
namespace Project.Zap.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
[AllowAnonymous]
public IActionResult Index()
{
return View();
}
[AllowAnonymous]
public IActionResult Privacy()
{
return View();
}
[AllowAnonymous]
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

Просмотреть файл

@ -0,0 +1,121 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Project.Zap.Helpers;
using Project.Zap.Library.Models;
using Project.Zap.Library.Services;
using Project.Zap.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace Project.Zap.Controllers
{
[Authorize(Policy = "OrgAManager")]
public class OrganizationController : Controller
{
private readonly IRepository<Organization> organizationRepository;
private Organization organization;
public OrganizationController(IRepository<Organization> organizationRepository)
{
this.organizationRepository = organizationRepository;
this.organization = this.organizationRepository.Get().Result.FirstOrDefault();
}
public IActionResult Index()
{
if(this.organization == null)
{
return View("Setup");
}
return View(this.organization.Map());
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AddStore(StoreViewModel viewModel)
{
if(!ModelState.IsValid)
{
return BadRequest(ModelState);
}
Store store = viewModel.Map();
if (this.organization.Stores == null) this.organization.Stores = new List<Store>();
this.organization.Stores.Add(store);
await this.organizationRepository.Update(this.organization);
return Redirect($"/ShiftManagement/Index/{store.Name}");
}
[HttpGet]
public async Task<IActionResult> DeleteStore(string id)
{
Store store = this.organization.Stores.Where(x => x.Name == id).FirstOrDefault();
if (store == null) return View("Index", this.organization.Map());
this.organization.Stores.Remove(store);
await this.organizationRepository.Update(this.organization);
return View("Index", this.organization.Map());
}
[HttpGet]
public IActionResult EditStore(string id)
{
Store store = this.organization.Stores.Where(x => x.Name == id).FirstOrDefault();
return View(store.Map());
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> EditStore(StoreViewModel viewModel)
{
Store store = viewModel.Map();
Store oldStore = this.organization.Stores.Where(x => x.Name == store.Name).FirstOrDefault();
if (oldStore == null) return View("Index", this.organization.Map());
this.organization.Stores.Remove(oldStore);
this.organization.Stores.Add(store);
await this.organizationRepository.Update(this.organization);
return View("Index", this.organization.Map());
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Setup(OrganizationViewModel viewModel)
{
if(this.organization != null)
{
return new NotFoundResult();
}
Claim email = HttpContext.User.Claims.Where(x => x.Type == "emails").FirstOrDefault();
if (email == null)
{
throw new ArgumentException("Email claim must be present");
}
var organization = new Organization
{
Name = viewModel.Name,
StoreType = Library.Models.StoreTypes.Open,
ManagerEmails = new List<string>
{
email.Value
}
};
await this.organizationRepository.Add(organization);
return Redirect("/Home");
}
}
}

Просмотреть файл

@ -0,0 +1,81 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Project.Zap.Helpers;
using Project.Zap.Library.Models;
using Project.Zap.Library.Services;
using Project.Zap.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Project.Zap.Controllers
{
[Authorize(Policy = "OrgAManager")]
public class PartnerOrganizationController : Controller
{
private readonly Random random;
private readonly IRepository<PartnerOrganization> repository;
public PartnerOrganizationController(IRepository<PartnerOrganization> repository)
{
this.random = new Random();
this.repository = repository;
}
[HttpGet]
public async Task<IActionResult> Index()
{
IEnumerable<PartnerOrganization> partners = await this.repository.Get();
return View("Index", partners.Map());
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AddPartner(PartnerOrganizationViewModel viewModel)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
PartnerOrganization partner = viewModel.Map();
partner.RegistrationCode = this.GetCode();
await this.repository.Add(partner);
return await this.Index();
}
[HttpGet]
public async Task<IActionResult> DeletePartner(string id)
{
await this.repository.Delete(x => x.Name == id);
return await this.Index();
}
private char[] chars = new char[]
{
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'0','1','2','3','4','5','6','7','8','9',
'!','£','@','#','<','>'
};
private string GetCode()
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 6; i++)
{
int next = this.random.Next(0, this.chars.Length);
builder.Append(this.chars[next]);
}
return builder.ToString();
}
}
}

Просмотреть файл

@ -0,0 +1,231 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Project.Zap.Helpers;
using Project.Zap.Library.Models;
using Project.Zap.Library.Services;
using Project.Zap.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace Project.Zap.Controllers
{
[Authorize(Policy = "ShiftViewer")]
public class ShiftController : Controller
{
private readonly IRepository<Shift> shiftRepository;
private readonly IRepository<Organization> organizationRepository;
private readonly Microsoft.Graph.IGraphServiceClient graphServiceClient;
public ShiftController(IRepository<Shift> shiftRepository, IRepository<Organization> organizationRepository, Microsoft.Graph.IGraphServiceClient graphServiceClient)
{
this.shiftRepository = shiftRepository;
this.organizationRepository = organizationRepository;
this.graphServiceClient = graphServiceClient;
}
public async Task<IActionResult> Index()
{
IEnumerable<Shift> shifts = await this.shiftRepository.Get();
SearchShiftViewModel viewModel = new SearchShiftViewModel
{
StoreNames = await this.GetStoreNames(),
Result = shifts.Map()
};
return View("Index", viewModel);
}
private async Task<SelectList> GetStoreNames()
{
Organization org = (await this.organizationRepository.Get()).FirstOrDefault();
if (org == null)
{
throw new ArgumentException("Organization needs to be createded before adding shifts");
}
return new SelectList(org.Stores.Select(x => x.Name).Distinct().Select(x => new { Value = x, Text = x }), "Value", "Text");
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Search(SearchShiftViewModel search)
{
IEnumerable<Shift> shifts = this.shiftRepository.Get(x => x.StoreName == search.NewShift.StoreName);
SearchShiftViewModel viewModel = new SearchShiftViewModel
{
StoreNames = await this.GetStoreNames(),
Result = shifts.Where(x => x.Start.DayOfYear == search.NewShift.Start.DayOfYear).Map()
};
return View("Index", viewModel);
}
[HttpGet]
[Authorize(Policy = "OrgAManager")]
public async Task<IActionResult> Delete(ShiftViewModel viewModel)
{
await this.shiftRepository.Delete(x => x.StoreName == viewModel.StoreName && x.Start == viewModel.Start && x.End == viewModel.End);
return await this.Index();
}
[HttpGet]
[Authorize(Policy = "OrgBEmployee")]
public IActionResult ViewShifts()
{
Claim id = HttpContext.User.Claims.Where(x => x.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier").FirstOrDefault();
if (id == null)
{
throw new ArgumentException("http://schemas.microsoft.com/identity/claims/objectidentifier claim is required ");
}
IEnumerable<Shift> shifts = this.shiftRepository.Get(x => x.EmployeeId == id.Value).AsEnumerable();
if (shifts?.Any() == false)
{
ViewData["NoShifts"] = "You have no shifts booked.";
}
return View(shifts.Map());
}
[HttpGet]
[Authorize(Policy = "OrgAManager")]
public IActionResult ViewShift(ShiftViewModel viewModel)
{
Shift shift = this.shiftRepository.Get(x => x.StoreName == viewModel.StoreName && x.Start == viewModel.Start && x.End == viewModel.End).FirstOrDefault();
if (shift.EmployeeId != null)
{
var employee = graphServiceClient.Users[shift.EmployeeId].Request().GetAsync().Result;
ViewData["Employee"] = employee.GivenName + " " + employee.Surname;
}
return View(viewModel);
}
[HttpGet]
[Authorize(Policy = "OrgBEmployee")]
public async Task<IActionResult> CancelShift(ShiftViewModel viewModel)
{
Claim id = HttpContext.User.Claims.Where(x => x.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier").FirstOrDefault();
if (id == null)
{
throw new ArgumentException("http://schemas.microsoft.com/identity/claims/objectidentifier claim is required ");
}
Shift shift = this.shiftRepository.Get(x => x.StoreName == viewModel.StoreName && x.Start == viewModel.Start && x.End == viewModel.End && x.Allocated == true).FirstOrDefault();
shift.EmployeeId = null;
shift.Allocated = false;
await this.shiftRepository.Update(shift);
return await this.Index();
}
[HttpGet]
[Authorize(Policy = "OrgBEmployee")]
public async Task<IActionResult> Book(ShiftViewModel viewModel)
{
Claim id = HttpContext.User.Claims.Where(x => x.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier").FirstOrDefault();
if (id == null)
{
throw new ArgumentException("http://schemas.microsoft.com/identity/claims/objectidentifier claim is required ");
}
Shift storeShift = this.shiftRepository.Get(x => x.StoreName == viewModel.StoreName && x.Start == viewModel.Start && x.End == viewModel.End && x.Allocated == false).FirstOrDefault();
if (storeShift == null)
{
ViewData["ValidationError"] = "No available shifts at this time.";
return await this.Index();
}
storeShift.EmployeeId = id.Value;
storeShift.Allocated = true;
await this.shiftRepository.Update(storeShift);
return await this.Index();
}
[HttpGet]
[Authorize(Policy = "OrgAManager")]
public async Task<IActionResult> Add()
{
SearchShiftViewModel viewModel = new SearchShiftViewModel
{
StoreNames = await this.GetStoreNames(),
NewShift = new ShiftViewModel()
};
return View(viewModel);
}
[HttpPost]
[Authorize(Policy = "OrgAManager")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AddShift(SearchShiftViewModel viewModel)
{
List<Shift> shifts = viewModel.NewShift.Map().ToList();
shifts.ForEach(async x => await this.shiftRepository.Add(x));
return await this.Index();
}
[HttpGet]
[Authorize(Policy = "OrgAManager")]
public async Task<IActionResult> Upload()
{
return View(new FileUploadViewModel { StoreNames = await this.GetStoreNames() });
}
[HttpPost]
[Authorize(Policy = "OrgAManager")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> UploadShifts(FileUploadViewModel file)
{
bool headersProcessed = false;
using (StreamReader reader = new StreamReader(file.FormFile.OpenReadStream()))
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
if (!headersProcessed)
{
headersProcessed = true;
continue;
}
string[] parts = line.Split(",");
await this.shiftRepository.Add(new Shift
{
StoreName = file.StoreName,
Start = DateTime.Parse(parts[0]),
End = DateTime.Parse(parts[1]),
WorkType = parts[2],
Allocated = false
});
}
}
return await this.Index();
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
namespace Project.Zap.Filters
{
public class DisableFormValueModelBindingAttribute : Attribute, IResourceFilter
{
public void OnResourceExecuting(ResourceExecutingContext context)
{
var factories = context.ValueProviderFactories;
factories.RemoveType<FormValueProviderFactory>();
factories.RemoveType<FormFileValueProviderFactory>();
factories.RemoveType<JQueryFormValueProviderFactory>();
}
public void OnResourceExecuted(ResourceExecutedContext context)
{
}
}
}

Просмотреть файл

@ -0,0 +1,40 @@
using Project.Zap.Library.Models;
using Project.Zap.Models;
using System.Collections.Generic;
using System.Linq;
namespace Project.Zap.Helpers
{
public static class OrganizationModelHelper
{
public static OrganizationViewModel Map(this Organization organization)
{
var viewModel = new OrganizationViewModel
{
Name = organization.Name,
Stores = new List<StoreViewModel>()
};
if (organization.Stores == null || !organization.Stores.Any())
{
return viewModel;
}
foreach (Store store in organization.Stores)
{
viewModel.Stores.Add(new StoreViewModel
{
Name = store.Name,
Address = new AddressViewModel
{
City = store.Address.City,
ZipOrPostCode = store.Address.ZipOrPostCode
}
});
}
return viewModel;
}
}
}

Просмотреть файл

@ -0,0 +1,35 @@
using Project.Zap.Library.Models;
using Project.Zap.Models;
using System.Collections.Generic;
namespace Project.Zap.Helpers
{
public static class PartnerHelper
{
public static PartnerOrganization Map(this PartnerOrganizationViewModel viewModel)
{
return new PartnerOrganization { Name = viewModel?.Name };
}
public static IEnumerable<PartnerOrganizationViewModel> Map(this IEnumerable<PartnerOrganization> partners)
{
List<PartnerOrganizationViewModel> viewModels = new List<PartnerOrganizationViewModel>();
foreach(var partner in partners)
{
viewModels.Add(Map(partner));
}
return viewModels;
}
public static PartnerOrganizationViewModel Map (this PartnerOrganization partner)
{
return new PartnerOrganizationViewModel
{
Name = partner?.Name,
RegistrationCode = partner?.RegistrationCode
};
}
}
}

Просмотреть файл

@ -0,0 +1,57 @@
using Microsoft.AspNetCore.Mvc.Rendering;
using Project.Zap.Library.Models;
using Project.Zap.Models;
using System.Collections.Generic;
using System.Linq;
namespace Project.Zap.Helpers
{
public static class ShiftModelHelper
{
public static IEnumerable<ShiftViewModel> Map(this IEnumerable<Shift> shifts)
{
var viewModels = new List<ShiftViewModel>();
var grouped = shifts.GroupBy(x => new { Start = x.Start, End = x.End, WorkType = x.WorkType });
foreach(var shift in grouped)
{
ShiftViewModel viewModel = Map(shift.First());
viewModel.Quantity = shift.Count();
viewModel.Available = shift.Count(x => !x.Allocated);
viewModels.Add(viewModel);
}
return viewModels;
}
private static ShiftViewModel Map(Shift shift)
{
return new ShiftViewModel
{
StoreName = shift.StoreName,
Start = shift.Start,
End = shift.End,
WorkType = shift.WorkType,
};
}
public static IEnumerable<Shift> Map(this ShiftViewModel viewModel)
{
IList<Shift> shifts = new List<Shift>();
int allocated = viewModel.Quantity - viewModel.Available;
for(int i = 0; i < viewModel.Quantity; i++)
{
shifts.Add(new Shift
{
StoreName = viewModel.StoreName,
Start = viewModel.Start,
End = viewModel.End,
WorkType = viewModel.WorkType
});
}
return shifts;
}
}
}

Просмотреть файл

@ -0,0 +1,34 @@
using Project.Zap.Library.Models;
using Project.Zap.Models;
namespace Project.Zap.Helpers
{
public static class StoreModelHelper
{
public static Store Map(this StoreViewModel viewModel)
{
return new Store
{
Name = viewModel.Name,
Address = new Address
{
City = viewModel?.Address?.City,
ZipOrPostCode = viewModel?.Address?.ZipOrPostCode
}
};
}
public static StoreViewModel Map(this Store store)
{
return new StoreViewModel
{
Name = store.Name,
Address = new AddressViewModel
{
City = store?.Address?.City,
ZipOrPostCode = store?.Address?.ZipOrPostCode
}
};
}
}
}

Просмотреть файл

@ -0,0 +1,109 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Graph;
using Project.Zap.Library.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Project.Zap.Library.Services;
using System.Threading;
using System.Threading.Tasks;
namespace Project.Zap.Middleware
{
public static class UserSetupExtensions
{
public static IApplicationBuilder UseUserRegistration(this IApplicationBuilder app, string managerCode, string extensionId)
{
app.Use(async (context, next) =>
{
if (context.User.HasClaim(c => c.Type == "newUser" && c.Value == "true" && !context.User.HasClaim(c => c.Type == "extension_zaprole")))
{
IGraphServiceClient graphClient = app.ApplicationServices.GetService<IGraphServiceClient>();
Claim id = context.User.Claims.Where(x => x.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier").FirstOrDefault();
if (id == null)
{
throw new ArgumentException("http://schemas.microsoft.com/identity/claims/objectidentifier claim is required on new user signin");
}
Claim registrationCode = context.User.Claims.Where(x => x.Type == "extension_RegistrationCode").FirstOrDefault();
if (registrationCode == null)
{
await graphClient.Users[id.Value].Request().DeleteAsync();
throw new ArgumentException("Registration Code is required on new user signin");
}
if(managerCode == registrationCode.Value)
{
context.User = await UpdateUserRole(context.User, "org_a_manager", id.Value, extensionId, graphClient);
}
else
{
IRepository<PartnerOrganization> partnerRepository = app.ApplicationServices.GetService<IRepository<PartnerOrganization>>();
PartnerOrganization partner = partnerRepository.Get(x => x.RegistrationCode == registrationCode.Value).FirstOrDefault();
if (partner == null)
{
await graphClient.Users[id.Value].Request().DeleteAsync();
throw new ArgumentException("No Partner organization found");
}
IRepository<Employee> employeeRepository = app.ApplicationServices.GetService<IRepository<Employee>>();
Employee employee = employeeRepository.Get(x => x.EmployeeId == id.Value).FirstOrDefault();
if (employee == null)
{
await employeeRepository.Add(new Employee { EmployeeId = id.Value, PartnerOrgId = partner.id });
}
context.User = await UpdateUserRole(context.User, "org_b_employee", id.Value, extensionId, graphClient);
}
}
await next.Invoke();
});
return app;
}
private static async Task<ClaimsPrincipal> UpdateUserRole(ClaimsPrincipal user, string role, string id, string extensionId, IGraphServiceClient graphClient)
{
var claims = user.Claims.Append(new Claim("extension_zaprole", role));
ClaimsPrincipal principal = new ClaimsPrincipal(new ClaimsIdentity(user.Identity, claims));
Thread.CurrentPrincipal = principal;
IDictionary<string, object> extensions = new Dictionary<string, object>();
extensions.Add($"extension_{extensionId}_zaprole", role);
var adUser = new Microsoft.Graph.User
{
AdditionalData = extensions
};
int retries = 0;
async Task updateUser(string userId)
{
try
{
await graphClient.Users[userId].Request().UpdateAsync(adUser);
}
catch(Exception exception)
{
await Task.Delay(1000);
retries++;
if (retries > 2) throw exception;
await updateUser(id);
}
}
await updateUser(id);
return principal;
}
}
}

Просмотреть файл

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace Project.Zap.Models
{
public class AddressViewModel
{
[BindProperty]
[Required, StringLength(30)]
public string City { get; set; }
[BindProperty]
[Required, StringLength(8)]
public string ZipOrPostCode { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,11 @@
using System;
namespace Project.Zap.Models
{
public class ErrorViewModel
{
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

Просмотреть файл

@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace Project.Zap.Models
{
public class FileUploadViewModel
{
[BindProperty]
public string StoreName { get; set; }
public SelectList StoreNames { get; set; }
[BindProperty]
public IFormFile FormFile { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Project.Zap.Models
{
public class OrganizationViewModel
{
[JsonPropertyName("id")]
public string id { get; set; } = Guid.NewGuid().ToString();
[BindProperty]
[Required, StringLength(30)]
public string Name { get; set; }
public StoreTypes StoreType { get; set; }
public List<StoreViewModel> Stores { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace Project.Zap.Models
{
public class PartnerOrganizationViewModel
{
[BindProperty]
[Required, StringLength(30, MinimumLength = 5)]
public string Name { get; set; }
[BindProperty]
public string RegistrationCode { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,47 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Project.Zap.Models
{
public class SearchShiftViewModel
{
public SelectList StoreNames { get; set; }
public ShiftViewModel NewShift { get; set; }
public IEnumerable<ShiftViewModel> Result { get; set; }
}
public class ShiftViewModel
{
[BindProperty]
[Required]
public string StoreName { get; set; }
[BindProperty]
[Required]
[DisplayFormat(DataFormatString = "{yyyy-MM-ddTHH:mm}")]
public DateTime Start { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
[BindProperty]
[Required]
[DisplayFormat(DataFormatString = "{yyyy-MM-ddTHH:mm}")]
public DateTime End { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
[BindProperty]
[Required]
public string WorkType { get; set; }
[BindProperty]
[Required]
public int Quantity { get; set; }
[BindProperty]
[Required]
public int Available { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,8 @@
namespace Project.Zap.Models
{
public enum StoreTypes
{
Open,
Closed
}
}

Просмотреть файл

@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System.ComponentModel.DataAnnotations;
namespace Project.Zap.Models
{
[BindRequired]
public class StoreViewModel
{
[BindProperty]
[Required, StringLength(30, MinimumLength = 5)]
public string Name { get; set; }
[BindProperty]
[Required]
public AddressViewModel Address { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace Project.Zap.Models
{
public class UserViewModel
{
[BindProperty]
[Required, StringLength(30)]
public string DisplayName { get; set; }
[BindProperty]
[Required, EmailAddress]
public string Email { get; set; }
}
}

20
Project.Zap/Program.cs Normal file
Просмотреть файл

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace Project.Zap
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

Просмотреть файл

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>aspnet-Project.Zap-857F001C-6B87-45F8-B26D-95D46C83C6C4</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureADB2C.UI" Version="3.1.2" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.7.0" />
<PackageReference Include="Microsoft.Graph" Version="3.0.1" />
<PackageReference Include="Microsoft.Graph.Auth" Version="1.0.0-preview.4" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.10.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Project.Zap.Library\Project.Zap.Library.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57230",
"sslPort": 44393
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Project.Zap": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

120
Project.Zap/Startup.cs Normal file
Просмотреть файл

@ -0,0 +1,120 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.AzureADB2C.UI;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.Cosmos;
using Microsoft.Azure.Cosmos.Fluent;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Graph;
using Microsoft.Graph.Auth;
using Microsoft.Identity.Client;
using Project.Zap.Library.Models;
using Project.Zap.Library.Services;
using Project.Zap.Middleware;
using System.Threading.Tasks;
namespace Project.Zap
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential
// cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
// requires using Microsoft.AspNetCore.Http;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddAuthentication(AzureADB2CDefaults.AuthenticationScheme)
.AddAzureADB2C(options => Configuration.Bind("AzureAdB2C", options));
services.AddAuthorization(options =>
{
options.AddPolicy("OrgAManager", policy =>
policy.RequireAssertion(context =>
context.User.HasClaim(c => c.Type == "extension_zaprole" && c.Value == "org_a_manager")));
options.AddPolicy("OrgBEmployee", policy =>
policy.RequireAssertion(context =>
context.User.HasClaim(c => c.Type == "extension_zaprole" && c.Value == "org_b_employee")));
options.AddPolicy("ShiftViewer", policy =>
policy.RequireAssertion(context =>
context.User.HasClaim(c => c.Type == "extension_zaprole" && c.Value == "org_a_manager" || c.Type == "extension_zaprole" && c.Value == "org_b_employee")));
});
services.AddControllers();
services.AddRazorPages();
services.AddTransient<Database>(x => this.GetCosmosDatabase().Result);
services.AddSingleton<IRepository<Library.Models.Organization>, OrganizationRepository>();
services.AddSingleton<IRepository<Library.Models.Shift>, ShiftRepository>();
services.AddSingleton<IRepository<PartnerOrganization>, PartnerRepository>();
services.AddSingleton<IRepository<Employee>, EmployeeRepository>();
services.AddTransient<IConfidentialClientApplication>(x => ConfidentialClientApplicationBuilder
.Create(this.Configuration["ClientId"])
.WithTenantId(this.Configuration["TenantId"])
.WithClientSecret(this.Configuration["ClientSecret"])
.Build());
services.AddTransient<IAuthenticationProvider, ClientCredentialProvider>();
services.AddSingleton<IGraphServiceClient, GraphServiceClient>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseUserRegistration(this.Configuration["ManagerCode"], this.Configuration["ExtensionId"]);
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
}
private async Task<Database> GetCosmosDatabase()
{
string endpoint = this.Configuration["CosmosEndpoint"];
string key = this.Configuration["CosmosKey"];
CosmosClient client = new CosmosClientBuilder(endpoint, key).Build();
return await client.CreateDatabaseIfNotExistsAsync("zap");
}
}
}

Просмотреть файл

@ -0,0 +1,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

Просмотреть файл

@ -0,0 +1,12 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Project ZAP</h1>
<h2>The emergency shift management system</h2>
<p>
To get started Sign up using "123456" as the Registration Code to become a new Manager at Contoso!
</p>
</div>

Просмотреть файл

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

Просмотреть файл

@ -0,0 +1,22 @@
@model Project.Zap.Models.StoreViewModel
<form asp-controller="Organization" asp-action="AddStore" method="Post">
<div class="form-group">
<label asp-for="@Model.Name"></label>
<input type="text" asp-for="@Model.Name" class="form-control" />
<span asp-validation-for="@Model.Name"></span>
</div>
<h5>Address</h5>
<div class="form-group">
<label asp-for="@Model.Address.City"></label>
<input type="text" asp-for="@Model.Address.City" class="form-control" />
<span asp-validation-for="@Model.Address.City"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Address.ZipOrPostCode"></label>
<input type="text" asp-for="@Model.Address.ZipOrPostCode" class="form-control" />
<span asp-validation-for="@Model.Address.ZipOrPostCode"></span>
</div>
<button type="submit" class="btn btn-primary mb-2">Add</button>
</form>

Просмотреть файл

@ -0,0 +1,24 @@
@model Project.Zap.Models.StoreViewModel
<h3>Edit Store</h3>
<form asp-controller="Organization" asp-action="EditStore" method="Post">
<div class="form-group">
<label asp-for="@Model.Name"></label>
<input type="text" asp-for="@Model.Name" class="form-control" />
<span asp-validation-for="@Model.Name"></span>
</div>
<h5>Address</h5>
<div class="form-group">
<label asp-for="@Model.Address.City"></label>
<input type="text" asp-for="@Model.Address.City" class="form-control" />
<span asp-validation-for="@Model.Address.City"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Address.ZipOrPostCode"></label>
<input type="text" asp-for="@Model.Address.ZipOrPostCode" class="form-control" />
<span asp-validation-for="@Model.Address.ZipOrPostCode"></span>
</div>
<button type="submit" class="btn btn-primary mb-2">Update</button>
</form>

Просмотреть файл

@ -0,0 +1,50 @@
@model Project.Zap.Models.OrganizationViewModel
<div id="accordion">
<div class="card">
<div class="card-header" id="storeHeader">
<h3>
<button class="btn" data-toggle="collapse" data-target="#stores" aria-expanded="true" aria-controls="stores">Stores</button>
</h3>
</div>
<div id="stores" class="collapse show" data-parent="#accordion" aria-labelledby="storeHeader">
<div class="card-body">
<table class="table">
<tr>
<th>Name</th>
<th>City</th>
<th>Zip or PostCode</th>
<th>Edit</th>
<th>Delete</th>
</tr>
@foreach (var store in Model.Stores)
{
<tr>
<td>@store.Name</td>
<td>@store.Address.City</td>
<td>@store.Address.ZipOrPostCode</td>
<th><a asp-controller="Organization" asp-action="EditStore" asp-route-id="@store.Name">Edit</a></th>
<th><a asp-controller="Organization" asp-action="DeleteStore" asp-route-id="@store.Name">Delete</a></th>
</tr>
}
</table>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="newStoreHeader">
<h3>
<button class="btn" data-toggle="collapse" data-target="#newStore" aria-expanded="false" aria-controls="newStore">New Store</button>
</h3>
</div>
<div id="newStore" class="collapse" data-parent="#accordion" aria-labelledby="newStoreHeader">
<div class="card-body">
<partial name="AddStore" model="new Project.Zap.Models.StoreViewModel()" />
</div>
</div>
</div>
</div>

Просмотреть файл

@ -0,0 +1,16 @@
@model Project.Zap.Models.OrganizationViewModel
<div class="text-center">
<h1 class="display-4">Setup Organization</h1>
<h3>First time setup</h3>
<form asp-controller="Organization" asp-action="Setup" method="post">
<div class="form-group">
<label asp-for="@Model.Name"></label>
<input type="text" asp-for="@Model.Name" class="form-control" />
<span asp-validation-for="@Model.Name"></span>
</div>
<button type="submit" class="btn btn-primary mb-2">Add</button>
</form>
</div>

Просмотреть файл

@ -0,0 +1,11 @@
@model Project.Zap.Models.PartnerOrganizationViewModel
<h3>New Partner Org</h3>
<form asp-controller="PartnerOrganization" asp-action="AddPartner" method="Post">
<div class="form-group">
<label asp-for="@Model.Name"></label>
<input type="text" asp-for="@Model.Name" class="form-control" />
<span asp-validation-for="@Model.Name"></span>
</div>
<button type="submit" class="btn btn-primary mb-2">Add</button>
</form>

Просмотреть файл

@ -0,0 +1,49 @@
@model IEnumerable<Project.Zap.Models.PartnerOrganizationViewModel>
<div id="accordion">
<div class="card">
<div class="card-header" id="partnerHeader">
<h3>
<button class="btn" data-toggle="collapse" data-target="#partners" aria-expanded="true" aria-controls="partners">Partners</button>
</h3>
</div>
<div id="partners" class="collapse show" data-parent="#accordion" aria-labelledby="partnerHeader">
<div class="card-body">
<table class="table">
<tr>
<th>Name</th>
<th>Registration Code</th>
<th>Delete</th>
</tr>
@if (Model != null && Model.Any())
{
@foreach (var org in Model)
{
<tr>
<td>@org.Name</td>
<td>@org.RegistrationCode</td>
<th><a asp-controller="PartnerOrganization" asp-action="DeletePartner" asp-route-id="@org.Name">Delete</a></th>
</tr>
}
}
</table>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="newPartnerHeader">
<h3>
<button class="btn" data-toggle="collapse" data-target="#newPartner" aria-expanded="false" aria-controls="newPartner">New Partner</button>
</h3>
</div>
<div id="newPartner" class="collapse" data-parent="#accordion" aria-labelledby="newPartnerHeader">
<div class="card-body">
<partial name="AddPartner" model="new Project.Zap.Models.PartnerOrganizationViewModel()" />
</div>
</div>
</div>
</div>

Просмотреть файл

@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

Просмотреть файл

@ -0,0 +1,25 @@
@using Microsoft.AspNetCore.Http.Features
@{
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
var showBanner = !consentFeature?.CanTrack ?? false;
var cookieString = consentFeature?.CreateConsentCookie();
}
@if (showBanner)
{
<div id="cookieConsent" class="alert alert-info alert-dismissible fade show" role="alert">
Use this space to summarize your privacy and cookie use policy. <a asp-page="/Privacy">Learn More</a>.
<button type="button" class="accept-policy close" data-dismiss="alert" aria-label="Close" data-cookie-string="@cookieString">
<span aria-hidden="true">Accept</span>
</button>
</div>
<script>
(function () {
var button = document.querySelector("#cookieConsent button[data-cookie-string]");
button.addEventListener("click", function (event) {
document.cookie = button.dataset.cookieString;
}, false);
})();
</script>
}

Просмотреть файл

@ -0,0 +1,97 @@
@{
@using Microsoft.AspNetCore.Authorization
@inject IAuthorizationService AuthorizationService
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Contoso</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Contoso</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<partial name="_LoginPartial" />
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
@if ((await AuthorizationService.AuthorizeAsync(User, "OrgAManager")).Succeeded)
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Organization" asp-action="Index">Manage Organization</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="PartnerOrganization" asp-action="Index">Partner Organizations</a>
</li>
}
@if (User.Identity.IsAuthenticated)
{
<li class="dropdown">
<a class="dropdown-toggle nav-link text-dark" data-toggle="dropdown" href="#">Shifts<b class="caret"></b></a>
<ul class="dropdown-menu">
@if ((await AuthorizationService.AuthorizeAsync(User, "OrgAManager")).Succeeded)
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Shift" asp-action="Index">Search</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Shift" asp-action="Add">Add</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Shift" asp-action="Upload">Upload</a>
</li>
}
@if ((await AuthorizationService.AuthorizeAsync(User, "OrgBEmployee")).Succeeded)
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Shift" asp-action="ViewShifts">My Shifts</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Shift" asp-action="Index">Book Shifts</a>
</li>
}
</ul>
</li>
}
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2020 - Project.Zap - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
@if (User.Identity.IsAuthenticated)
{
<span> - </span><a asp-controller="DataRequest" asp-action="Index">Data Request</a>
}
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@RenderSection("Scripts", required: false)
</body>
</html>

Просмотреть файл

@ -0,0 +1,38 @@
@using System.Security.Principal
@using Microsoft.AspNetCore.Authentication.AzureADB2C.UI
@using Microsoft.Extensions.Options
@inject IOptionsMonitor<AzureADB2COptions> AzureADB2COptions
@{
var options = AzureADB2COptions.Get(AzureADB2CDefaults.AuthenticationScheme);
}
<ul class="navbar-nav">
@if (User.Identity.IsAuthenticated)
{
@if (!string.IsNullOrEmpty(options.EditProfilePolicyId))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureADB2C" asp-controller="Account" asp-action="EditProfile">
<span class="text-dark">Hello @User.Identity.Name!</span>
</a>
</li>
}
else
{
<li class="nav-item">
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
</li>
}
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureADB2C" asp-controller="Account" asp-action="SignOut">Sign out</a>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureADB2C" asp-controller="Account" asp-action="SignIn">Sign in</a>
</li>
}
</ul>

Просмотреть файл

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

Просмотреть файл

@ -0,0 +1,35 @@
@model Project.Zap.Models.SearchShiftViewModel
<h3>Add Shift</h3>
<form asp-controller="Shift" asp-action="AddShift" method="Post">
<div class="form-group">
<label asp-for="@Model.NewShift.StoreName"></label>
<select asp-for="@Model.NewShift.StoreName" asp-items="@Model.StoreNames">
<option>Select Store</option>
</select>
<span asp-validation-for="@Model.NewShift.StoreName"></span>
</div>
<div class="form-group">
<label asp-for="@Model.NewShift.Start"></label>
<input type="datetime-local" asp-for="@Model.NewShift.Start" class="form-control" />
<span asp-validation-for="@Model.NewShift.Start"></span>
</div>
<div class="form-group">
<label asp-for="@Model.NewShift.End"></label>
<input type="datetime-local" asp-for="@Model.NewShift.End" class="form-control" />
<span asp-validation-for="@Model.NewShift.End"></span>
</div>
<div class="form-group">
<label asp-for="@Model.NewShift.Quantity"></label>
<input type="text" asp-for="@Model.NewShift.Quantity" class="form-control" />
<span asp-validation-for="@Model.NewShift.Quantity"></span>
</div>
<div class="form-group">
<label asp-for="@Model.NewShift.WorkType"></label>
<input type="text" asp-for="@Model.NewShift.WorkType" class="form-control" />
<span asp-validation-for="@Model.NewShift.WorkType"></span>
</div>
<input type="hidden" asp-for="@Model.NewShift.Available" />
<button type="submit" class="btn btn-primary mb-2">Add</button>
</form>

Просмотреть файл

@ -0,0 +1,75 @@
@{
@using Microsoft.AspNetCore.Authorization
@inject IAuthorizationService AuthorizationService
}
@model Project.Zap.Models.SearchShiftViewModel
<h1>Book a Shift</h1>
@if (ViewData.ContainsKey("ValidationError"))
{
<div class="alert alert-danger">
<strong>Error</strong> @ViewData["ValidationError"]
</div>
}
@if (ViewData.ContainsKey("SuccessMessage"))
{
<div class="alert alert-success">
<strong>Success</strong> @ViewData["SuccessMessage"]
</div>
}
<partial name="Search" model="new Project.Zap.Models.SearchShiftViewModel { StoreNames = Model.StoreNames, NewShift = new Project.Zap.Models.ShiftViewModel() }" />
<h3>Results</h3>
<table class="table">
<thead>
<tr>
<th>Store</th>
<th>Start Time</th>
<th>End Time</th>
<th>Work Type</th>
<th>Quantity</th>
<th>Available</th>
@if ((await AuthorizationService.AuthorizeAsync(User, "OrgAManager")).Succeeded)
{
<th>View</th>
<th>Delete</th>
}
@if ((await AuthorizationService.AuthorizeAsync(User, "OrgBEmployee")).Succeeded)
{
<th>Book</th>
}
</tr>
</thead>
<tbody>
@foreach (var shift in Model.Result)
{
<tr>
<td>@shift.StoreName</td>
<td>@shift.Start</td>
<td>@shift.End</td>
<td>@shift.WorkType</td>
<td>@shift.Quantity</td>
<td>@shift.Available</td>
@if ((await AuthorizationService.AuthorizeAsync(User, "OrgAManager")).Succeeded)
{
<td><a asp-controller="Shift" asp-action="ViewShift" asp-route-StoreName="@shift.StoreName" asp-route-Start="@shift.Start.ToString("yyyy-MM-ddTHH:mm")" asp-route-End="@shift.End.ToString("yyyy-MM-ddTHH:mm")" asp-route-WorkType="@shift.WorkType">View</a></td>
<td><a asp-controller="Shift" asp-action="Delete" asp-route-StoreName="@shift.StoreName" asp-route-Start="@shift.Start.ToString("yyyy-MM-ddTHH:mm")" asp-route-End="@shift.End.ToString("yyyy-MM-ddTHH:mm")" asp-route-WorkType="@shift.WorkType">Delete</a></td>
}
@if ((await AuthorizationService.AuthorizeAsync(User, "OrgBEmployee")).Succeeded)
{
<td>
<a asp-controller="Shift" asp-action="Book" asp-route-StoreName="@shift.StoreName" asp-route-Start="@shift.Start.ToString("yyyy-MM-ddTHH:mm")" asp-route-End="@shift.End.ToString("yyyy-MM-ddTHH:mm")" asp-route-WorkType="@shift.WorkType">Book</a>
</td>
}
</tr>
}
</tbody>
</table>

Просмотреть файл

@ -0,0 +1,18 @@
@model Project.Zap.Models.SearchShiftViewModel
<form asp-controller="Shift" asp-action="Search" method="post">
<div class="form-group">
<label asp-for="@Model.NewShift.StoreName"></label>
<select asp-for="@Model.NewShift.StoreName" asp-items="@Model.StoreNames">
<option value="">Select Store</option>
</select>
<span asp-validation-for="@Model.NewShift.StoreName"></span>
</div>
<div class="form-group">
<label asp-for="@Model.NewShift.Start"></label>
<input type="datetime-local" asp-for="@Model.NewShift.Start" />
</div>
<span asp-validation-for="@Model.NewShift.Start"></span>
<button type="submit" class="btn btn-primary mb-2">Search</button>
</form>

Просмотреть файл

@ -0,0 +1,21 @@
@model Project.Zap.Models.FileUploadViewModel
<h3>Upload shifts</h3>
<form enctype="multipart/form-data" method="post" asp-controller="Shift" asp-action="UploadShifts">
<div class="form-group">
<label asp-for="@Model.StoreName"></label>
<select asp-for="@Model.StoreName" asp-items="@Model.StoreNames">
<option>Select Store</option>
</select>
<span asp-validation-for="@Model.StoreName"></span>
</div>
<div class="form-group">
<label asp-for="@Model.FormFile"></label>
<input asp-for="@Model.FormFile" type="file">
<span asp-validation-for="@Model.FormFile"></span>
</div>
<div class="form-group">
<input class="btn btn-primary mb-2" type="submit" value="Upload" />
</div>
</form>

Просмотреть файл

@ -0,0 +1,25 @@
@model Project.Zap.Models.ShiftViewModel
<h1>Shift details</h1>
<table class="table">
<thead>
<tr>
<th>Store Name</th>
<th>Start Time</th>
<th>End Time</th>
<th>Work Type</th>
<th>Employee</th>
</tr>
</thead>
<tbody>
<tr>
<td>@Model.StoreName</td>
<td>@Model.Start</td>
<td>@Model.End</td>
<td>@Model.WorkType</td>
<td>@ViewData["Employee"]</td>
</tr>
</tbody>
</table>

Просмотреть файл

@ -0,0 +1,43 @@
@model IEnumerable<Project.Zap.Models.ShiftViewModel>
@{
ViewData["Title"] = "Upcoming shifts";
}
<h1>Upcoming shifts</h1>
@if (ViewData.ContainsKey("NoShifts"))
{
<div class="alert alert-info">
<strong>No shifts.</strong> @ViewData["NoShifts"]
</div>
}
<table class="table">
<thead>
<tr>
<th>Store Name</th>
<th>Start Time</th>
<th>End Time</th>
<th>Work Type</th>
<th>Cancel</th>
</tr>
</thead>
<tbody>
@foreach (var shift in Model)
{
<tr>
<td>@shift.StoreName</td>
<td>@shift.Start</td>
<td>@shift.End</td>
<td>@shift.WorkType</td>
<td>
<a asp-controller="Shift" asp-action="CancelShift" asp-route-StoreName="@shift.StoreName" asp-route-Start="@shift.Start.ToString("yyyy-MM-ddTHH:mm")" asp-route-End="@shift.End.ToString("yyyy-MM-ddTHH:mm")">Cancel</a>
</td>
</tr>
}
</tbody>
</table>

Просмотреть файл

@ -0,0 +1,3 @@
@using Project.Zap
@using Project.Zap.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Просмотреть файл

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

Просмотреть файл

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

Просмотреть файл

@ -0,0 +1,99 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
/* Provide sufficient contrast against white background */
a {
color: #0366d6;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
/* Sticky footer styles
-------------------------------------------------- */
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px; /* Vertically center the text there */
}
.ui-datepicker-header {
background: #3399ff;
color: #ffffff;
border-width: 1px 0 0 0;
border-style: solid;
border-color: #111;
}
.Highlighted a {
background-color: Green !important;
background-image: none !important;
color: White !important;
font-weight: bold !important;
font-size: 12pt;
}
td.highlight {
border: none !important;
padding: 1px 0 1px 1px !important;
background: none !important;
overflow: hidden;
}
td.highlight a {
background: #ad3f29 url(bg.png) 50% 50% repeat-x !important;
border: 1px #88a276 solid !important;
}

Двоичные данные
Project.Zap/wwwroot/favicon.ico Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 31 KiB

Просмотреть файл

@ -0,0 +1,4 @@
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.

Просмотреть файл

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2011-2018 Twitter, Inc.
Copyright (c) 2011-2018 The Bootstrap Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

3719
Project.Zap/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

331
Project.Zap/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css поставляемый Normal file
Просмотреть файл

@ -0,0 +1,331 @@
/*!
* Bootstrap Reboot v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
display: block;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex="-1"]:focus {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: .5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]):not([tabindex]) {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):focus {
outline: 0;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
}
figure {
margin: 0 0 1rem;
}
img {
vertical-align: middle;
border-style: none;
}
svg {
overflow: hidden;
vertical-align: middle;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
}
label {
display: inline-block;
margin-bottom: 0.5rem;
}
button {
border-radius: 0;
}
button:focus {
outline: 1px dotted;
outline: 5px auto -webkit-focus-ring-color;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
select {
word-wrap: normal;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button:not(:disabled),
[type="button"]:not(:disabled),
[type="reset"]:not(:disabled),
[type="submit"]:not(:disabled) {
cursor: pointer;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type="radio"],
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
-webkit-appearance: listbox;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: .5rem;
font-size: 1.5rem;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,8 @@
/*!
* Bootstrap Reboot v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

10038
Project.Zap/wwwroot/lib/bootstrap/dist/css/bootstrap.css поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1
Project.Zap/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

7
Project.Zap/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

7013
Project.Zap/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

4435
Project.Zap/wwwroot/lib/bootstrap/dist/js/bootstrap.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1
Project.Zap/wwwroot/lib/bootstrap/dist/js/bootstrap.js.map поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

7
Project.Zap/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,12 @@
Copyright (c) .NET Foundation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
these files except in compliance with the License. You may obtain a copy of the
License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

Просмотреть файл

@ -0,0 +1,432 @@
// Unobtrusive validation support library for jQuery and jQuery Validate
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// @version v3.2.11
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */
/*global document: false, jQuery: false */
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define("jquery.validate.unobtrusive", ['jquery-validation'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports
module.exports = factory(require('jquery-validation'));
} else {
// Browser global
jQuery.validator.unobtrusive = factory(jQuery);
}
}(function ($) {
var $jQval = $.validator,
adapters,
data_validation = "unobtrusiveValidation";
function setValidationValues(options, ruleName, value) {
options.rules[ruleName] = value;
if (options.message) {
options.messages[ruleName] = options.message;
}
}
function splitAndTrim(value) {
return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g);
}
function escapeAttributeValue(value) {
// As mentioned on http://api.jquery.com/category/selectors/
return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1");
}
function getModelPrefix(fieldName) {
return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
}
function appendModelPrefix(value, prefix) {
if (value.indexOf("*.") === 0) {
value = value.replace("*.", prefix);
}
return value;
}
function onError(error, inputElement) { // 'this' is the form element
var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"),
replaceAttrValue = container.attr("data-valmsg-replace"),
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null;
container.removeClass("field-validation-valid").addClass("field-validation-error");
error.data("unobtrusiveContainer", container);
if (replace) {
container.empty();
error.removeClass("input-validation-error").appendTo(container);
}
else {
error.hide();
}
}
function onErrors(event, validator) { // 'this' is the form element
var container = $(this).find("[data-valmsg-summary=true]"),
list = container.find("ul");
if (list && list.length && validator.errorList.length) {
list.empty();
container.addClass("validation-summary-errors").removeClass("validation-summary-valid");
$.each(validator.errorList, function () {
$("<li />").html(this.message).appendTo(list);
});
}
}
function onSuccess(error) { // 'this' is the form element
var container = error.data("unobtrusiveContainer");
if (container) {
var replaceAttrValue = container.attr("data-valmsg-replace"),
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null;
container.addClass("field-validation-valid").removeClass("field-validation-error");
error.removeData("unobtrusiveContainer");
if (replace) {
container.empty();
}
}
}
function onReset(event) { // 'this' is the form element
var $form = $(this),
key = '__jquery_unobtrusive_validation_form_reset';
if ($form.data(key)) {
return;
}
// Set a flag that indicates we're currently resetting the form.
$form.data(key, true);
try {
$form.data("validator").resetForm();
} finally {
$form.removeData(key);
}
$form.find(".validation-summary-errors")
.addClass("validation-summary-valid")
.removeClass("validation-summary-errors");
$form.find(".field-validation-error")
.addClass("field-validation-valid")
.removeClass("field-validation-error")
.removeData("unobtrusiveContainer")
.find(">*") // If we were using valmsg-replace, get the underlying error
.removeData("unobtrusiveContainer");
}
function validationInfo(form) {
var $form = $(form),
result = $form.data(data_validation),
onResetProxy = $.proxy(onReset, form),
defaultOptions = $jQval.unobtrusive.options || {},
execInContext = function (name, args) {
var func = defaultOptions[name];
func && $.isFunction(func) && func.apply(form, args);
};
if (!result) {
result = {
options: { // options structure passed to jQuery Validate's validate() method
errorClass: defaultOptions.errorClass || "input-validation-error",
errorElement: defaultOptions.errorElement || "span",
errorPlacement: function () {
onError.apply(form, arguments);
execInContext("errorPlacement", arguments);
},
invalidHandler: function () {
onErrors.apply(form, arguments);
execInContext("invalidHandler", arguments);
},
messages: {},
rules: {},
success: function () {
onSuccess.apply(form, arguments);
execInContext("success", arguments);
}
},
attachValidation: function () {
$form
.off("reset." + data_validation, onResetProxy)
.on("reset." + data_validation, onResetProxy)
.validate(this.options);
},
validate: function () { // a validation function that is called by unobtrusive Ajax
$form.validate();
return $form.valid();
}
};
$form.data(data_validation, result);
}
return result;
}
$jQval.unobtrusive = {
adapters: [],
parseElement: function (element, skipAttach) {
/// <summary>
/// Parses a single HTML element for unobtrusive validation attributes.
/// </summary>
/// <param name="element" domElement="true">The HTML element to be parsed.</param>
/// <param name="skipAttach" type="Boolean">[Optional] true to skip attaching the
/// validation to the form. If parsing just this single element, you should specify true.
/// If parsing several elements, you should specify false, and manually attach the validation
/// to the form when you are finished. The default is false.</param>
var $element = $(element),
form = $element.parents("form")[0],
valInfo, rules, messages;
if (!form) { // Cannot do client-side validation without a form
return;
}
valInfo = validationInfo(form);
valInfo.options.rules[element.name] = rules = {};
valInfo.options.messages[element.name] = messages = {};
$.each(this.adapters, function () {
var prefix = "data-val-" + this.name,
message = $element.attr(prefix),
paramValues = {};
if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy)
prefix += "-";
$.each(this.params, function () {
paramValues[this] = $element.attr(prefix + this);
});
this.adapt({
element: element,
form: form,
message: message,
params: paramValues,
rules: rules,
messages: messages
});
}
});
$.extend(rules, { "__dummy__": true });
if (!skipAttach) {
valInfo.attachValidation();
}
},
parse: function (selector) {
/// <summary>
/// Parses all the HTML elements in the specified selector. It looks for input elements decorated
/// with the [data-val=true] attribute value and enables validation according to the data-val-*
/// attribute values.
/// </summary>
/// <param name="selector" type="String">Any valid jQuery selector.</param>
// $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one
// element with data-val=true
var $selector = $(selector),
$forms = $selector.parents()
.addBack()
.filter("form")
.add($selector.find("form"))
.has("[data-val=true]");
$selector.find("[data-val=true]").each(function () {
$jQval.unobtrusive.parseElement(this, true);
});
$forms.each(function () {
var info = validationInfo(this);
if (info) {
info.attachValidation();
}
});
}
};
adapters = $jQval.unobtrusive.adapters;
adapters.add = function (adapterName, params, fn) {
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation.</summary>
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
/// <param name="params" type="Array" optional="true">[Optional] An array of parameter names (strings) that will
/// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and
/// mmmm is the parameter name).</param>
/// <param name="fn" type="Function">The function to call, which adapts the values from the HTML
/// attributes into jQuery Validate rules and/or messages.</param>
/// <returns type="jQuery.validator.unobtrusive.adapters" />
if (!fn) { // Called with no params, just a function
fn = params;
params = [];
}
this.push({ name: adapterName, params: params, adapt: fn });
return this;
};
adapters.addBool = function (adapterName, ruleName) {
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
/// the jQuery Validate validation rule has no parameter values.</summary>
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
/// of adapterName will be used instead.</param>
/// <returns type="jQuery.validator.unobtrusive.adapters" />
return this.add(adapterName, function (options) {
setValidationValues(options, ruleName || adapterName, true);
});
};
adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) {
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
/// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and
/// one for min-and-max). The HTML parameters are expected to be named -min and -max.</summary>
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
/// <param name="minRuleName" type="String">The name of the jQuery Validate rule to be used when you only
/// have a minimum value.</param>
/// <param name="maxRuleName" type="String">The name of the jQuery Validate rule to be used when you only
/// have a maximum value.</param>
/// <param name="minMaxRuleName" type="String">The name of the jQuery Validate rule to be used when you
/// have both a minimum and maximum value.</param>
/// <param name="minAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
/// contains the minimum value. The default is "min".</param>
/// <param name="maxAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
/// contains the maximum value. The default is "max".</param>
/// <returns type="jQuery.validator.unobtrusive.adapters" />
return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) {
var min = options.params.min,
max = options.params.max;
if (min && max) {
setValidationValues(options, minMaxRuleName, [min, max]);
}
else if (min) {
setValidationValues(options, minRuleName, min);
}
else if (max) {
setValidationValues(options, maxRuleName, max);
}
});
};
adapters.addSingleVal = function (adapterName, attribute, ruleName) {
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
/// the jQuery Validate validation rule has a single value.</summary>
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
/// in the data-val-nnnn HTML attribute(where nnnn is the adapter name).</param>
/// <param name="attribute" type="String">[Optional] The name of the HTML attribute that contains the value.
/// The default is "val".</param>
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
/// of adapterName will be used instead.</param>
/// <returns type="jQuery.validator.unobtrusive.adapters" />
return this.add(adapterName, [attribute || "val"], function (options) {
setValidationValues(options, ruleName || adapterName, options.params[attribute]);
});
};
$jQval.addMethod("__dummy__", function (value, element, params) {
return true;
});
$jQval.addMethod("regex", function (value, element, params) {
var match;
if (this.optional(element)) {
return true;
}
match = new RegExp(params).exec(value);
return (match && (match.index === 0) && (match[0].length === value.length));
});
$jQval.addMethod("nonalphamin", function (value, element, nonalphamin) {
var match;
if (nonalphamin) {
match = value.match(/\W/g);
match = match && match.length >= nonalphamin;
}
return match;
});
if ($jQval.methods.extension) {
adapters.addSingleVal("accept", "mimtype");
adapters.addSingleVal("extension", "extension");
} else {
// for backward compatibility, when the 'extension' validation method does not exist, such as with versions
// of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for
// validating the extension, and ignore mime-type validations as they are not supported.
adapters.addSingleVal("extension", "extension", "accept");
}
adapters.addSingleVal("regex", "pattern");
adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");
adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range");
adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength");
adapters.add("equalto", ["other"], function (options) {
var prefix = getModelPrefix(options.element.name),
other = options.params.other,
fullOtherName = appendModelPrefix(other, prefix),
element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0];
setValidationValues(options, "equalTo", element);
});
adapters.add("required", function (options) {
// jQuery Validate equates "required" with "mandatory" for checkbox elements
if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") {
setValidationValues(options, "required", true);
}
});
adapters.add("remote", ["url", "type", "additionalfields"], function (options) {
var value = {
url: options.params.url,
type: options.params.type || "GET",
data: {}
},
prefix = getModelPrefix(options.element.name);
$.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) {
var paramName = appendModelPrefix(fieldName, prefix);
value.data[paramName] = function () {
var field = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']");
// For checkboxes and radio buttons, only pick up values from checked fields.
if (field.is(":checkbox")) {
return field.filter(":checked").val() || field.filter(":hidden").val() || '';
}
else if (field.is(":radio")) {
return field.filter(":checked").val() || '';
}
return field.val();
};
});
setValidationValues(options, "remote", value);
});
adapters.add("password", ["min", "nonalphamin", "regex"], function (options) {
if (options.params.min) {
setValidationValues(options, "minlength", options.params.min);
}
if (options.params.nonalphamin) {
setValidationValues(options, "nonalphamin", options.params.nonalphamin);
}
if (options.params.regex) {
setValidationValues(options, "regex", options.params.regex);
}
});
adapters.add("fileextensions", ["extensions"], function (options) {
setValidationValues(options, "extension", options.params.extensions);
});
$(function () {
$jQval.unobtrusive.parse(document);
});
return $jQval.unobtrusive;
}));

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,22 @@
The MIT License (MIT)
=====================
Copyright Jörn Zaefferer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

1601
Project.Zap/wwwroot/lib/jquery-validation/dist/jquery.validate.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,36 @@
Copyright JS Foundation and other contributors, https://js.foundation/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

10364
Project.Zap/wwwroot/lib/jquery/dist/jquery.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

2
Project.Zap/wwwroot/lib/jquery/dist/jquery.min.js поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше