UserRoles basic concept

This commit is contained in:
Adam 2023-11-07 18:39:36 +01:00
parent 9d3bf9d19a
commit 033e33e84d
20 changed files with 847 additions and 89 deletions

261
.gitignore vendored Normal file
View File

@ -0,0 +1,261 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

View File

@ -0,0 +1,106 @@
@page "/hotel"
@using TIAMSharedUI.Shared
@inject NavigationManager navManager
<div class="container-fluid">
<section class="py-5">
<div class="row gx-4 gx-lg-5 align-items-center">
<div class="col-md-6">
<!--Slider here-->
<style>
.owl-stage-outer {
border-radius: 15px;
}
</style>
<div style="position: relative; width:100%; height: 100%">
<div style="position:absolute; top: 10px; left: 10px; z-index:999; ">
<h3 style="backdrop-filter: blur(5px); border-radius: 5px; color: white; padding: 3px; background-color: rgba(0,0,0,.2);">
10% DISCOUNT COUPON
</h3>
</div>
<div id="owl-restaurant" class="owl-carousel owl-theme">
<div class="item d-flex align-items-center">
<img src="_content/TIAMSharedUI/images/restaurant_1.jpg" class="my-auto" alt="The Last of us">
</div>
<div class="item d-flex align-items-center">
<img src="_content/TIAMSharedUI/images/restaurant_2.jpg" class="my-auto" alt="GTA V">
</div>
<div class="item d-flex align-items-center">
<img src="_content/TIAMSharedUI/images/restaurant_3.jpg" class="my-auto" alt="Mirror Edge">
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="small mb-1">Authentic</div>
<h1 class="display-5 fw-bolder">Mandragóra Restaurant</h1>
<div class="fs-5 mb-5">
<!--span class="text-decoration-line-through">$45.00</span-->
<span>$10.00</span>
</div>
<p class="lead">A nice Hungarian restaurant that offers a delightful culinary journey with traditional dishes like goulash, stuffed peppers, and chimney cake, in a cozy, welcoming atmosphere.</p>
<div class="d-flex">
<button class="btn btn-primary" @onclick="next">Book a transfer now</button>
</div>
</div>
<div class="col-md-12">
<div class="embed-responsive">
<h3> Location: </h3>
<p>Kacsa u. 13, Budapest</p>
@{
var aKey = "AIzaSyAyEYJkpt2KDa3SJ34UNWO4-dNOJKmUtF8";
var gUrl = "https://www.google.com/maps/embed/v1/place?key=" + aKey + "&q=Space+Needle,Budapest+HU";
}
<iframe class="embed-responsive-item"
loading="lazy"
width="100%"
style="height: 30vh; border-radius: 15px;"
referrerpolicy="no-referrer-when-downgrade"
src=@gUrl>
</iframe>
</div>
</div>
</div>
</section>
<!-- Related items section-->
<FeaturedItems ItemType="1"></FeaturedItems>
</div>
<script>
$(document).ready(function () {
$("#owl-restaurant").owlCarousel({
navigation: true, // Show next and prev buttons
slideSpeed: 300,
paginationSpeed: 400,
items: 1,
itemsDesktop: false,
itemsDesktopSmall: false,
itemsTablet: false,
itemsMobile: false
});
});
</script>
@code {
public void next() => navManager.NavigateTo("/transfer");
}

View File

@ -1,14 +1,21 @@
@page "/restaurant"
@using TIAMSharedUI.Shared
@inject NavigationManager navManager
<div class="container-fluid">
<section class="py-5">
<div class="row gx-4 gx-lg-5 align-items-center">
<div class="col-md-6">
<div class="col-md-6 my-3">
<!--Slider here-->
<style>
.owl-stage-outer {
border-radius: 15px;
}
</style>
<div style="position: relative; width:100%; height: 100%">
<div style="position:absolute; top: 10px; left: 10px; z-index:999; ">
<h3 style="backdrop-filter: blur(5px); border-radius: 5px; color: white; padding: 3px; background-color: rgba(0,0,0,.2);">
@ -29,12 +36,13 @@
<img src="_content/TIAMSharedUI/images/restaurant_3.jpg" class="my-auto" alt="Mirror Edge">
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-6 my-3">
<div class="small mb-1">Authentic</div>
<h1 class="display-5 fw-bolder">Mandragóra Restaurant</h1>
<div class="fs-5 mb-5">
@ -43,6 +51,31 @@
</div>
<p class="lead">A nice Hungarian restaurant that offers a delightful culinary journey with traditional dishes like goulash, stuffed peppers, and chimney cake, in a cozy, welcoming atmosphere.</p>
<div class="d-flex">
<button class="btn btn-primary" @onclick="next">Book a transfer now</button>
</div>
</div>
<div class="col-md-6 my-3">
<h3> Offer: </h3>
<p>Traditional Hungarian cuisine</p>
<embed class="bg-light" src="https://newyorkrestaurant.co.za/new-york-menu.pdf" style="width:100%; height:45vh;"/>
</div>
<div class="col-md-6 my-3">
<h3> Location: </h3>
<p>Kacsa u. 13, Budapest</p>
<div class="embed-responsive">
@{
var aKey = "AIzaSyAyEYJkpt2KDa3SJ34UNWO4-dNOJKmUtF8";
var gUrl = "https://www.google.com/maps/embed/v1/place?key=" + aKey + "&q=Space+Needle,Kacsa+utca+13,Budapest+HU";
}
<iframe class="embed-responsive-item"
loading="lazy"
width="100%"
style="height: 45vh; border-radius: 15px;"
referrerpolicy="no-referrer-when-downgrade"
src=@gUrl>
</iframe>
</div>
</div>
@ -50,7 +83,7 @@
</section>
<!-- Related items section-->
<FeaturedItems ItemType="1"></FeaturedItems>
<FeaturedItems ItemType="2"></FeaturedItems>
</div>
<script>
$(document).ready(function () {
@ -74,5 +107,8 @@
</script>
@code {
public void next() => navManager.NavigateTo("/transfer");
}

View File

@ -1,6 +1,6 @@
@page "/transfer"
@using TIAMSharedUI.Shared
@inject NavigationManager navManager
<PageTitle>Transfer</PageTitle>
<div class="text-center m-5">
@ -9,15 +9,17 @@
</div>
<SliderItemSelector @ref="slider" OnSliderChanged=@DisplaySlideData></SliderItemSelector>
<SliderItemSelector @ref="slider" OnSliderChanged=@DisplaySlideData TextChanged="@changeDest"></SliderItemSelector>
<div class="wrapper">
<div class="text-center name">
@message
</div>
<form class="p-3 mt-2">
<div class="form-field d-flex align-items-center">
<input type="tel" name="phone" id="phone" placeholder="Pick up address">
<input value=@message2 type="text" name="DestinationAddress" id="destinationAddress" placeholder="Destination" disabled>
</div>
<div class="form-field d-flex align-items-center">
<input type="tel" name="phone" id="phone" placeholder="Phone number">
</div>
<div class="form-field d-flex align-items-center">
<input type="text" name="address" id="address" placeholder="Pick up address">
@ -41,11 +43,17 @@
@code {
SliderItemSelector slider;
public string message;
public string message;
public string message2;
public List<string> destinations = new List<string>() {"Liszt Ferenc Airport", "Buda Castle", "Chain Bridge"};
void DisplaySlideData()
{
message = " Target destination is " + slider.SliderElementId.ToString();
if(slider.SliderElementId != 0)
{
message2 = destinations[slider.SliderElementId-1];
}
}
/*protected override void OnAfterRender(bool isFirst)
@ -53,10 +61,13 @@
message = " Target destination is " + slider.SliderElementId.ToString();
}*/
public void next()
void changeDest(string dest)
{
message2 = dest;
}
public void next() => navManager.NavigateTo("/transfer2");
}

View File

@ -176,7 +176,7 @@
/*background-color: #03A9F4;*/
color: #fff;
border-radius: 15px;
box-shadow: 3px 3px 3px #b1b1b1, -3px -3px 3px #fff;
/*box-shadow: 3px 3px 3px #b1b1b1, -3px -3px 3px #fff;*/
letter-spacing: 1.3px;
}

View File

@ -1,53 +0,0 @@
@page "/transfer2"
@using TIAMSharedUI.Shared
<PageTitle>Transfer summary</PageTitle>
<div class="text-center m-5">
<h1>Transfer</h1>
<h2 style="font-size:small">Please finalize your order!</h2>
</div>
<div class="wrapper">
<div class="text-center name">
</div>
<form class="p-3 mt-2">
<div class="form-field d-flex align-items-center">
<input type="tel" name="phone" id="phone" placeholder="Pick up address">
</div>
<div class="form-field d-flex align-items-center">
<input type="text" name="address" id="address" placeholder="Pick up address">
</div>
<div class="form-field d-flex align-items-center">
<input type="date" name="date" id="date" placeholder="Date of transfer">
</div>
<div class="form-field d-flex align-items-center">
<input type="time" name="time" id="time" placeholder="Time of transfer">
</div>
<div class="form-field d-flex align-items-center">
<input type="number" name="time" id="passengers" placeholder="Number of passangers">
</div>
<a class="btn btn-secondary mt-3" @onclick="next">Back</a>
<a class="btn btn-primary mt-3" @onclick="next">Next</a>
</form>
</div>
@code {
[Parameter]
public object? Transfer { get; set; }
public void next()
{
}
}

View File

@ -0,0 +1,72 @@
@page "/transfer2"
<PageTitle>Transferdetails</PageTitle>
@inject NavigationManager navManager
<div class="text-center m-5">
<h1>Transfer summary</h1>
<h2 style="font-size:small">Please review your transfer!</h2>
</div>
<section>
<div class="container py-1">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-md-10 col-lg-8 col-xl-6">
<div class="card card-admin card-stepper" style="border-radius: 16px;">
<div class="card-header py-2 px-4">
<div class="d-flex justify-content-between align-items-center">
<div>
<h4>27th November, 2023, 10:00 AM</h4>
</div>
</div>
</div>
<div class="card-body p-4">
<div class="d-flex flex-row mb-4 pb-2">
<div class="flex-fill">
<p class="text-muted"> Passenger info</p>
<h5 class="bold"> +1 123 12345678</h5>
<hr/>
<p class="text-muted">Destination</p>
<h5 class="bold">Liszt Ferenc Airport</h5>
<hr />
<p class="text-muted"> Pick up address</p>
<h5> Budapest, Dózsa György út 35, 1146</h5>
<hr />
<h5>3 persons</h5>
<p class="text-muted"> Silver, Toyota, Prius</p>
</div>
<div>
<!--img class="align-self-center img-fluid"
src="https://mdbcdn.b-cdn.net/img/Photos/Horizontal/E-commerce/Products/6.webp" width="250"-->
</div>
</div>
<div class="d-flex flex-row mb-4 pb-2">
<h4> $ 35 <span class="small text-muted"> via (COD) </span></h4>
</div>
</div>
<div class="card-footer p-4">
<div class="d-flex justify-content-between">
<a class="btn btn-danger" href="#!">Cancel</a>
<div class="border-start h-100"></div>
<a class="btn btn-warning" @onclick="previous">Modify</a>
<div class="border-start h-100"></div>
<a class="btn btn-success" href="#!">Finalize</a>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
@code {
public void next() => navManager.NavigateTo("/transfer");
public void previous() => navManager.NavigateTo("/transfer3");
}

View File

@ -1,6 +1,7 @@
@inherits LayoutComponentBase
@using TIAMWebApp.Shared.Application.Interfaces
@inject IUserDataService UserDataService;
@inject IJSRuntime jsRuntime
<div class="page">
<div class="my-sidebar">
@ -27,10 +28,31 @@
bool isUserLoggedIn;
int userType = 0;
int currentUserRole = 249;
//add a new dictionary for the role types
protected override async Task OnInitializedAsync()
{
var user = await UserDataService.IsLoggedInAsync();
isUserLoggedIn = user.IsLoggedIn;
isUserLoggedIn = user.IsLoggedIn;
}
protected override void OnAfterRender(bool isFirst)
{
LogToBrowserConsole("0 ");
}
public void LogToBrowserConsole(string message)
{
jsRuntime.InvokeVoidAsync("console.log", message);
}
}

View File

@ -1,5 +1,41 @@

<div id="owl-selector" class="owl-carousel owl-theme" style="padding-left: 20px; padding-right:20px;">
<style>
.underlineInput{
padding-left: 10px;
margin-bottom: 20px;
border-bottom: 1px solid;
}
.underlineInput > input {
padding-left: 10px;
border-bottom: 1px solid;
}
</style>
<div id="owl-selector" class="owl-carousel owl-theme" style="padding-left: 20px; padding-right:20px; border-radius: 15px;">
<div class="item" id="0" style="background-color: rgba(0,0,0,0.1)">
<div class="item-desc text-center pt-3">
<h3>Please type an address or swipe to select from preset destinations!</h3>
<div class="wrapper" style="max-width: 800px; margin:0 auto">
<DxTextBox
TextChanged="@((newValue) => OnTextChanged(newValue))"
BindValueMode="@BindValueMode"
InputDelay="@InputDelay"
NullText="Type text..."
CssClass="cw-320 form-field underlineInput" />
</div>
<p class="demo-text cw-320 mt-2">
Text: <b>@TextValue</b>
</p>
</div>
</div>
<div class="item" id="1" style="background-image: url(https://images.unsplash.com/photo-1551867633-194f125bddfa?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D); background-position: center;">
<div class="item-desc text-center pt-3">
<h3>Liszt Ferenc Airport</h3>
@ -20,12 +56,6 @@
</div>
</div>
<form>
</form>
<script>
@ -51,20 +81,20 @@
owl.owlCarousel({
navigation: true, // Show next and prev buttons
loop: true,
slideSpeed: 300,
paginationSpeed: 400,
items: 1,
itemsDesktop: false,
itemsDesktopSmall: false,
itemsTablet: false,
itemsMobile: false
itemsMobile: false
});
owl.trigger("to.owl.carousel", owl.maximum)
});
function CStoJSCall(dotNetObjRef) {
@ -94,11 +124,19 @@
@code {
public string TextValue { get; set; } = null;
int? InputDelay { get; set; } = 3500;
BindValueMode BindValueMode { get; set; } = BindValueMode.OnInput;
bool BindDelayEnabled { get { return BindValueMode == BindValueMode.OnDelayedInput; } }
[Parameter]
public EventCallback<string> TextChanged { get; set; }
public int SliderElementId = 0;
string content = "";
[Parameter]
public EventCallback<int> OnSliderChanged { get; set; }
[Inject]
public IJSRuntime JSRuntime { get; set; }
@ -121,7 +159,13 @@
SliderElementId = Convert.ToInt32(itemId);
OnSliderChanged.InvokeAsync(Convert.ToInt32(itemId));
StateHasChanged();
/*StateHasChanged();*/
}
void OnTextChanged(string newValue)
{
TextValue = newValue;
TextChanged.InvokeAsync(newValue);
}
}

View File

@ -34,6 +34,10 @@ body {
border-radius: 15px;
}
.btn-success, .btn-warning, .btn-danger {
border-radius: 15px;
}
.btn-secondary {
background-color: #f7279f;
border-radius: 15px;
@ -70,18 +74,28 @@ select {
.dxbl-text-edit {
background-color: transparent;
border-color: transparent;
padding-left: 10px;
/*padding-left: 10px;
margin-bottom: 20px;
border-radius: 20px;
box-shadow: inset 3px 3px 3px #cbced1, inset -3px -3px 3px #fff;
box-shadow: inset 3px 3px 3px #cbced1, inset -3px -3px 3px #fff;*/
color: #666;
}
.dxbl-text-edit:focus, .dxbl-text-edit:focus-within {
border-color: transparent;
box-shadow: none;
}
.dxbl-text-edit-input {
background-color: transparent;
margin:10px;
color: #666;
}
.dxbl-text-edit-input:focus, .dxbl-text-edit-input:focus-within {
border-color: transparent;
box-shadow: none;
}
/*my blazor overrides end*/
.custom-select {
padding: 10px 15px 10px 10px !important;
@ -326,6 +340,8 @@ select:focus-visible {
border-radius: 15px;*/
}
/*End Hero Carousel*/
/*Admin*/

View File

@ -1,6 +1,7 @@
using System.Net.Http.Json;
using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models;
using static TIAMSharedUI.Shared.MainLayout;
namespace TIAMWebApp.Client.Services
{
@ -8,12 +9,29 @@ namespace TIAMWebApp.Client.Services
{
private readonly HttpClient http;
public User? User { get; set; } = new User();
public Dictionary<int, string> userRoleTypes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public UserDataService(HttpClient http)
{
this.http = http;
}
public List<RoleType> roleTypes = new List<RoleType>
{
new RoleType { Id = 1, RoleName = "Login" },
new RoleType { Id = 2, RoleName = "Member" },
new RoleType { Id = 4, RoleName = "Vip" },
new RoleType { Id = 8, RoleName = "Uvip" },
new RoleType { Id = 16, RoleName = "Volunteer" },
new RoleType { Id = 32, RoleName = "Guide" },
new RoleType { Id = 64, RoleName = "Protector" },
new RoleType { Id = 128, RoleName = "Admin" },
new RoleType { Id = 256, RoleName = "SuperAdmin" },
new RoleType { Id = 512, RoleName = "God" }
};
public async Task<User> IsLoggedInAsync()
{
if (User == null)
@ -43,6 +61,25 @@ namespace TIAMWebApp.Client.Services
return User;
}
public Task<Dictionary<int, string>> GetUserRolesAsync(User user)
{
//get the user's roles
int role = User.UserRoles;
foreach (var roleType in roleTypes)
{
if ((role & roleType.Id) == roleType.Id)
{
//add the role to the dictionary
userRoleTypes.Add(roleType.Id, roleType.RoleName);
}
}
return Task.FromResult(userRoleTypes);
}
}
}

View File

@ -15,7 +15,8 @@
<link href="_content/TIAMSharedUI/css/app.css" rel="stylesheet" />
<link href="_content/TIAMSharedUI/css/TourIAm.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="_content/TIAMSharedUI/favicon.png" />
<link href="TIAMWebApp.Client.styles.css" rel="stylesheet" />
<link href="TIAMWebApp.Client.styles.css" rel="stylesheet" />
</head>
<body>
@ -33,6 +34,7 @@
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/cesiumjs/1.105/Build/Cesium/Cesium.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
</body>

View File

@ -0,0 +1,138 @@
using System;
using System.Threading.Tasks;
using GoogleApi.Entities.Common;
using GoogleApi.Entities.Common.Enums;
using GoogleApi.Entities.Maps.Common;
using GoogleApi.Entities.Maps.Common.Enums;
using GoogleApi.Entities.Maps.DistanceMatrix.Request;
using Microsoft.AspNetCore.Mvc;
using System.Reflection.Metadata;
using TIAMWebApp.Shared.Application.Models;
using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames;
using System.Net;
using GoogleApi.Entities.Maps.DistanceMatrix.Response;
namespace TIAMWebApp.Server.Controllers
{
[ApiController]
[Route("[controller]")]
public class GoogleAPIController : ControllerBase
{
private static readonly TripInfo[] Trips = new TripInfo[]
{
new TripInfo(47.511887f, 19.031920f, 47.510769f, 19.081422f ),
};
private readonly ILogger<SupplierAPIController> _logger;
public GoogleAPIController(ILogger<SupplierAPIController> logger)
{
_logger = logger;
}
[HttpGet]
[Route("GetAddressForCoordinates")]
public string GetAddressForCoordinates(TripInfo myTrip)
{
var latitude = Trips[0].StartLatitude; // Example latitude
var longitude = Trips[0].StartLongitude; // Example longitude
Console.WriteLine(latitude);
Console.WriteLine(longitude);
try
{
/*var address = locationService.GetAddressFromLatLang(latitude, longitude);
Console.WriteLine(address.Address);
string myaddress = address.Address;
return "myaddress: " + myaddress;*/
return "";
}
catch (System.Net.WebException ex)
{
Console.WriteLine("Google Maps API Error {0}", ex.Message);
return "Google Maps API Error {0}" + ex.Message;
}
}
[HttpGet]
[Route("GetTravelTime")]
//public string GetTravelTime(TripInfo)
public async Task<string> GetTravelTimeWithGoogleMatrix()
{
var latitude1 = Trips[0].StartLatitude; // Example latitude
var longitude1 = Trips[0].StartLongitude; // Example longitude
var latitude2 = Trips[0].EndLatitude; // Example latitude
var longitude2 = Trips[0].EndLongitude; // Example longitude
Console.WriteLine(latitude1);
Console.WriteLine(longitude1);
Console.WriteLine(latitude2);
Console.WriteLine(longitude2);
try
{
var origin1 = new Address("Margit utca 35, Budapest, Budapest, Magyarország");
var origin2 = new Address("Nefelejcs utca 18, Budapest, Budapest, Magyarország");
var destination1 = new Address("Százados utca 30/a, Budapest, Budapest, Magyarország");
var destination2 = new Address("Novoszadek utca 53, Pilisszántó, Pest, Magyarország");
DistanceMatrixResponse? response = null;
//var response = await GoogleMaps.DistanceMatrix.QueryAsync(request);
try
{
var request = new DistanceMatrixRequest
{
Key = "AIzaSyAyEYJkpt2KDa3SJ34UNWO4-dNOJKmUtF8",
Origins = new[]
{
new LocationEx(origin1),
new LocationEx(origin2)
},
Destinations = new[]
{
new LocationEx(destination1),
new LocationEx(destination2)
},
TravelMode = TravelMode.Driving,
};
response = await GoogleApi.GoogleMaps.DistanceMatrix.QueryAsync(request);
return response.RawJson;
}
catch (Exception e)
{
Console.Write("Errorcode: {0}", (int)response.Status);
}
return "";
}
catch (WebException ex)
{
Console.WriteLine("Google Maps API Error {0}", ex.Message);
return "Google Maps API Error {0}" + ex.Message;
}
}
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>C:\REPOS\AYCODE\Publish\Server</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
</PropertyGroup>
</Project>

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GoogleApi" Version="5.2.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.10" />
</ItemGroup>

View File

@ -2,6 +2,6 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>https</ActiveDebugProfile>
<NameOfLastUsedPublishProfile>C:\MANGOWEB\TourIAmProject\TIAMWebApp\Server\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
<NameOfLastUsedPublishProfile>C:\REPOS\AYCODE\source\TourIAm\TIAMWebApp\Server\Properties\PublishProfiles\FolderProfile1.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>

View File

@ -9,8 +9,13 @@ namespace TIAMWebApp.Shared.Application.Interfaces
{
public interface IUserDataService
{
public User? User { get; set; }
public Dictionary<int, string> userRoleTypes { get; set; }
public Task<User> IsLoggedInAsync();
public Task<User> AuthorizeUserAsync(int userType);
public Task<Dictionary<int, string>> GetUserRolesAsync(User user);
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TIAMWebApp.Shared.Application.Models
{
public class RoleType
{
public int Id { get; set; }
public string? RoleName { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TIAMWebApp.Shared.Application.Models
{
public class TripInfo
{
public float StartLatitude { get; set; }
public float StartLongitude { get; set; }
public float EndLatitude { get; set; }
public float EndLongitude { get; set; }
public TripInfo(float startLatitude, float startLongitude, float endLatitude, float endLongitude )
{
StartLatitude = startLatitude;
StartLongitude = startLongitude;
EndLatitude = endLatitude;
EndLongitude = endLongitude;
}
}
}

View File

@ -9,7 +9,9 @@ namespace TIAMWebApp.Shared.Application.Models
public class User
{
public bool IsLoggedIn { get; set; }
public UserType UserType { get; set; }
public UserType UserType { get; set; }
public int UserRoles { get; set; }
public Dictionary<int, string> UserRolesDictionary { get; set; }
}