mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 21:50:12 +01:00
Compare commits
71 Commits
pawelZmian
...
8837c4c09e
| Author | SHA1 | Date | |
|---|---|---|---|
| 8837c4c09e | |||
| e20347d8fa | |||
|
|
3aabcd831e | ||
|
|
f5d7637d2f | ||
|
|
0b27a0f91c | ||
|
|
fd6c4dfb11 | ||
| a4cea4eeb3 | |||
| b8990be51e | |||
| 9dbbb7690d | |||
|
|
a8d706bf97 | ||
| 80ad9db83d | |||
| ae0fab301a | |||
| 9de5c85120 | |||
| f7583738d7 | |||
| 4a82822d64 | |||
| b075ef7e78 | |||
| 50a4c24660 | |||
| 271bf84467 | |||
|
|
fd97b2c2d9 | ||
| 42fd94e5ac | |||
| 07128948b0 | |||
| efb71b24d3 | |||
|
|
aa5caf4375 | ||
|
|
26635b4e88 | ||
|
|
7e3759927f | ||
|
|
b440a0334c | ||
|
|
69895f4f35 | ||
|
|
5d362e2a39 | ||
|
|
a81a57654c | ||
| 426288d728 | |||
| 72fbfe982f | |||
| 4be57c27d9 | |||
| b9a7ca08f5 | |||
| a83d8e963a | |||
|
|
9306c90ad6 | ||
| 239b588175 | |||
| 32027f7384 | |||
|
|
e47fd77333 | ||
|
|
2a8fff39c9 | ||
|
|
b194819b6e | ||
|
|
5da58ee030 | ||
|
|
42e468f28f | ||
|
|
48184cd8b6 | ||
|
|
f2ccde2ea6 | ||
|
|
740f8a955d | ||
| 89543558b0 | |||
| 39f483fdaa | |||
| 07702b93b1 | |||
| ace54fb4ef | |||
| 82936633f1 | |||
| ef7ec0fc33 | |||
| 4da3729edb | |||
| 5536a9ad7f | |||
| e0e6fa0573 | |||
| d4db4e2493 | |||
| 8ffb7f4eff | |||
|
|
69c508ef84 | ||
|
|
bebf47a2ba | ||
| 1eb104945a | |||
|
|
b5838cbac1 | ||
|
|
b70697abc3 | ||
| d1117959cd | |||
| eb9fa8b9ca | |||
| 9034c058f0 | |||
| fc1ff88f3d | |||
| ad4743d68e | |||
| 840bc3e0bd | |||
|
|
7c78386b04 | ||
| 48fed2ee5d | |||
| 38e3cf06b9 | |||
|
|
31f8cabeb0 |
5
.editorconfig
Normal file
5
.editorconfig
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[*]
|
||||||
|
end_of_line = crlf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using WebApp.Data;
|
|
||||||
using WebApp.Entities;
|
|
||||||
|
|
||||||
namespace WebApp.Controllers.Api;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/events")]
|
|
||||||
public class EventsApiController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ApplicationDbContext _context;
|
|
||||||
|
|
||||||
public EventsApiController(ApplicationDbContext context)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: /api/events
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult GetAll()
|
|
||||||
{
|
|
||||||
var events = _context.Events.ToList();
|
|
||||||
return Ok(events);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: /api/events/5
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public IActionResult GetById(int id)
|
|
||||||
{
|
|
||||||
var ev = _context.Events.Find(id);
|
|
||||||
if (ev == null)
|
|
||||||
return NotFound();
|
|
||||||
|
|
||||||
return Ok(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST: /api/events
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult Create([FromBody] Event ev)
|
|
||||||
{
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(ModelState);
|
|
||||||
|
|
||||||
ev.EventDate = DateTime.SpecifyKind(ev.EventDate, DateTimeKind.Utc);
|
|
||||||
|
|
||||||
_context.Events.Add(ev);
|
|
||||||
_context.SaveChanges();
|
|
||||||
|
|
||||||
return CreatedAtAction(nameof(GetById), new { id = ev.EventId }, ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT: /api/events/5
|
|
||||||
[HttpPut("{id}")]
|
|
||||||
public IActionResult Update(int id, [FromBody] Event updated)
|
|
||||||
{
|
|
||||||
if (id != updated.EventId)
|
|
||||||
return BadRequest("ID w URL nie zgadza się z obiektem.");
|
|
||||||
|
|
||||||
var ev = _context.Events.Find(id);
|
|
||||||
if (ev == null)
|
|
||||||
return NotFound();
|
|
||||||
|
|
||||||
ev.Title = updated.Title;
|
|
||||||
ev.Description = updated.Description;
|
|
||||||
ev.Location = updated.Location;
|
|
||||||
ev.EventDate = updated.EventDate;
|
|
||||||
ev.OrganisationId = updated.OrganisationId;
|
|
||||||
|
|
||||||
_context.SaveChanges();
|
|
||||||
return NoContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE: /api/events/5
|
|
||||||
[HttpDelete("{id}")]
|
|
||||||
public IActionResult Delete(int id)
|
|
||||||
{
|
|
||||||
var ev = _context.Events.Find(id);
|
|
||||||
if (ev == null)
|
|
||||||
return NotFound();
|
|
||||||
|
|
||||||
_context.Events.Remove(ev);
|
|
||||||
_context.SaveChanges();
|
|
||||||
|
|
||||||
return NoContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
15
WebApp/DTOs/EventCreateDto.cs
Normal file
15
WebApp/DTOs/EventCreateDto.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
// Input values in JSON file to create event
|
||||||
|
public record class EventCreateDto
|
||||||
|
(
|
||||||
|
[Required][StringLength(50)] string Title,
|
||||||
|
[StringLength(500)] string Description,
|
||||||
|
string? ImageURL,
|
||||||
|
[Required][StringLength(100)] string Location,
|
||||||
|
[Required] DateTime? EventDate,
|
||||||
|
ICollection<EventSkill> EventSkills
|
||||||
|
);
|
||||||
22
WebApp/DTOs/EventDetailsDto.cs
Normal file
22
WebApp/DTOs/EventDetailsDto.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
// Output values in JSON file
|
||||||
|
public record class EventDetailsDto
|
||||||
|
{
|
||||||
|
public int EventId { get; set; }
|
||||||
|
[Required] public int? OrganisationId { get; set; }
|
||||||
|
[Required] public string? OrganisationName { get; set; }
|
||||||
|
[Required][StringLength(50)] public string Title { get; set; }
|
||||||
|
[StringLength(500)] public string Description { get; set; }
|
||||||
|
public string? ImageURL { get; set; }
|
||||||
|
[Required][StringLength(100)] public string Location { get; set; }
|
||||||
|
[Required] public DateTime? EventDate { get; set; }
|
||||||
|
//ICollection<EventSkill> EventSkills,
|
||||||
|
public ICollection<SkillSummaryDto> EventSkills { get; set; }
|
||||||
|
public ICollection<EventRegistrationDto> EventRegistrations { get; set; }
|
||||||
|
|
||||||
|
public EventDetailsDto() { }
|
||||||
|
};
|
||||||
15
WebApp/DTOs/EventRegistrationDto.cs
Normal file
15
WebApp/DTOs/EventRegistrationDto.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
public record class EventRegistrationDto
|
||||||
|
{
|
||||||
|
public int EventId { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public string UserName { get; set; }
|
||||||
|
public DateTime RegisteredAt { get; set; }
|
||||||
|
|
||||||
|
public EventRegistrationDto() { }
|
||||||
|
|
||||||
|
};
|
||||||
17
WebApp/DTOs/EventSearchDto.cs
Normal file
17
WebApp/DTOs/EventSearchDto.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
// Input values in JSON file
|
||||||
|
public record class EventSearchDto
|
||||||
|
(
|
||||||
|
int? OrganisationId,
|
||||||
|
string? TitleOrDescription,
|
||||||
|
string? Location,
|
||||||
|
DateTime? EventDateFrom, // zakres daty od
|
||||||
|
DateTime? EventDateTo, // zakres daty do
|
||||||
|
ICollection<EventSkill>? EventSkills, // obecnie nie dotyczy
|
||||||
|
ICollection<EventRegistration>? EventRegistrations // obecnie nie dotyczy
|
||||||
|
|
||||||
|
);
|
||||||
20
WebApp/DTOs/EventSummaryDto.cs
Normal file
20
WebApp/DTOs/EventSummaryDto.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
// Output values in JSON file
|
||||||
|
public record class EventSummaryDto {
|
||||||
|
public int EventId { get; set; }
|
||||||
|
[Required] public string Organisation { get; set; }
|
||||||
|
[Required] public int OrganisationId { get; set; }
|
||||||
|
[Required] [StringLength(50)] public string Title { get; set; }
|
||||||
|
[StringLength(500)] public string Description { get; set; }
|
||||||
|
public string? ImageURL { get; set; }
|
||||||
|
[Required] [StringLength(100)] public string Location { get; set; }
|
||||||
|
[Required] public DateTime? EventDate { get; set; }
|
||||||
|
public ICollection<SkillSummaryDto> EventSkills { get; set; }
|
||||||
|
public ICollection<EventRegistrationDto> EventRegistrations { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
18
WebApp/DTOs/EventSummaryNoErDto.cs
Normal file
18
WebApp/DTOs/EventSummaryNoErDto.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
// Output values in JSON file
|
||||||
|
public record class EventSummaryNoErDto(
|
||||||
|
int EventId,
|
||||||
|
[Required] string Organisation,
|
||||||
|
[Required] int OrganisationId,
|
||||||
|
[Required][StringLength(50)] string Title,
|
||||||
|
[StringLength(500)] string Description,
|
||||||
|
string? ImageURL,
|
||||||
|
[Required][StringLength(100)] string Location,
|
||||||
|
[Required] DateTime? EventDate,
|
||||||
|
ICollection<EventSkill> EventSkills
|
||||||
|
// ICollection<SkillSummaryDto> EventSkills
|
||||||
|
);
|
||||||
15
WebApp/DTOs/EventUpdateDto.cs
Normal file
15
WebApp/DTOs/EventUpdateDto.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
// Input values in JSON file to update event
|
||||||
|
public record class EventUpdateDto
|
||||||
|
(
|
||||||
|
[Required][StringLength(50)] string Title,
|
||||||
|
[StringLength(500)] string Description,
|
||||||
|
string? ImageURL,
|
||||||
|
[Required][StringLength(100)] string Location,
|
||||||
|
[Required] DateTime? EventDate,
|
||||||
|
ICollection<EventSkill> EventSkills
|
||||||
|
);
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using WebApp.Entities;
|
|
||||||
|
|
||||||
namespace WebApp.DTOs;
|
|
||||||
public record class EventsDto(
|
|
||||||
int EventId,
|
|
||||||
int OrganisationId, //foreign key
|
|
||||||
[StringLength(200)] string Title,
|
|
||||||
[StringLength(800)] string Description,
|
|
||||||
[StringLength(100)] string Location,
|
|
||||||
DateTime EventDate,
|
|
||||||
Organisation? Organisation,
|
|
||||||
ICollection<EventSkill> EventSkills,
|
|
||||||
ICollection<EventRegistration> EventRegistrations
|
|
||||||
);
|
|
||||||
9
WebApp/DTOs/LoginDto.cs
Normal file
9
WebApp/DTOs/LoginDto.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
public record class LoginDto
|
||||||
|
(
|
||||||
|
[Required] string Email,
|
||||||
|
[Required] string Password
|
||||||
|
);
|
||||||
11
WebApp/DTOs/OrganisationSummaryDto.cs
Normal file
11
WebApp/DTOs/OrganisationSummaryDto.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
public record class OrganisationSummaryDto
|
||||||
|
(
|
||||||
|
[Required] int? OrganisationId,
|
||||||
|
[Required][StringLength(50)] string Name,
|
||||||
|
[StringLength(500)] string Description,
|
||||||
|
[Required][StringLength(200)] string Website
|
||||||
|
);
|
||||||
8
WebApp/DTOs/SingleSkillDto.cs
Normal file
8
WebApp/DTOs/SingleSkillDto.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
public record class SingleSkillDto
|
||||||
|
(
|
||||||
|
[Required] int Skill
|
||||||
|
);
|
||||||
13
WebApp/DTOs/SkillSummaryDto.cs
Normal file
13
WebApp/DTOs/SkillSummaryDto.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs;
|
||||||
|
|
||||||
|
public record class SkillSummaryDto
|
||||||
|
{
|
||||||
|
public int? SkillId { get; set; }
|
||||||
|
public string? SkillName { get; set; }
|
||||||
|
|
||||||
|
public SkillSummaryDto() { }
|
||||||
|
|
||||||
|
};
|
||||||
25
WebApp/DTOs/UserSummaryDto.cs
Normal file
25
WebApp/DTOs/UserSummaryDto.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace WebApp.DTOs
|
||||||
|
{
|
||||||
|
public record class UserSummaryDto
|
||||||
|
(
|
||||||
|
[Required] int UserId,
|
||||||
|
[Required] string Email,
|
||||||
|
[Required] string FirstName,
|
||||||
|
[Required] string LastName,
|
||||||
|
[Required] DateTime CreatedAt,
|
||||||
|
[Required] bool isOrganisation
|
||||||
|
);
|
||||||
|
|
||||||
|
public record class UserSummaryWithOrgIdDto
|
||||||
|
(
|
||||||
|
[Required] int UserId,
|
||||||
|
[Required] string Email,
|
||||||
|
[Required] string FirstName,
|
||||||
|
[Required] string LastName,
|
||||||
|
[Required] DateTime CreatedAt,
|
||||||
|
[Required] bool isOrganisation,
|
||||||
|
int? OrganisationId
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -5,19 +5,23 @@ using WebApp.Entities;
|
|||||||
|
|
||||||
namespace WebApp.Data
|
namespace WebApp.Data
|
||||||
{
|
{
|
||||||
public class ApplicationDbContext : IdentityDbContext<User, IdentityRole<string>, string>
|
public class ApplicationDbContext : IdentityDbContext//<User, IdentityRole<string>, string>
|
||||||
{
|
{
|
||||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
||||||
: base(options)
|
: base(options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DbSet<User> WebUsers => Set<User>();
|
||||||
|
public DbSet<Token> Tokens => Set<Token>();
|
||||||
public DbSet<Organisation> Organisations => Set<Organisation>();
|
public DbSet<Organisation> Organisations => Set<Organisation>();
|
||||||
public DbSet<Event> Events => Set<Event>();
|
public DbSet<Event> Events => Set<Event>();
|
||||||
public DbSet<Skill> Skills => Set<Skill>();
|
public DbSet<Skill> Skills => Set<Skill>();
|
||||||
public DbSet<VolunteerSkill> VolunteerSkills => Set<VolunteerSkill>();
|
public DbSet<VolunteerSkill> VolunteerSkills => Set<VolunteerSkill>();
|
||||||
public DbSet<EventSkill> EventSkills => Set<EventSkill>();
|
public DbSet<EventSkill> EventSkills => Set<EventSkill>();
|
||||||
public DbSet<EventRegistration> EventRegistrations => Set<EventRegistration>();
|
public DbSet<EventRegistration> EventRegistrations => Set<EventRegistration>();
|
||||||
|
public DbSet<Message> Messages => Set<Message>();
|
||||||
|
public DbSet<MessageActivity> MessagesActivities => Set<MessageActivity>();
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
@@ -32,6 +36,9 @@ namespace WebApp.Data
|
|||||||
|
|
||||||
builder.Entity<EventRegistration>()
|
builder.Entity<EventRegistration>()
|
||||||
.HasKey(er => new { er.UserId, er.EventId });
|
.HasKey(er => new { er.UserId, er.EventId });
|
||||||
|
|
||||||
|
builder.Entity<MessageActivity>()
|
||||||
|
.HasKey(ma => new { ma.Sender, ma.Recipient });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
255
WebApp/Endpoints/AuthEndpoints.cs
Normal file
255
WebApp/Endpoints/AuthEndpoints.cs
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WebApp.Data;
|
||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
using WebApp.Mapping;
|
||||||
|
|
||||||
|
namespace WebApp.Endpoints
|
||||||
|
{
|
||||||
|
public static class AuthEndpoints
|
||||||
|
{
|
||||||
|
|
||||||
|
public static RouteGroupBuilder MapAuthEndpoints(this WebApplication app)
|
||||||
|
{
|
||||||
|
const string GetUserEndpointName = "GetUser";
|
||||||
|
|
||||||
|
var group = app.MapGroup("api/auth")
|
||||||
|
.WithParameterValidation();
|
||||||
|
|
||||||
|
// POST /api/auth/login
|
||||||
|
group.MapPost("/login", async (LoginDto dto, ApplicationDbContext context, GeneralUseHelpers guh) =>
|
||||||
|
{
|
||||||
|
var user = await context.WebUsers.FirstOrDefaultAsync(u => u.Email == dto.Email);
|
||||||
|
|
||||||
|
string hashedPassword = HashPasswordSHA512(dto.Password);
|
||||||
|
|
||||||
|
if (user == null || user.Password != hashedPassword)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "Wrong email or password." }, statusCode: 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
var token = await guh.CreateNewToken(user.UserId);
|
||||||
|
|
||||||
|
return Results.Ok(new
|
||||||
|
{
|
||||||
|
message = "Login successful.",
|
||||||
|
token = token.Value
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/auth/logout
|
||||||
|
group.MapPost("/logout", async (HttpContext httpContext, GeneralUseHelpers guh) =>
|
||||||
|
{
|
||||||
|
var token = await guh.GetTokenFromHTTPContext(httpContext);
|
||||||
|
|
||||||
|
if (token == null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "No valid token found." }, statusCode: 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
await guh.DeleteToken(token);
|
||||||
|
|
||||||
|
httpContext.Response.Cookies.Delete("token");
|
||||||
|
|
||||||
|
return Results.Ok(new { success = true });
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/auth/my_account
|
||||||
|
group.MapGet("/my_account", async (HttpContext httpContext, GeneralUseHelpers guh) =>
|
||||||
|
{
|
||||||
|
var token = await guh.GetTokenFromHTTPContext(httpContext);
|
||||||
|
|
||||||
|
if(token == null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "No valid token found." }, statusCode: 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
User? user = await guh.GetUserFromToken(token);
|
||||||
|
|
||||||
|
if(user == null)
|
||||||
|
{
|
||||||
|
return Results.Json(new {message = "No user found."}, statusCode: 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
Organisation? org = await guh.GetOrganisationFromUserId(user.UserId);
|
||||||
|
if (org is not null) return Results.Ok(user.ToUserSummaryWithOrgIdDto(org.OrganisationId));
|
||||||
|
return Results.Ok(user.ToUserSummaryDto());
|
||||||
|
|
||||||
|
})
|
||||||
|
.WithName(GetUserEndpointName);
|
||||||
|
|
||||||
|
// GET /api/auth/my_events
|
||||||
|
group.MapGet("/my_events", async (HttpContext httpContext, GeneralUseHelpers guh, ApplicationDbContext context) =>
|
||||||
|
{
|
||||||
|
var token = await guh.GetTokenFromHTTPContext(httpContext);
|
||||||
|
|
||||||
|
if (token == null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "No valid token found." }, statusCode: 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
User? user = await guh.GetUserFromToken(token);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "No user found." }, statusCode: 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!user.IsOrganisation)
|
||||||
|
{
|
||||||
|
|
||||||
|
var eventIds = await context.EventRegistrations
|
||||||
|
.Where(er => er.UserId == user.UserId)
|
||||||
|
.Select(er => er.EventId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var events = await context.Events
|
||||||
|
.Where(e => eventIds.Contains(e.EventId))
|
||||||
|
.Include(e => e.Organisation)
|
||||||
|
.Select(e => e.ToEventSummaryDto())
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Ok(events);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var org = await context.Organisations.FirstOrDefaultAsync(o => o.UserId == user.UserId);
|
||||||
|
|
||||||
|
if(org == null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "No organisation found for this user." }, statusCode: 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
var events = await context.Events
|
||||||
|
.Where(e => e.OrganisationId == org.OrganisationId)
|
||||||
|
.Select(e => e.ToEventSummaryDto())
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Ok(events);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/auth/add_skill
|
||||||
|
group.MapPost("/add_skill", async (SingleSkillDto dto, HttpContext httpContext, ApplicationDbContext context, GeneralUseHelpers guh) =>
|
||||||
|
{
|
||||||
|
// Uzyskaj użytkownika z tokenu
|
||||||
|
Token? token = await guh.GetTokenFromHTTPContext(httpContext);
|
||||||
|
User? user = await guh.GetUserFromToken(token);
|
||||||
|
|
||||||
|
// Tylko wolontariusze powinni móc dodawać swoje skille
|
||||||
|
if (user == null || user.IsOrganisation) {
|
||||||
|
return Results.Json(new { message = "Unauthorized" }, statusCode: 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Szukamy skilla w bazie o ID takim, jak w otrzymanym DTO
|
||||||
|
Skill? skill = await context.Skills.FindAsync(dto.Skill);
|
||||||
|
if (skill is null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "Skill not found" }, statusCode: 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sprawdzamy, czy ten użytkownik nie ma już takiego skilla. Jeżeli ma, nie ma sensu dodawać go kilkukrotnie.
|
||||||
|
VolunteerSkill? vs = await context.VolunteerSkills.FirstOrDefaultAsync(v => v.UserId == user.UserId && v.SkillId == dto.Skill);
|
||||||
|
if (vs is null)
|
||||||
|
{
|
||||||
|
// Nie ma - zatem musimy dodać nowy VolunteerSkill do bazy
|
||||||
|
VolunteerSkill newVs = dto.ToVolunteerSkillEntity(user.UserId);
|
||||||
|
context.VolunteerSkills.Add(newVs);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// Ma - (ta para UserId <-> SkillId już istnieje w bazie) użytkownik już ma ten skill
|
||||||
|
return Results.Json(new { message = "You already have this skill!" }, statusCode: 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Json(new { message = "Skill added successfully!" }, statusCode: 201);
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/auth/remove_skill
|
||||||
|
group.MapPost("/remove_skill", async (SingleSkillDto dto, HttpContext httpContext, ApplicationDbContext context, GeneralUseHelpers guh) =>
|
||||||
|
{
|
||||||
|
// Uzyskaj użytkownika z tokenu
|
||||||
|
Token? token = await guh.GetTokenFromHTTPContext(httpContext);
|
||||||
|
User? user = await guh.GetUserFromToken(token);
|
||||||
|
|
||||||
|
// Tylko wolontariusze powinni móc usuwać swoje skille
|
||||||
|
if (user == null || user.IsOrganisation)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "Unauthorized" }, statusCode: 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Szukamy skilla w bazie o ID takim, jak w otrzymanym DTO
|
||||||
|
Skill? skill = await context.Skills.FindAsync(dto.Skill);
|
||||||
|
if (skill is null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "Skill not found" }, statusCode: 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sprawdzamy, czy ten użytkownik ma już taki skill. Jeżeli nie ma, to nie ma sensu usuwać czegoś, czego nie ma.
|
||||||
|
VolunteerSkill? vs = await context.VolunteerSkills.FirstOrDefaultAsync(v => v.UserId == user.UserId && v.SkillId == dto.Skill);
|
||||||
|
if (vs is not null)
|
||||||
|
{
|
||||||
|
// Ma - zatem musimy usunąć otrzymany VolunteerSkill z bazy
|
||||||
|
VolunteerSkill newVs = dto.ToVolunteerSkillEntity(user.UserId);
|
||||||
|
|
||||||
|
await context.VolunteerSkills.Where(v => v.SkillId == dto.Skill)
|
||||||
|
.ExecuteDeleteAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Nie ma - (ta para UserId <-> SkillId nie istnieje w bazie). Zwracamy błąd.
|
||||||
|
return Results.Json(new { message = "You don't have this skill" }, statusCode: 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Json(new { message = "Skill deleted successfully!" }, statusCode: 201);
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/auth/skills
|
||||||
|
group.MapGet("/skills", async (HttpContext httpContext, ApplicationDbContext context, GeneralUseHelpers guh) =>
|
||||||
|
{
|
||||||
|
// Uzyskaj użytkownika z tokenu
|
||||||
|
Token? token = await guh.GetTokenFromHTTPContext(httpContext);
|
||||||
|
User? user = await guh.GetUserFromToken(token);
|
||||||
|
|
||||||
|
// Sprawdź, czy użytkownik istnieje i nie jest organizacją
|
||||||
|
if (user == null || user.IsOrganisation)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "Unauthorized" }, statusCode: 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pobierz skille wolontariusza
|
||||||
|
var skills = await context.VolunteerSkills
|
||||||
|
.Where(vs => vs.UserId == user.UserId)
|
||||||
|
.Include(vs => vs.Skill)
|
||||||
|
.Select(vs => new
|
||||||
|
{
|
||||||
|
skillId = vs.Skill!.SkillId,
|
||||||
|
skillName = vs.Skill.Name
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Json(skills);
|
||||||
|
});
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
static string HashPasswordSHA512(string password)
|
||||||
|
{
|
||||||
|
using (var sha512 = SHA512.Create())
|
||||||
|
{
|
||||||
|
byte[] bytes = Encoding.ASCII.GetBytes(password);
|
||||||
|
byte[] hash = sha512.ComputeHash(bytes);
|
||||||
|
string hashstring = BitConverter.ToString(hash).Replace("-", "").ToLower();
|
||||||
|
|
||||||
|
return hashstring;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
154
WebApp/Endpoints/EventRegistrationEndpoints.cs
Normal file
154
WebApp/Endpoints/EventRegistrationEndpoints.cs
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Http.HttpResults;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using WebApp.Data;
|
||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
using WebApp.Mapping;
|
||||||
|
|
||||||
|
namespace WebApp.Endpoints
|
||||||
|
{
|
||||||
|
public static class EventsRegistrationEndpoints
|
||||||
|
{
|
||||||
|
const string GetEventEndpointRegistrationName = "GetEventRegistration";
|
||||||
|
|
||||||
|
public static RouteGroupBuilder MapEventsRegistrationEndpoints(this WebApplication app)
|
||||||
|
{
|
||||||
|
var group = app.MapGroup("api/events")
|
||||||
|
.WithParameterValidation();
|
||||||
|
|
||||||
|
// POST /api/events/join/{id}
|
||||||
|
group.MapPost("/join/{id}",
|
||||||
|
async (int id, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Event? Eve = await dbContext.Events.FindAsync(id);
|
||||||
|
if (Eve is null)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Event not found." });
|
||||||
|
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
User? user = await guhf.GetUserFromToken(token);
|
||||||
|
|
||||||
|
if (user is null || user.IsOrganisation)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Unauthorized or organisations cannot register for events." });
|
||||||
|
|
||||||
|
if (await dbContext.EventRegistrations.AnyAsync(er => er.UserId == user.UserId && er.EventId == id))
|
||||||
|
return Results.Json(new { success = false, error_msg = "You are already registered for this event." });
|
||||||
|
|
||||||
|
if (Eve.EventDate < DateTime.UtcNow)
|
||||||
|
return Results.Json(new { success = false, error_msg = "This event has already ended." });
|
||||||
|
|
||||||
|
EventRegistration registration = new EventRegistration
|
||||||
|
{
|
||||||
|
UserId = user.UserId,
|
||||||
|
EventId = id,
|
||||||
|
RegisteredAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
dbContext.EventRegistrations.Add(registration);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Results.Json(new { success = true });
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/events/leave/{id}
|
||||||
|
group.MapPost("/leave/{id}",
|
||||||
|
async (int id, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Event? Eve = await dbContext.Events.FindAsync(id);
|
||||||
|
if (Eve is null)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Event not found." });
|
||||||
|
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
User? user = await guhf.GetUserFromToken(token);
|
||||||
|
|
||||||
|
if (user is null)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Unauthorized." });
|
||||||
|
|
||||||
|
if (!await dbContext.EventRegistrations.AnyAsync(er => er.UserId == user.UserId && er.EventId == id))
|
||||||
|
return Results.Json(new { success = false, error_msg = "You are not registered for this event." });
|
||||||
|
|
||||||
|
if (Eve.EventDate < DateTime.UtcNow)
|
||||||
|
return Results.Json(new { success = false, error_msg = "This event has already ended." });
|
||||||
|
|
||||||
|
EventRegistration? registration = await dbContext.EventRegistrations
|
||||||
|
.FirstOrDefaultAsync(er => er.UserId == user.UserId && er.EventId == id);
|
||||||
|
|
||||||
|
dbContext.EventRegistrations.Remove(registration);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Results.Json(new { success = true });
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/events/registrations/{id}
|
||||||
|
group.MapGet("/registrations/{id}",
|
||||||
|
async (int id, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Event? Eve = await dbContext.Events.FindAsync(id);
|
||||||
|
if (Eve is null)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Event not found." });
|
||||||
|
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
if (org is null || org.OrganisationId != Eve.OrganisationId)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Unauthorized." });
|
||||||
|
|
||||||
|
var registrations = await dbContext.EventRegistrations
|
||||||
|
.Where(er => er.EventId == id)
|
||||||
|
.Select(er => er.ToEventRegistrationDto())
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Json(new
|
||||||
|
{
|
||||||
|
success = true,
|
||||||
|
registrations
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /api/events/remove/{id}/{userId}
|
||||||
|
group.MapPost("/remove/{id}/{userId}",
|
||||||
|
async (int id, int userId, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Event? Eve = await dbContext.Events.FindAsync(id);
|
||||||
|
if (Eve is null)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Event not found." });
|
||||||
|
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
if (org is null || org.OrganisationId != Eve.OrganisationId)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Unauthorized." });
|
||||||
|
|
||||||
|
EventRegistration? registration = await dbContext.EventRegistrations
|
||||||
|
.FirstOrDefaultAsync(er => er.UserId == userId && er.EventId == id);
|
||||||
|
|
||||||
|
if (registration is null)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Registration not found." });
|
||||||
|
|
||||||
|
dbContext.EventRegistrations.Remove(registration);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Results.Json(new { success = true });
|
||||||
|
});
|
||||||
|
group.MapGet("/registered",
|
||||||
|
async (ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
User? user = await guhf.GetUserFromToken(token);
|
||||||
|
|
||||||
|
if (user is null || user.IsOrganisation)
|
||||||
|
return Results.Json(new { success = false, error_msg = "Unauthorized or organisations cannot register." });
|
||||||
|
|
||||||
|
var events = await dbContext.EventRegistrations
|
||||||
|
.Where(r => r.UserId == user.UserId)
|
||||||
|
.Select(r => new {
|
||||||
|
r.Event.EventId,
|
||||||
|
r.Event.Title,
|
||||||
|
r.Event.EventDate
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Json(events);
|
||||||
|
});
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
303
WebApp/Endpoints/EventsEndpoints.cs
Normal file
303
WebApp/Endpoints/EventsEndpoints.cs
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Runtime.Intrinsics.Arm;
|
||||||
|
using WebApp.Data;
|
||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
using WebApp.Mapping;
|
||||||
|
|
||||||
|
namespace WebApp.Endpoints
|
||||||
|
{
|
||||||
|
public static class EventsEndpoints
|
||||||
|
{
|
||||||
|
const string GetEventEndpointName = "GetEvent";
|
||||||
|
|
||||||
|
public static RouteGroupBuilder MapEventsEndpoints(this WebApplication app)
|
||||||
|
{
|
||||||
|
var group = app.MapGroup("api/events")
|
||||||
|
.WithParameterValidation();
|
||||||
|
|
||||||
|
// GET /events
|
||||||
|
group.MapGet("/",
|
||||||
|
async (ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
// Sprawdź, czy lista powinna by posortowana rosnąco. Domyślnie: malejąco.
|
||||||
|
var sort = httpContext.Request.Query["sort"].ToString().ToUpper();
|
||||||
|
|
||||||
|
// Sprawdź, czy token należy do organizacji, a jeżeli tak, to do której.
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
|
||||||
|
List<EventSummaryDto> result = await guhf.BuildSummaryEventsDto(
|
||||||
|
dbContext,
|
||||||
|
org,
|
||||||
|
(sort == "ASC")
|
||||||
|
);
|
||||||
|
|
||||||
|
return Results.Ok(result);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// GET /events/1
|
||||||
|
group.MapGet("/{id}",
|
||||||
|
async (int id, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
Event? Eve = await dbContext
|
||||||
|
.Events
|
||||||
|
.Include(e => e.Organisation)
|
||||||
|
.FirstOrDefaultAsync(e => e.EventId == id);
|
||||||
|
if (Eve is null) return Results.NotFound();
|
||||||
|
|
||||||
|
// Sprawdź, czy token należy do organizacji, a jeżeli tak, to do której.
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
|
||||||
|
// Jeśli token należy do organizacji, która utworzyła to wydarzenie,
|
||||||
|
// to zwróć także EventRegistrations. W przeciwnym razie niech będzie to
|
||||||
|
// puste pole.
|
||||||
|
List<EventDetailsDto> result = await guhf.BuildDetailedEventsDto(
|
||||||
|
dbContext,
|
||||||
|
org
|
||||||
|
);
|
||||||
|
|
||||||
|
return Results.Ok(result.FirstOrDefault(e => e.EventId == id));
|
||||||
|
})
|
||||||
|
.WithName(GetEventEndpointName);
|
||||||
|
|
||||||
|
// POST /events
|
||||||
|
group.MapPost("/",
|
||||||
|
async (EventCreateDto newEvent, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
// Uzyskaj organizację z tokenu
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
if (org is null) return Results.Unauthorized();
|
||||||
|
|
||||||
|
// dodajemy id organizacji z tokenu
|
||||||
|
Event Eve = newEvent.ToEntity();
|
||||||
|
Eve.OrganisationId = org.OrganisationId;
|
||||||
|
|
||||||
|
dbContext.Events.Add(Eve);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Results.CreatedAtRoute(
|
||||||
|
GetEventEndpointName,
|
||||||
|
new { id = Eve.EventId },
|
||||||
|
Eve.ToEventDetailsDto()); //EventDetailsDto
|
||||||
|
});
|
||||||
|
|
||||||
|
// PUT /events/1
|
||||||
|
group.MapPut("/{id}",
|
||||||
|
async (int id, EventUpdateDto updatedEvent, ApplicationDbContext dbContext, GeneralUseHelpers guhf, HttpContext httpContext) =>
|
||||||
|
{
|
||||||
|
// Uzyskaj organizację z tokenu
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
if (org is null) return Results.Unauthorized();
|
||||||
|
|
||||||
|
Console.Write(org.OrganisationId);
|
||||||
|
var existingEvent = await dbContext.Events.FindAsync(id);
|
||||||
|
if (existingEvent is null)
|
||||||
|
{
|
||||||
|
return Results.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sprawdź, czy organizacja ma prawo
|
||||||
|
// do zmodyfikowania tego (EventId = id) eventu.
|
||||||
|
if (org.OrganisationId != existingEvent.OrganisationId) return Results.StatusCode(403);
|
||||||
|
|
||||||
|
var originalOrgId = existingEvent.OrganisationId;
|
||||||
|
dbContext.Entry(existingEvent)
|
||||||
|
.CurrentValues
|
||||||
|
.SetValues(updatedEvent.ToEntity(id));
|
||||||
|
existingEvent.OrganisationId = originalOrgId;
|
||||||
|
|
||||||
|
dbContext.Entry(existingEvent)
|
||||||
|
.Collection(Eve => Eve.EventRegistrations)
|
||||||
|
.IsModified = false;
|
||||||
|
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Results.NoContent();
|
||||||
|
});
|
||||||
|
|
||||||
|
// DELETE /events/1
|
||||||
|
group.MapDelete("/{id}",
|
||||||
|
async (int id, ApplicationDbContext dbContext, GeneralUseHelpers guhf, HttpContext httpContext) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
// Uzyskaj organizację z tokenu
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
if (org is null) return Results.Unauthorized();
|
||||||
|
|
||||||
|
// Sprawdź, czy organizacja ma prawo
|
||||||
|
// do usunięcia tego (EventId = id) eventu.
|
||||||
|
Event? Eve = await dbContext.Events.FindAsync(id);
|
||||||
|
if (Eve is null) return Results.NotFound();
|
||||||
|
else if (org.OrganisationId != Eve.OrganisationId) return Results.StatusCode(403);
|
||||||
|
|
||||||
|
await dbContext.Events
|
||||||
|
.Where(Eve => Eve.EventId == id)
|
||||||
|
.ExecuteDeleteAsync();
|
||||||
|
|
||||||
|
return Results.NoContent();
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /events/search
|
||||||
|
group.MapPost("/search/",
|
||||||
|
async (EventSearchDto query, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
// Uzyskaj organizację z tokenu
|
||||||
|
var sort = httpContext.Request.Query["sort"].ToString().ToUpper();
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
List<EventSummaryDto> SearchCandidates = await guhf.BuildSummaryEventsDto(dbContext, org, sort == "ASC");
|
||||||
|
List<EventSummaryDto> SearchResults = [];
|
||||||
|
|
||||||
|
|
||||||
|
foreach(EventSummaryDto e in SearchCandidates)
|
||||||
|
{
|
||||||
|
bool matchFound = true;
|
||||||
|
// Logika wyszukiwania
|
||||||
|
// Sprawdź wszystkie pola z EventSearchDto, np.
|
||||||
|
if (query.OrganisationId is not null)
|
||||||
|
{
|
||||||
|
// Sprawdź, czy Event należy do query.OrganisationId.
|
||||||
|
if (e.OrganisationId != query.OrganisationId) matchFound = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.TitleOrDescription is not null)
|
||||||
|
{
|
||||||
|
var TitleMatch = guhf.SearchString(e.Title, query.TitleOrDescription);
|
||||||
|
var DescMatch = guhf.SearchString(e.Description, query.TitleOrDescription);
|
||||||
|
if (!TitleMatch && !DescMatch) matchFound = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Zakres dat do wyszukiwania
|
||||||
|
if (query.EventDateFrom is not null)
|
||||||
|
{
|
||||||
|
if (e.EventDate < query.EventDateFrom) matchFound = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (query.EventDateTo is not null)
|
||||||
|
{
|
||||||
|
if (e.EventDate > query.EventDateTo) matchFound = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// Jeśli Event jest tym, czego szuka użytkownik,
|
||||||
|
// dodaj go do listy SearchResults.
|
||||||
|
//
|
||||||
|
// Uwaga! Zanim to zrobisz, sprawdź, czy użytkownik
|
||||||
|
// jest twórcą danego wydarzenia! Jeżeli nim nie jest,
|
||||||
|
// wyzeruj EventRegistrations!
|
||||||
|
//if (org is null || e.OrganisationId != org.OrganisationId)
|
||||||
|
//{
|
||||||
|
// e.EventRegistrations.Clear();
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (matchFound) SearchResults.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Ok(SearchResults);
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /events/1/add_skill
|
||||||
|
group.MapPost("/{id}/add_skill/",
|
||||||
|
async (int id, SingleSkillDto dto, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Event? Eve = await dbContext.Events.FindAsync(id);
|
||||||
|
|
||||||
|
if (Eve is null) return Results.Json(new { message = "Event not found" }, statusCode: 404);
|
||||||
|
|
||||||
|
// Sprawdź, czy token należy do organizacji, a jeżeli tak, to do której.
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
|
||||||
|
// Jeśli token należy do organizacji, która utworzyła to wydarzenie,
|
||||||
|
// to zwróć także EventRegistrations. W przeciwnym razie usuń to pole
|
||||||
|
// przed jego wysłaniem!
|
||||||
|
if (org is null || org.OrganisationId != Eve.OrganisationId) return Results.Unauthorized();
|
||||||
|
|
||||||
|
// Szukamy skilla w bazie o ID takim, jak w otrzymanym DTO
|
||||||
|
Skill? skill = await dbContext.Skills.FindAsync(dto.Skill);
|
||||||
|
if (skill is null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "Skill not found" }, statusCode: 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sprawdzamy, czy to wydarzenie nie ma już takiego skilla. Jeżeli ma, nie ma sensu dodawać go kilkukrotnie.
|
||||||
|
EventSkill? es = await dbContext.EventSkills.FirstOrDefaultAsync(e => e.EventId == id && e.SkillId == dto.Skill);
|
||||||
|
if (es is null)
|
||||||
|
{
|
||||||
|
// Nie ma - zatem musimy dodać nowy EventSkill do bazy
|
||||||
|
EventSkill newEs = dto.ToEventSkillEntity(Eve.EventId);
|
||||||
|
dbContext.EventSkills.Add(newEs);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Ma - (ta para EventId <-> SkillId już istnieje w bazie); ten Event posiada już ten skill
|
||||||
|
return Results.Json(new { message = "Skill already assinged to this event!" }, statusCode: 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Json(new { message = "Skill added to event successfully!" }, statusCode: 201);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /events/1/renive_skill
|
||||||
|
group.MapPost("/{id}/remove_skill/",
|
||||||
|
async (int id, SingleSkillDto dto, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Event? Eve = await dbContext.Events.FindAsync(id);
|
||||||
|
|
||||||
|
if (Eve is null) return Results.Json(new { message = "Event not found" }, statusCode: 404);
|
||||||
|
|
||||||
|
// Sprawdź, czy token należy do organizacji, a jeżeli tak, to do której.
|
||||||
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
|
||||||
|
// Jeśli token należy do organizacji, która utworzyła to wydarzenie,
|
||||||
|
// to zwróć także EventRegistrations. W przeciwnym razie usuń to pole
|
||||||
|
// przed jego wysłaniem!
|
||||||
|
if (org is null || org.OrganisationId != Eve.OrganisationId) return Results.Unauthorized();
|
||||||
|
|
||||||
|
// Szukamy skilla w bazie o ID takim, jak w otrzymanym DTO
|
||||||
|
Skill? skill = await dbContext.Skills.FindAsync(dto.Skill);
|
||||||
|
if (skill is null)
|
||||||
|
{
|
||||||
|
return Results.Json(new { message = "Skill not found" }, statusCode: 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sprawdzamy, czy to wydarzenie nie ma już takiego skilla. Jeżeli nie ma, to nie ma sensu kasować czegoś, czego nie ma.
|
||||||
|
EventSkill? es = await dbContext.EventSkills.FirstOrDefaultAsync(e => e.EventId == id && e.SkillId == dto.Skill);
|
||||||
|
if (es is not null)
|
||||||
|
{
|
||||||
|
// Ma - zatem musimy usunąć ten EventSkill z bazy
|
||||||
|
await dbContext.EventSkills.Where(e => e.SkillId == dto.Skill)
|
||||||
|
.ExecuteDeleteAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Nie ma - (ta para EventId <-> SkillId nie istnieje w bazie); ten Event nie posiada tego skill'a
|
||||||
|
return Results.Json(new { message = "This skill isn't assinged to this event!" }, statusCode: 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Json(new { message = "Skill removed from event successfully!" }, statusCode: 201);
|
||||||
|
});
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
201
WebApp/Endpoints/GeneralUseHelperFunctions.cs
Normal file
201
WebApp/Endpoints/GeneralUseHelperFunctions.cs
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WebApp.Data;
|
||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.Endpoints;
|
||||||
|
|
||||||
|
public class GeneralUseHelpers(ApplicationDbContext context)
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly ApplicationDbContext _context = context;
|
||||||
|
|
||||||
|
async public Task<Token?> FindTokenFromString(string token_str)
|
||||||
|
{
|
||||||
|
// foreach (Token t in _context.Tokens) if (t.Value == token) return t;
|
||||||
|
// return null;
|
||||||
|
return await _context.Tokens.FirstOrDefaultAsync(t => t.Value == token_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
async public Task<User?> GetUserFromToken(Token? t)
|
||||||
|
{
|
||||||
|
// Zwróci null, gdy nie znaleziono użytkownika
|
||||||
|
if (t is null) return null;
|
||||||
|
User? user = await _context.WebUsers.FindAsync(t.UserId);
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
async public Task<Organisation?> GetOrganisationFromToken(Token? t)
|
||||||
|
{
|
||||||
|
User? user = await GetUserFromToken(t);
|
||||||
|
if (user is not null && user.IsOrganisation)
|
||||||
|
{
|
||||||
|
Organisation? org = await _context.Organisations.FirstOrDefaultAsync(o => o.UserId == t!.UserId);
|
||||||
|
|
||||||
|
return org;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async public Task<Organisation?> GetOrganisationFromId(int id)
|
||||||
|
{
|
||||||
|
Organisation? org = await _context.Organisations.FirstOrDefaultAsync(o => o.OrganisationId == id);
|
||||||
|
return org;
|
||||||
|
}
|
||||||
|
|
||||||
|
async public Task<Organisation?> GetOrganisationFromUserId(int userId)
|
||||||
|
{
|
||||||
|
Organisation? org = await _context.Organisations.FirstOrDefaultAsync(o => o.UserId == userId);
|
||||||
|
return org;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? GetTokenStrFromHTTPContext(HttpContext httpContext)
|
||||||
|
{
|
||||||
|
var cookies = httpContext.Request.Cookies;
|
||||||
|
string? token = cookies["token"];
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
async public Task<Token?> GetTokenFromHTTPContext(HttpContext httpContext)
|
||||||
|
{
|
||||||
|
var cookies = httpContext.Request.Cookies;
|
||||||
|
string? token_str = cookies["token"];
|
||||||
|
if (token_str is not null)
|
||||||
|
{
|
||||||
|
Token? token = await FindTokenFromString(token_str);
|
||||||
|
if (token is not null) return token;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Token> CreateNewToken(int userId)
|
||||||
|
{
|
||||||
|
var token = new Token
|
||||||
|
{
|
||||||
|
UserId = userId,
|
||||||
|
Value = "lah-" + Guid.NewGuid().ToString(),
|
||||||
|
ValidUntil = DateTime.UtcNow.AddDays(7)
|
||||||
|
};
|
||||||
|
|
||||||
|
_context.Tokens.Add(token);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteToken(Token token)
|
||||||
|
{
|
||||||
|
_context.Tokens.Remove(token);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SearchString(string? text, string searchTerm)
|
||||||
|
{
|
||||||
|
// Zwraca fałsz jeśli tekst jest pusty.
|
||||||
|
// (Brak tekstu nie wpływa na wynik wyszukiwania).
|
||||||
|
if (text is null) return false;
|
||||||
|
|
||||||
|
// Zamienia tekst na słowa
|
||||||
|
var words = text.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
// Sprawdza, czy któreś ze słów pasuje (nawet częściowo) do searchTerm
|
||||||
|
return words.Any(word => word.Contains(searchTerm, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<EventDetailsDto>> BuildDetailedEventsDto(
|
||||||
|
ApplicationDbContext context,
|
||||||
|
Organisation? org,
|
||||||
|
bool sortAscending = false)
|
||||||
|
{
|
||||||
|
// https://khalidabuhakmeh.com/ef-core-and-aspnet-core-cycle-issue-and-solution
|
||||||
|
|
||||||
|
// Jeśli token należy do organizacji, która utworzyła to wydarzenie,
|
||||||
|
// to zwróć także EventRegistrations. W przeciwnym razie niech będzie to
|
||||||
|
// puste pole.
|
||||||
|
|
||||||
|
IQueryable<EventDetailsDto> result_iq = context
|
||||||
|
.Events
|
||||||
|
.Select(e => new EventDetailsDto
|
||||||
|
{
|
||||||
|
EventId = e.EventId,
|
||||||
|
OrganisationId = e.OrganisationId,
|
||||||
|
OrganisationName = e.Organisation!.Name,
|
||||||
|
Title = e.Title,
|
||||||
|
Description = e.Description ?? "",
|
||||||
|
ImageURL = e.ImageURL,
|
||||||
|
Location = e.Location,
|
||||||
|
EventDate = e.EventDate,
|
||||||
|
EventSkills = e
|
||||||
|
.EventSkills
|
||||||
|
.Select(es => new SkillSummaryDto
|
||||||
|
{
|
||||||
|
SkillId = es.SkillId,
|
||||||
|
SkillName = es.Skill!.Name
|
||||||
|
}).ToList(),
|
||||||
|
EventRegistrations = e.Organisation == org ?
|
||||||
|
e.EventRegistrations
|
||||||
|
.Select(er => new EventRegistrationDto
|
||||||
|
{
|
||||||
|
EventId = er.EventId,
|
||||||
|
UserId = er.UserId,
|
||||||
|
UserName = er.User!.FirstName + " " + er.User.LastName,
|
||||||
|
RegisteredAt = er.RegisteredAt
|
||||||
|
}).ToList() : null!
|
||||||
|
});
|
||||||
|
|
||||||
|
if (sortAscending) result_iq = result_iq.OrderBy(e => e.EventId);
|
||||||
|
else result_iq = result_iq.OrderByDescending(e => e.EventId);
|
||||||
|
|
||||||
|
|
||||||
|
return await result_iq.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<EventSummaryDto>> BuildSummaryEventsDto(
|
||||||
|
ApplicationDbContext context,
|
||||||
|
Organisation? org,
|
||||||
|
bool sortAscending = false)
|
||||||
|
{
|
||||||
|
// https://khalidabuhakmeh.com/ef-core-and-aspnet-core-cycle-issue-and-solution
|
||||||
|
|
||||||
|
// Jeśli token należy do organizacji, która utworzyła to wydarzenie,
|
||||||
|
// to zwróć także EventRegistrations. W przeciwnym razie niech będzie to
|
||||||
|
// puste pole.
|
||||||
|
IQueryable<EventSummaryDto> result_iq = context
|
||||||
|
.Events
|
||||||
|
.Select(e => new EventSummaryDto
|
||||||
|
{
|
||||||
|
EventId = e.EventId,
|
||||||
|
OrganisationId = e.OrganisationId,
|
||||||
|
Organisation = e.Organisation!.Name,
|
||||||
|
Title = e.Title,
|
||||||
|
Description = e.Description ?? "",
|
||||||
|
ImageURL = e.ImageURL,
|
||||||
|
Location = e.Location,
|
||||||
|
EventDate = e.EventDate,
|
||||||
|
EventSkills = e
|
||||||
|
.EventSkills
|
||||||
|
.Select(es => new SkillSummaryDto
|
||||||
|
{
|
||||||
|
SkillId = es.SkillId,
|
||||||
|
SkillName = es.Skill!.Name
|
||||||
|
}).ToList(),
|
||||||
|
EventRegistrations = e.Organisation == org ?
|
||||||
|
e.EventRegistrations
|
||||||
|
.Select(er => new EventRegistrationDto
|
||||||
|
{
|
||||||
|
EventId = er.EventId,
|
||||||
|
UserId = er.UserId,
|
||||||
|
UserName = er.User!.FirstName + " " + er.User.LastName,
|
||||||
|
RegisteredAt = er.RegisteredAt
|
||||||
|
}).ToList() : null!
|
||||||
|
});
|
||||||
|
|
||||||
|
if (sortAscending) result_iq = result_iq.OrderBy(e => e.EventId);
|
||||||
|
else result_iq = result_iq.OrderByDescending(e => e.EventId);
|
||||||
|
|
||||||
|
return await result_iq.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
113
WebApp/Endpoints/MessagesEndpoints.cs
Normal file
113
WebApp/Endpoints/MessagesEndpoints.cs
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WebApp.Data;
|
||||||
|
using WebApp.Entities;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace WebApp.Endpoints
|
||||||
|
{
|
||||||
|
public static class MessagesEndpoints
|
||||||
|
{
|
||||||
|
public static RouteGroupBuilder MapMessagesEndpoints(this WebApplication app)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Registering MessagesEndpoints...");
|
||||||
|
|
||||||
|
var group = app.MapGroup("api/messages");
|
||||||
|
|
||||||
|
// Test endpoint to verify registration
|
||||||
|
group.MapGet("/test", () => Results.Ok("Messages endpoint is working"));
|
||||||
|
|
||||||
|
// POST /api/messages/sendFromOrgToVolunteers
|
||||||
|
group.MapPost("/sendFromOrgToVolunteers",
|
||||||
|
async (SendMessageRequest request, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hit sendFromOrgToVolunteers endpoint.");
|
||||||
|
|
||||||
|
// Get token and organization
|
||||||
|
var token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
var org = await guhf.GetOrganisationFromToken(token);
|
||||||
|
if (org == null)
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
// Verify event belongs to org
|
||||||
|
var ev = await dbContext.Events.FindAsync(request.EventId);
|
||||||
|
if (ev == null || ev.OrganisationId != org.OrganisationId)
|
||||||
|
return Results.BadRequest("Event not found or unauthorized.");
|
||||||
|
|
||||||
|
// Get all volunteers (non-org users)
|
||||||
|
var volunteers = await dbContext.WebUsers
|
||||||
|
.Where(u => !u.IsOrganisation)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Create message entities
|
||||||
|
var messages = volunteers.Select(v => new Message
|
||||||
|
{
|
||||||
|
EventType = request.EventId,
|
||||||
|
VolunteerId = v.UserId,
|
||||||
|
OrganizationId = org.OrganisationId,
|
||||||
|
IsMsgFromVolunteer = false,
|
||||||
|
IsoDate = DateTime.UtcNow,
|
||||||
|
Content = request.Content
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
dbContext.Messages.AddRange(messages);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Results.Ok();
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /api/messages/my - get messages for current user
|
||||||
|
group.MapGet("/my",
|
||||||
|
async (ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
var token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
var user = await guhf.GetUserFromToken(token);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
var messages = await dbContext.Messages
|
||||||
|
.Where(m =>
|
||||||
|
(user.IsOrganisation && m.OrganizationId == user.UserId) ||
|
||||||
|
(!user.IsOrganisation && m.VolunteerId == user.UserId))
|
||||||
|
.OrderByDescending(m => m.IsoDate)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Results.Ok(messages);
|
||||||
|
});
|
||||||
|
// DELETE /api/messages/{id}
|
||||||
|
group.MapDelete("/{id:int}", async (int id, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
var token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
|
var user = await guhf.GetUserFromToken(token);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
return Results.Unauthorized();
|
||||||
|
|
||||||
|
var message = await dbContext.Messages.FindAsync(id);
|
||||||
|
if (message == null)
|
||||||
|
return Results.NotFound();
|
||||||
|
|
||||||
|
// Only allow deleting if user is either the organization or volunteer in the message
|
||||||
|
if (user.IsOrganisation && message.OrganizationId != user.UserId)
|
||||||
|
return Results.Forbid();
|
||||||
|
|
||||||
|
if (!user.IsOrganisation && message.VolunteerId != user.UserId)
|
||||||
|
return Results.Forbid();
|
||||||
|
|
||||||
|
dbContext.Messages.Remove(message);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Results.NoContent();
|
||||||
|
});
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SendMessageRequest
|
||||||
|
{
|
||||||
|
public int EventId { get; set; }
|
||||||
|
public string Content { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
42
WebApp/Endpoints/OrganizationsEndpoints.cs
Normal file
42
WebApp/Endpoints/OrganizationsEndpoints.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WebApp.Data;
|
||||||
|
using WebApp.Entities;
|
||||||
|
using WebApp.Mapping;
|
||||||
|
|
||||||
|
|
||||||
|
namespace WebApp.Endpoints;
|
||||||
|
|
||||||
|
public static class OrganizationsEndpoints
|
||||||
|
{
|
||||||
|
const string GetOrganizationEndpointName = "GetOrganization";
|
||||||
|
|
||||||
|
public static RouteGroupBuilder MapOrganizationsEndpoints(this WebApplication app)
|
||||||
|
{
|
||||||
|
var group = app.MapGroup("api/organizations")
|
||||||
|
.WithParameterValidation();
|
||||||
|
|
||||||
|
// GET /organizations
|
||||||
|
group.MapGet("/",
|
||||||
|
async (ApplicationDbContext dbContext, HttpContext httpContext) =>
|
||||||
|
await dbContext.Organisations
|
||||||
|
//.Include(Eve => Eve.Organisation)
|
||||||
|
.OrderByDescending(Org => Org.OrganisationId)
|
||||||
|
.Select(Org => Org.ToOrgSummaryDto()) //OrgSummaryDto
|
||||||
|
.AsNoTracking()
|
||||||
|
.ToListAsync());
|
||||||
|
|
||||||
|
// GET /organizations/1
|
||||||
|
group.MapGet("/{id}",
|
||||||
|
async (int id, ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||||
|
{
|
||||||
|
Organisation? Org = await dbContext.Organisations.FindAsync(id);
|
||||||
|
|
||||||
|
if (Org is null) return Results.NotFound();
|
||||||
|
|
||||||
|
return Results.Ok(Org.ToOrgSummaryDto()); //OrgSummaryDto
|
||||||
|
})
|
||||||
|
.WithName(GetOrganizationEndpointName);
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
WebApp/Endpoints/SkillsEndpoints.cs
Normal file
26
WebApp/Endpoints/SkillsEndpoints.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WebApp.Data;
|
||||||
|
using WebApp.Mapping;
|
||||||
|
|
||||||
|
namespace WebApp.Endpoints;
|
||||||
|
|
||||||
|
public static class SkillsEndpoints
|
||||||
|
{
|
||||||
|
const string GetSkillEndpointName = "GetSkill";
|
||||||
|
|
||||||
|
public static RouteGroupBuilder MapSkillsEndpoints(this WebApplication app)
|
||||||
|
{
|
||||||
|
var group = app.MapGroup("api/skills").WithParameterValidation();
|
||||||
|
|
||||||
|
// GET /skills
|
||||||
|
group.MapGet("/",
|
||||||
|
async (ApplicationDbContext dbContext) =>
|
||||||
|
await dbContext.Skills
|
||||||
|
.OrderBy(Sk => Sk.SkillId)
|
||||||
|
.Select(Sk => Sk.ToSkillSummaryDto()) // SkillSummaryDto
|
||||||
|
.AsNoTracking()
|
||||||
|
.ToListAsync());
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace WebApp.Entities
|
namespace WebApp.Entities
|
||||||
{
|
{
|
||||||
public class Event
|
public class Event
|
||||||
{
|
{
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
public int OrganisationId { get; set; }
|
public int OrganisationId { get; set; }
|
||||||
public required string Title { get; set; }
|
public required string Title { get; set; }
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
|
public string? ImageURL { get; set; }
|
||||||
public required string Location { get; set; }
|
public required string Location { get; set; }
|
||||||
public required DateTime EventDate { get; set; }
|
public required DateTime EventDate { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
public class EventRegistration
|
public class EventRegistration
|
||||||
{
|
{
|
||||||
public int EventId { get; set; }
|
public int EventId { get; set; }
|
||||||
public required string UserId { get; set; }
|
public required int UserId { get; set; }
|
||||||
public DateTime RegisteredAt { get; set; } = DateTime.UtcNow;
|
public DateTime RegisteredAt { get; set; } = DateTime.UtcNow;
|
||||||
public Event? Event { get; set; }
|
public Event? Event { get; set; }
|
||||||
public User? User { get; set; }
|
public User? User { get; set; }
|
||||||
|
|||||||
13
WebApp/Entities/Message.cs
Normal file
13
WebApp/Entities/Message.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace WebApp.Entities
|
||||||
|
{
|
||||||
|
public class Message
|
||||||
|
{
|
||||||
|
public int MessageId { get; set; }
|
||||||
|
public int EventType { get; set; }
|
||||||
|
public int VolunteerId { get; set; }
|
||||||
|
public int OrganizationId { get; set; }
|
||||||
|
public bool IsMsgFromVolunteer { get; set; }
|
||||||
|
public DateTime IsoDate { get; set; }
|
||||||
|
public string? Content { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
9
WebApp/Entities/MessageActivity.cs
Normal file
9
WebApp/Entities/MessageActivity.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace WebApp.Entities
|
||||||
|
{
|
||||||
|
public class MessageActivity
|
||||||
|
{
|
||||||
|
public int Recipient { get; set; }
|
||||||
|
public int Sender { get; set; }
|
||||||
|
public DateTime RecipientLastActive { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
public class Organisation
|
public class Organisation
|
||||||
{
|
{
|
||||||
public int OrganisationId { get; set; }
|
public int OrganisationId { get; set; }
|
||||||
public required string UserId { get; set; }
|
public required int UserId { get; set; }
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
public string? Website { get; set; }
|
public string? Website { get; set; }
|
||||||
|
|||||||
10
WebApp/Entities/Token.cs
Normal file
10
WebApp/Entities/Token.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace WebApp.Entities
|
||||||
|
{
|
||||||
|
public class Token
|
||||||
|
{
|
||||||
|
public int TokenId { get; set; }
|
||||||
|
public required int UserId { get; set; }
|
||||||
|
public required DateTime ValidUntil { get; set; }
|
||||||
|
public string? Value { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace WebApp.Entities
|
namespace WebApp.Entities
|
||||||
{
|
{
|
||||||
public class User : IdentityUser
|
public class User //: IdentityUser
|
||||||
{
|
{
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? Password { get; set; }
|
||||||
|
|
||||||
public required string FirstName { get; set; }
|
public required string FirstName { get; set; }
|
||||||
public required string LastName { get; set; }
|
public required string LastName { get; set; }
|
||||||
public bool IsOrganisation { get; set; } = false;
|
public bool IsOrganisation { get; set; } = false;
|
||||||
@@ -11,5 +16,6 @@ namespace WebApp.Entities
|
|||||||
|
|
||||||
public ICollection<VolunteerSkill> VolunteerSkills { get; set; } = new List<VolunteerSkill>();
|
public ICollection<VolunteerSkill> VolunteerSkills { get; set; } = new List<VolunteerSkill>();
|
||||||
public ICollection<EventRegistration> EventRegistrations { get; set; } = new List<EventRegistration>();
|
public ICollection<EventRegistration> EventRegistrations { get; set; } = new List<EventRegistration>();
|
||||||
|
public ICollection<Token> Tokens { get; set; } = new List<Token>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class VolunteerSkill
|
public class VolunteerSkill
|
||||||
{
|
{
|
||||||
public required string UserId { get; set; }
|
public required int UserId { get; set; }
|
||||||
public int SkillId { get; set; }
|
public int SkillId { get; set; }
|
||||||
|
|
||||||
public User? User { get; set; }
|
public User? User { get; set; }
|
||||||
|
|||||||
132
WebApp/Mapping/EventMapping.cs
Normal file
132
WebApp/Mapping/EventMapping.cs
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.Mapping;
|
||||||
|
|
||||||
|
public static class EventMapping
|
||||||
|
{
|
||||||
|
public static Event ToEntity(this EventCreateDto ECDto)
|
||||||
|
{
|
||||||
|
return new Event()
|
||||||
|
{
|
||||||
|
Title = ECDto.Title,
|
||||||
|
Description = ECDto.Description,
|
||||||
|
ImageURL = ECDto.ImageURL,
|
||||||
|
Location = ECDto.Location,
|
||||||
|
EventDate = DateTime.SpecifyKind(ECDto.EventDate!.Value, DateTimeKind.Utc),
|
||||||
|
EventSkills = ECDto.EventSkills,
|
||||||
|
EventRegistrations = []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Event ToEntity(this EventUpdateDto EUDto, int id)
|
||||||
|
{
|
||||||
|
return new Event()
|
||||||
|
{
|
||||||
|
EventId = id,
|
||||||
|
Title = EUDto.Title,
|
||||||
|
Description = EUDto.Description,
|
||||||
|
ImageURL = EUDto.ImageURL,
|
||||||
|
Location = EUDto.Location,
|
||||||
|
EventDate = DateTime.SpecifyKind(EUDto.EventDate!.Value, DateTimeKind.Utc),
|
||||||
|
EventSkills = EUDto.EventSkills
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EventSummaryDto ToEventSummaryDto(this Event myEvent)
|
||||||
|
{
|
||||||
|
|
||||||
|
List<SkillSummaryDto> ssdto = [];
|
||||||
|
List<EventRegistrationDto> erdto = [];
|
||||||
|
|
||||||
|
if (myEvent.EventSkills != null)
|
||||||
|
{
|
||||||
|
foreach (EventSkill es in myEvent.EventSkills)
|
||||||
|
{
|
||||||
|
ssdto.Add(es.ToSkillSummaryDto());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myEvent.EventRegistrations != null)
|
||||||
|
{
|
||||||
|
foreach (EventRegistration er in myEvent.EventRegistrations)
|
||||||
|
{
|
||||||
|
erdto.Add(er.ToEventRegistrationDto());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EventSummaryDto {
|
||||||
|
EventId = myEvent.EventId,
|
||||||
|
Organisation = myEvent.Organisation!.Name,
|
||||||
|
OrganisationId = myEvent.OrganisationId,
|
||||||
|
Title = myEvent.Title,
|
||||||
|
Description = myEvent.Description ?? "",
|
||||||
|
Location = myEvent.Location,
|
||||||
|
EventDate = myEvent.EventDate,
|
||||||
|
EventSkills = ssdto,
|
||||||
|
EventRegistrations = erdto
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static EventSummaryNoErDto ToEventSummaryNoErDto(this Event myEvent)
|
||||||
|
{
|
||||||
|
|
||||||
|
return new EventSummaryNoErDto(
|
||||||
|
myEvent.EventId,
|
||||||
|
myEvent.Organisation!.Name,
|
||||||
|
myEvent.OrganisationId,
|
||||||
|
myEvent.Title,
|
||||||
|
myEvent.Description ?? "",
|
||||||
|
myEvent.ImageURL,
|
||||||
|
myEvent.Location,
|
||||||
|
myEvent.EventDate,
|
||||||
|
myEvent.EventSkills
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EventRegistrationDto ToEventRegistrationDto(this EventRegistration myER)
|
||||||
|
{
|
||||||
|
|
||||||
|
return new EventRegistrationDto {
|
||||||
|
EventId = myER.EventId,
|
||||||
|
UserId = myER.UserId,
|
||||||
|
UserName = myER.User!.FirstName + " " + myER.User!.LastName,
|
||||||
|
RegisteredAt = myER.RegisteredAt
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EventDetailsDto ToEventDetailsDto(this Event myEvent)
|
||||||
|
{
|
||||||
|
List<SkillSummaryDto> ssdto = [];
|
||||||
|
List<EventRegistrationDto> erdto = [];
|
||||||
|
|
||||||
|
if (myEvent.EventSkills != null)
|
||||||
|
{
|
||||||
|
foreach (EventSkill es in myEvent.EventSkills)
|
||||||
|
{
|
||||||
|
ssdto.Add(es.ToSkillSummaryDto());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myEvent.EventRegistrations != null)
|
||||||
|
{
|
||||||
|
foreach (EventRegistration er in myEvent.EventRegistrations)
|
||||||
|
{
|
||||||
|
erdto.Add(er.ToEventRegistrationDto());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EventDetailsDto {
|
||||||
|
EventId = myEvent.EventId,
|
||||||
|
OrganisationId = myEvent.OrganisationId,
|
||||||
|
OrganisationName = myEvent.Organisation!.Name,
|
||||||
|
Title = myEvent.Title,
|
||||||
|
Description = myEvent.Description ?? "",
|
||||||
|
Location = myEvent.Location,
|
||||||
|
EventDate = myEvent.EventDate,
|
||||||
|
EventSkills = ssdto,
|
||||||
|
EventRegistrations = erdto
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
24
WebApp/Mapping/EventSkillMapping.cs
Normal file
24
WebApp/Mapping/EventSkillMapping.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.Mapping;
|
||||||
|
|
||||||
|
public static class EventSkillMapping
|
||||||
|
{
|
||||||
|
public static EventSkill ToEventSkillEntity(this SingleSkillDto SSDto, int eid)
|
||||||
|
{
|
||||||
|
return new EventSkill()
|
||||||
|
{
|
||||||
|
EventId = eid,
|
||||||
|
SkillId = SSDto.Skill,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkillSummaryDto ToSkillSummaryDto(this EventSkill es)
|
||||||
|
{
|
||||||
|
return new SkillSummaryDto{
|
||||||
|
SkillId = es.SkillId,
|
||||||
|
SkillName = es.Skill.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
27
WebApp/Mapping/OrganizationMapping.cs
Normal file
27
WebApp/Mapping/OrganizationMapping.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.Mapping;
|
||||||
|
|
||||||
|
public static class OrganizationMapping
|
||||||
|
{
|
||||||
|
// obecnie zbędne
|
||||||
|
//public static Organisation ToEntity(this OrganisationSummaryDto ODto)
|
||||||
|
//{
|
||||||
|
// return new Organisation()
|
||||||
|
// {
|
||||||
|
// OrganisationId = ODto.OrganisationId!.Value,
|
||||||
|
// };
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static OrganisationSummaryDto ToOrgSummaryDto(this Organisation org)
|
||||||
|
{
|
||||||
|
return new OrganisationSummaryDto(
|
||||||
|
org.OrganisationId,
|
||||||
|
org.Name,
|
||||||
|
org.Description,
|
||||||
|
org.Website
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
WebApp/Mapping/SkillMapping.cs
Normal file
25
WebApp/Mapping/SkillMapping.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.Mapping
|
||||||
|
{
|
||||||
|
public static class SkillMapping
|
||||||
|
{
|
||||||
|
public static Skill ToSkillEntity(this SingleSkillDto SSDto, string name)
|
||||||
|
{
|
||||||
|
return new Skill()
|
||||||
|
{
|
||||||
|
SkillId = SSDto.Skill,
|
||||||
|
Name = name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkillSummaryDto ToSkillSummaryDto(this Skill s)
|
||||||
|
{
|
||||||
|
return new SkillSummaryDto {
|
||||||
|
SkillId = s.SkillId,
|
||||||
|
SkillName = s.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
WebApp/Mapping/UserMapping.cs
Normal file
33
WebApp/Mapping/UserMapping.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.Mapping
|
||||||
|
{
|
||||||
|
public static class UserMapping
|
||||||
|
{
|
||||||
|
public static UserSummaryDto ToUserSummaryDto(this User user)
|
||||||
|
{
|
||||||
|
return new UserSummaryDto(
|
||||||
|
user.UserId,
|
||||||
|
user.Email,
|
||||||
|
user.FirstName,
|
||||||
|
user.LastName,
|
||||||
|
user.CreatedAt,
|
||||||
|
user.IsOrganisation
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserSummaryWithOrgIdDto ToUserSummaryWithOrgIdDto(this User user, int OrganisationId)
|
||||||
|
{
|
||||||
|
return new UserSummaryWithOrgIdDto(
|
||||||
|
user.UserId,
|
||||||
|
user.Email,
|
||||||
|
user.FirstName,
|
||||||
|
user.LastName,
|
||||||
|
user.CreatedAt,
|
||||||
|
user.IsOrganisation,
|
||||||
|
OrganisationId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
WebApp/Mapping/VolunteerSkillMapping.cs
Normal file
16
WebApp/Mapping/VolunteerSkillMapping.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using WebApp.DTOs;
|
||||||
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
namespace WebApp.Mapping;
|
||||||
|
|
||||||
|
public static class VolunteerSkillMapping
|
||||||
|
{
|
||||||
|
public static VolunteerSkill ToVolunteerSkillEntity(this SingleSkillDto SSDto, int uid)
|
||||||
|
{
|
||||||
|
return new VolunteerSkill()
|
||||||
|
{
|
||||||
|
UserId = uid,
|
||||||
|
SkillId = SSDto.Skill,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,281 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using WebApp.Data;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace WebApp.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
|
||||||
[Migration("20250408112459_InitialDataStore")]
|
|
||||||
partial class InitialDataStore
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "9.0.3")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
|
||||||
.IsConcurrencyToken()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedName")
|
|
||||||
.IsUnique()
|
|
||||||
.HasDatabaseName("RoleNameIndex");
|
|
||||||
|
|
||||||
b.ToTable("AspNetRoles", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetRoleClaims", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("AccessFailedCount")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
|
||||||
.IsConcurrencyToken()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.Property<bool>("EmailConfirmed")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedEmail")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedUserName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PhoneNumber")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("PhoneNumberConfirmed")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<string>("SecurityStamp")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("TwoFactorEnabled")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<string>("UserName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedEmail")
|
|
||||||
.HasDatabaseName("EmailIndex");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedUserName")
|
|
||||||
.IsUnique()
|
|
||||||
.HasDatabaseName("UserNameIndex");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUsers", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserClaims", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderKey")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderDisplayName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("LoginProvider", "ProviderKey");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserLogins", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "RoleId");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserRoles", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "LoginProvider", "Name");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserTokens", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace WebApp.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialDataStore : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUsers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<string>(type: "text", nullable: false),
|
|
||||||
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
PasswordHash = table.Column<string>(type: "text", nullable: true),
|
|
||||||
SecurityStamp = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
|
|
||||||
PhoneNumber = table.Column<string>(type: "text", nullable: true),
|
|
||||||
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
||||||
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetRoleClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
RoleId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
ClaimType = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "AspNetRoles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
ClaimType = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserLogins",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
LoginProvider = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
|
||||||
ProviderKey = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
|
||||||
ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
RoleId = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "AspNetRoles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserTokens",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
LoginProvider = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
|
||||||
Value = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetRoleClaims_RoleId",
|
|
||||||
table: "AspNetRoleClaims",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "RoleNameIndex",
|
|
||||||
table: "AspNetRoles",
|
|
||||||
column: "NormalizedName",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserClaims_UserId",
|
|
||||||
table: "AspNetUserClaims",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserLogins_UserId",
|
|
||||||
table: "AspNetUserLogins",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserRoles_RoleId",
|
|
||||||
table: "AspNetUserRoles",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "EmailIndex",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
column: "NormalizedEmail");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "UserNameIndex",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
column: "NormalizedUserName",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetRoleClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserLogins");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserTokens");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUsers");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
308
WebApp/Migrations/20250424195335_EventTable.Designer.cs
generated
308
WebApp/Migrations/20250424195335_EventTable.Designer.cs
generated
@@ -1,308 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using WebApp.Data;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace WebApp.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
|
||||||
[Migration("20250424195335_EventTable")]
|
|
||||||
partial class EventTable
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "9.0.3")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
|
||||||
.IsConcurrencyToken()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedName")
|
|
||||||
.IsUnique()
|
|
||||||
.HasDatabaseName("RoleNameIndex");
|
|
||||||
|
|
||||||
b.ToTable("AspNetRoles", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetRoleClaims", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("AccessFailedCount")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
|
||||||
.IsConcurrencyToken()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.Property<bool>("EmailConfirmed")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedEmail")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedUserName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PhoneNumber")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("PhoneNumberConfirmed")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<string>("SecurityStamp")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("TwoFactorEnabled")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<string>("UserName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("character varying(256)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedEmail")
|
|
||||||
.HasDatabaseName("EmailIndex");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedUserName")
|
|
||||||
.IsUnique()
|
|
||||||
.HasDatabaseName("UserNameIndex");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUsers", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserClaims", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderKey")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderDisplayName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("LoginProvider", "ProviderKey");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserLogins", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "RoleId");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserRoles", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "LoginProvider", "Name");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserTokens", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<DateTime>("Date")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Place")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Events");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace WebApp.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class EventTable : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Events",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Place = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Description = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Events", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Events");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,279 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace WebApp.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class EventSkillsUsersOrganisations : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Place",
|
|
||||||
table: "Events",
|
|
||||||
newName: "Location");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Name",
|
|
||||||
table: "Events",
|
|
||||||
newName: "Title");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Date",
|
|
||||||
table: "Events",
|
|
||||||
newName: "EventDate");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Id",
|
|
||||||
table: "Events",
|
|
||||||
newName: "EventId");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "OrganisationId",
|
|
||||||
table: "Events",
|
|
||||||
type: "integer",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "timestamp with time zone",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "FirstName",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "text",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "IsOrganisation",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "boolean",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "LastName",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "text",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "EventRegistrations",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
EventId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
RegisteredAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_EventRegistrations", x => new { x.UserId, x.EventId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_EventRegistrations_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_EventRegistrations_Events_EventId",
|
|
||||||
column: x => x.EventId,
|
|
||||||
principalTable: "Events",
|
|
||||||
principalColumn: "EventId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Organisations",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
OrganisationId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Description = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Website = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Organisations", x => x.OrganisationId);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Organisations_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Skills",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
SkillId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Skills", x => x.SkillId);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "EventSkills",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
EventId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SkillId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_EventSkills", x => new { x.EventId, x.SkillId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_EventSkills_Events_EventId",
|
|
||||||
column: x => x.EventId,
|
|
||||||
principalTable: "Events",
|
|
||||||
principalColumn: "EventId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_EventSkills_Skills_SkillId",
|
|
||||||
column: x => x.SkillId,
|
|
||||||
principalTable: "Skills",
|
|
||||||
principalColumn: "SkillId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "VolunteerSkills",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "text", nullable: false),
|
|
||||||
SkillId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_VolunteerSkills", x => new { x.UserId, x.SkillId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_VolunteerSkills_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_VolunteerSkills_Skills_SkillId",
|
|
||||||
column: x => x.SkillId,
|
|
||||||
principalTable: "Skills",
|
|
||||||
principalColumn: "SkillId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Events_OrganisationId",
|
|
||||||
table: "Events",
|
|
||||||
column: "OrganisationId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_EventRegistrations_EventId",
|
|
||||||
table: "EventRegistrations",
|
|
||||||
column: "EventId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_EventSkills_SkillId",
|
|
||||||
table: "EventSkills",
|
|
||||||
column: "SkillId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Organisations_UserId",
|
|
||||||
table: "Organisations",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_VolunteerSkills_SkillId",
|
|
||||||
table: "VolunteerSkills",
|
|
||||||
column: "SkillId");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Events_Organisations_OrganisationId",
|
|
||||||
table: "Events",
|
|
||||||
column: "OrganisationId",
|
|
||||||
principalTable: "Organisations",
|
|
||||||
principalColumn: "OrganisationId",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Events_Organisations_OrganisationId",
|
|
||||||
table: "Events");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "EventRegistrations");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "EventSkills");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Organisations");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "VolunteerSkills");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Skills");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Events_OrganisationId",
|
|
||||||
table: "Events");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "OrganisationId",
|
|
||||||
table: "Events");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CreatedAt",
|
|
||||||
table: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "FirstName",
|
|
||||||
table: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "IsOrganisation",
|
|
||||||
table: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "LastName",
|
|
||||||
table: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Title",
|
|
||||||
table: "Events",
|
|
||||||
newName: "Name");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "Location",
|
|
||||||
table: "Events",
|
|
||||||
newName: "Place");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "EventDate",
|
|
||||||
table: "Events",
|
|
||||||
newName: "Date");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "EventId",
|
|
||||||
table: "Events",
|
|
||||||
newName: "Id");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
625
WebApp/Migrations/20250518010555_ESUOrev5.Designer.cs
generated
Normal file
625
WebApp/Migrations/20250518010555_ESUOrev5.Designer.cs
generated
Normal file
@@ -0,0 +1,625 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using WebApp.Data;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace WebApp.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
|
[Migration("20250518010555_ESUOrev5")]
|
||||||
|
partial class ESUOrev5
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "9.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("EventId"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EventDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Location")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("OrganisationId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("EventId");
|
||||||
|
|
||||||
|
b.HasIndex("OrganisationId");
|
||||||
|
|
||||||
|
b.ToTable("Events");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("VolunteerId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("RegisteredAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int?>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("VolunteerId", "EventId");
|
||||||
|
|
||||||
|
b.HasIndex("EventId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("EventRegistrations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("EventId", "SkillId");
|
||||||
|
|
||||||
|
b.HasIndex("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("EventSkills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Message", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("MessageId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("MessageId"));
|
||||||
|
|
||||||
|
b.Property<string>("Content")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("EventType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<bool>("IsMsgFromVolunteer")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTime>("IsoDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int>("OrganizationId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VolunteerId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("MessageId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.MessageActivity", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Sender")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Recipient")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("RecipientLastActive")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Sender", "Recipient");
|
||||||
|
|
||||||
|
b.ToTable("MessagesActivities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("OrganisationId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OrganisationId"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Website")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("OrganisationId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Organisations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SkillId"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("Skills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("TokenId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("TokenId"));
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ValidUntil")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("TokenId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Tokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserId"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsOrganisation")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId");
|
||||||
|
|
||||||
|
b.ToTable("WebUsers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "SkillId");
|
||||||
|
|
||||||
|
b.HasIndex("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("VolunteerSkills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.Organisation", "Organisation")
|
||||||
|
.WithMany("Events")
|
||||||
|
.HasForeignKey("OrganisationId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Organisation");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.Event", "Event")
|
||||||
|
.WithMany("EventRegistrations")
|
||||||
|
.HasForeignKey("EventId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebApp.Entities.User", "User")
|
||||||
|
.WithMany("EventRegistrations")
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("Event");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.Event", "Event")
|
||||||
|
.WithMany("EventSkills")
|
||||||
|
.HasForeignKey("EventId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebApp.Entities.Skill", "Skill")
|
||||||
|
.WithMany("EventSkills")
|
||||||
|
.HasForeignKey("SkillId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Event");
|
||||||
|
|
||||||
|
b.Navigation("Skill");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.User", null)
|
||||||
|
.WithMany("Tokens")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.Skill", "Skill")
|
||||||
|
.WithMany("VolunteerSkills")
|
||||||
|
.HasForeignKey("SkillId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebApp.Entities.User", "User")
|
||||||
|
.WithMany("VolunteerSkills")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Skill");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("EventRegistrations");
|
||||||
|
|
||||||
|
b.Navigation("EventSkills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Events");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("EventSkills");
|
||||||
|
|
||||||
|
b.Navigation("VolunteerSkills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("EventRegistrations");
|
||||||
|
|
||||||
|
b.Navigation("Tokens");
|
||||||
|
|
||||||
|
b.Navigation("VolunteerSkills");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
489
WebApp/Migrations/20250518010555_ESUOrev5.cs
Normal file
489
WebApp/Migrations/20250518010555_ESUOrev5.cs
Normal file
@@ -0,0 +1,489 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace WebApp.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ESUOrev5 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetRoles",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUsers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<string>(type: "text", nullable: false),
|
||||||
|
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
PasswordHash = table.Column<string>(type: "text", nullable: true),
|
||||||
|
SecurityStamp = table.Column<string>(type: "text", nullable: true),
|
||||||
|
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
|
||||||
|
PhoneNumber = table.Column<string>(type: "text", nullable: true),
|
||||||
|
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||||
|
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Messages",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
MessageId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
EventType = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
VolunteerId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
OrganizationId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
IsMsgFromVolunteer = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
IsoDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
Content = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "MessagesActivities",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Recipient = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Sender = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
RecipientLastActive = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_MessagesActivities", x => new { x.Sender, x.Recipient });
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Skills",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
SkillId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Skills", x => x.SkillId);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "WebUsers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Email = table.Column<string>(type: "text", nullable: true),
|
||||||
|
Password = table.Column<string>(type: "text", nullable: true),
|
||||||
|
FirstName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
LastName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
IsOrganisation = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_WebUsers", x => x.UserId);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetRoleClaims",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
RoleId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ClaimType = table.Column<string>(type: "text", nullable: true),
|
||||||
|
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
|
||||||
|
column: x => x.RoleId,
|
||||||
|
principalTable: "AspNetRoles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUserClaims",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ClaimType = table.Column<string>(type: "text", nullable: true),
|
||||||
|
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUserLogins",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
LoginProvider = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ProviderKey = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUserRoles",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
RoleId = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
|
||||||
|
column: x => x.RoleId,
|
||||||
|
principalTable: "AspNetRoles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUserTokens",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
LoginProvider = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Value = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Organisations",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
OrganisationId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "text", nullable: true),
|
||||||
|
Website = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Organisations", x => x.OrganisationId);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Organisations_WebUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "WebUsers",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Tokens",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
TokenId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
ValidUntil = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
Value = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Tokens", x => x.TokenId);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Tokens_WebUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "WebUsers",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "VolunteerSkills",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
SkillId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_VolunteerSkills", x => new { x.UserId, x.SkillId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_VolunteerSkills_Skills_SkillId",
|
||||||
|
column: x => x.SkillId,
|
||||||
|
principalTable: "Skills",
|
||||||
|
principalColumn: "SkillId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_VolunteerSkills_WebUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "WebUsers",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Events",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
EventId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
OrganisationId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Title = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "text", nullable: true),
|
||||||
|
Location = table.Column<string>(type: "text", nullable: false),
|
||||||
|
EventDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Events", x => x.EventId);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Events_Organisations_OrganisationId",
|
||||||
|
column: x => x.OrganisationId,
|
||||||
|
principalTable: "Organisations",
|
||||||
|
principalColumn: "OrganisationId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "EventRegistrations",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
EventId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
VolunteerId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
RegisteredAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
UserId = table.Column<int>(type: "integer", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_EventRegistrations", x => new { x.VolunteerId, x.EventId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_EventRegistrations_Events_EventId",
|
||||||
|
column: x => x.EventId,
|
||||||
|
principalTable: "Events",
|
||||||
|
principalColumn: "EventId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_EventRegistrations_WebUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "WebUsers",
|
||||||
|
principalColumn: "UserId");
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "EventSkills",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
EventId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
SkillId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_EventSkills", x => new { x.EventId, x.SkillId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_EventSkills_Events_EventId",
|
||||||
|
column: x => x.EventId,
|
||||||
|
principalTable: "Events",
|
||||||
|
principalColumn: "EventId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_EventSkills_Skills_SkillId",
|
||||||
|
column: x => x.SkillId,
|
||||||
|
principalTable: "Skills",
|
||||||
|
principalColumn: "SkillId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AspNetRoleClaims_RoleId",
|
||||||
|
table: "AspNetRoleClaims",
|
||||||
|
column: "RoleId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "RoleNameIndex",
|
||||||
|
table: "AspNetRoles",
|
||||||
|
column: "NormalizedName",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AspNetUserClaims_UserId",
|
||||||
|
table: "AspNetUserClaims",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AspNetUserLogins_UserId",
|
||||||
|
table: "AspNetUserLogins",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AspNetUserRoles_RoleId",
|
||||||
|
table: "AspNetUserRoles",
|
||||||
|
column: "RoleId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "EmailIndex",
|
||||||
|
table: "AspNetUsers",
|
||||||
|
column: "NormalizedEmail");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "UserNameIndex",
|
||||||
|
table: "AspNetUsers",
|
||||||
|
column: "NormalizedUserName",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_EventRegistrations_EventId",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
column: "EventId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_EventRegistrations_UserId",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Events_OrganisationId",
|
||||||
|
table: "Events",
|
||||||
|
column: "OrganisationId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_EventSkills_SkillId",
|
||||||
|
table: "EventSkills",
|
||||||
|
column: "SkillId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Organisations_UserId",
|
||||||
|
table: "Organisations",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Tokens_UserId",
|
||||||
|
table: "Tokens",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_VolunteerSkills_SkillId",
|
||||||
|
table: "VolunteerSkills",
|
||||||
|
column: "SkillId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetRoleClaims");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUserClaims");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUserLogins");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUserRoles");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUserTokens");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "EventRegistrations");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "EventSkills");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Messages");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "MessagesActivities");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Tokens");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "VolunteerSkills");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetRoles");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUsers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Events");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Skills");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Organisations");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "WebUsers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,8 +12,8 @@ using WebApp.Data;
|
|||||||
namespace WebApp.Migrations
|
namespace WebApp.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
[Migration("20250426222859_EventSkillsUsersOrganisations")]
|
[Migration("20250530235051_RenameEventRegistration")]
|
||||||
partial class EventSkillsUsersOrganisations
|
partial class RenameEventRegistration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -25,7 +25,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("Id")
|
b.Property<string>("Id")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -76,203 +76,7 @@ namespace WebApp.Migrations
|
|||||||
b.ToTable("AspNetRoleClaims", (string)null);
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserClaims", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderKey")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderDisplayName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("LoginProvider", "ProviderKey");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserLogins", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "RoleId");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserRoles", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "LoginProvider", "Name");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserTokens", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("EventId"));
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("EventDate")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("Location")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("OrganisationId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Title")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("EventId");
|
|
||||||
|
|
||||||
b.HasIndex("OrganisationId");
|
|
||||||
|
|
||||||
b.ToTable("Events");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("RegisteredAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "EventId");
|
|
||||||
|
|
||||||
b.HasIndex("EventId");
|
|
||||||
|
|
||||||
b.ToTable("EventRegistrations");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("SkillId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("EventId", "SkillId");
|
|
||||||
|
|
||||||
b.HasIndex("SkillId");
|
|
||||||
|
|
||||||
b.ToTable("EventSkills");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("OrganisationId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OrganisationId"));
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Website")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("OrganisationId");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("Organisations");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("SkillId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SkillId"));
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("SkillId");
|
|
||||||
|
|
||||||
b.ToTable("Skills");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.User", b =>
|
|
||||||
{
|
{
|
||||||
b.Property<string>("Id")
|
b.Property<string>("Id")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -284,9 +88,6 @@ namespace WebApp.Migrations
|
|||||||
.IsConcurrencyToken()
|
.IsConcurrencyToken()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("character varying(256)");
|
.HasColumnType("character varying(256)");
|
||||||
@@ -294,17 +95,6 @@ namespace WebApp.Migrations
|
|||||||
b.Property<bool>("EmailConfirmed")
|
b.Property<bool>("EmailConfirmed")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("IsOrganisation")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
b.Property<bool>("LockoutEnabled")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
@@ -350,11 +140,306 @@ namespace WebApp.Migrations
|
|||||||
b.ToTable("AspNetUsers", (string)null);
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("UserId")
|
b.Property<string>("UserId")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("EventId"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EventDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Location")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("OrganisationId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("EventId");
|
||||||
|
|
||||||
|
b.HasIndex("OrganisationId");
|
||||||
|
|
||||||
|
b.ToTable("Events");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("RegisteredAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "EventId");
|
||||||
|
|
||||||
|
b.HasIndex("EventId");
|
||||||
|
|
||||||
|
b.ToTable("EventRegistrations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("EventId", "SkillId");
|
||||||
|
|
||||||
|
b.HasIndex("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("EventSkills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Message", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("MessageId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("MessageId"));
|
||||||
|
|
||||||
|
b.Property<string>("Content")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("EventType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<bool>("IsMsgFromVolunteer")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTime>("IsoDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int>("OrganizationId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VolunteerId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("MessageId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.MessageActivity", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Sender")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Recipient")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("RecipientLastActive")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Sender", "Recipient");
|
||||||
|
|
||||||
|
b.ToTable("MessagesActivities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("OrganisationId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OrganisationId"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Website")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("OrganisationId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Organisations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SkillId"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("Skills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("TokenId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("TokenId"));
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ValidUntil")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("TokenId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Tokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserId"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsOrganisation")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId");
|
||||||
|
|
||||||
|
b.ToTable("WebUsers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("SkillId")
|
b.Property<int>("SkillId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
@@ -367,7 +452,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<string>", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -376,7 +461,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -385,7 +470,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -394,13 +479,13 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<string>", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -409,7 +494,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -476,6 +561,15 @@ namespace WebApp.Migrations
|
|||||||
b.Navigation("User");
|
b.Navigation("User");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.User", null)
|
||||||
|
.WithMany("Tokens")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.Skill", "Skill")
|
b.HasOne("WebApp.Entities.Skill", "Skill")
|
||||||
@@ -518,6 +612,8 @@ namespace WebApp.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("EventRegistrations");
|
b.Navigation("EventRegistrations");
|
||||||
|
|
||||||
|
b.Navigation("Tokens");
|
||||||
|
|
||||||
b.Navigation("VolunteerSkills");
|
b.Navigation("VolunteerSkills");
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
97
WebApp/Migrations/20250530235051_RenameEventRegistration.cs
Normal file
97
WebApp/Migrations/20250530235051_RenameEventRegistration.cs
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace WebApp.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class RenameEventRegistration : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_EventRegistrations_WebUsers_UserId",
|
||||||
|
table: "EventRegistrations");
|
||||||
|
|
||||||
|
migrationBuilder.DropPrimaryKey(
|
||||||
|
name: "PK_EventRegistrations",
|
||||||
|
table: "EventRegistrations");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_EventRegistrations_UserId",
|
||||||
|
table: "EventRegistrations");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "VolunteerId",
|
||||||
|
table: "EventRegistrations");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "UserId",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddPrimaryKey(
|
||||||
|
name: "PK_EventRegistrations",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
columns: new[] { "UserId", "EventId" });
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_EventRegistrations_WebUsers_UserId",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "WebUsers",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_EventRegistrations_WebUsers_UserId",
|
||||||
|
table: "EventRegistrations");
|
||||||
|
|
||||||
|
migrationBuilder.DropPrimaryKey(
|
||||||
|
name: "PK_EventRegistrations",
|
||||||
|
table: "EventRegistrations");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "UserId",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
type: "integer",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "VolunteerId",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddPrimaryKey(
|
||||||
|
name: "PK_EventRegistrations",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
columns: new[] { "VolunteerId", "EventId" });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_EventRegistrations_UserId",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_EventRegistrations_WebUsers_UserId",
|
||||||
|
table: "EventRegistrations",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "WebUsers",
|
||||||
|
principalColumn: "UserId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,8 +12,8 @@ using WebApp.Data;
|
|||||||
namespace WebApp.Migrations
|
namespace WebApp.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
[Migration("20250428003000_ESUOrev2")]
|
[Migration("20250602005444_EventImageURL")]
|
||||||
partial class ESUOrev2
|
partial class EventImageURL
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -25,7 +25,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("Id")
|
b.Property<string>("Id")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -76,203 +76,7 @@ namespace WebApp.Migrations
|
|||||||
b.ToTable("AspNetRoleClaims", (string)null);
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserClaims", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderKey")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderDisplayName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("LoginProvider", "ProviderKey");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserLogins", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "RoleId");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserRoles", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "LoginProvider", "Name");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserTokens", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("EventId"));
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("EventDate")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("Location")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("OrganisationId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Title")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("EventId");
|
|
||||||
|
|
||||||
b.HasIndex("OrganisationId");
|
|
||||||
|
|
||||||
b.ToTable("Events");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("RegisteredAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "EventId");
|
|
||||||
|
|
||||||
b.HasIndex("EventId");
|
|
||||||
|
|
||||||
b.ToTable("EventRegistrations");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("SkillId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("EventId", "SkillId");
|
|
||||||
|
|
||||||
b.HasIndex("SkillId");
|
|
||||||
|
|
||||||
b.ToTable("EventSkills");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("OrganisationId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OrganisationId"));
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Website")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("OrganisationId");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("Organisations");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("SkillId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SkillId"));
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("SkillId");
|
|
||||||
|
|
||||||
b.ToTable("Skills");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.User", b =>
|
|
||||||
{
|
{
|
||||||
b.Property<string>("Id")
|
b.Property<string>("Id")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -284,9 +88,6 @@ namespace WebApp.Migrations
|
|||||||
.IsConcurrencyToken()
|
.IsConcurrencyToken()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("character varying(256)");
|
.HasColumnType("character varying(256)");
|
||||||
@@ -294,17 +95,6 @@ namespace WebApp.Migrations
|
|||||||
b.Property<bool>("EmailConfirmed")
|
b.Property<bool>("EmailConfirmed")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("IsOrganisation")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
b.Property<bool>("LockoutEnabled")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
@@ -350,11 +140,309 @@ namespace WebApp.Migrations
|
|||||||
b.ToTable("AspNetUsers", (string)null);
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("UserId")
|
b.Property<string>("UserId")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("EventId"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EventDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Location")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("OrganisationId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("EventId");
|
||||||
|
|
||||||
|
b.HasIndex("OrganisationId");
|
||||||
|
|
||||||
|
b.ToTable("Events");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("RegisteredAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "EventId");
|
||||||
|
|
||||||
|
b.HasIndex("EventId");
|
||||||
|
|
||||||
|
b.ToTable("EventRegistrations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("EventId", "SkillId");
|
||||||
|
|
||||||
|
b.HasIndex("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("EventSkills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Message", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("MessageId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("MessageId"));
|
||||||
|
|
||||||
|
b.Property<string>("Content")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("EventType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<bool>("IsMsgFromVolunteer")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTime>("IsoDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int>("OrganizationId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VolunteerId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("MessageId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.MessageActivity", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Sender")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Recipient")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("RecipientLastActive")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Sender", "Recipient");
|
||||||
|
|
||||||
|
b.ToTable("MessagesActivities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("OrganisationId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OrganisationId"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Website")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("OrganisationId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Organisations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SkillId"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("Skills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("TokenId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("TokenId"));
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ValidUntil")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("TokenId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Tokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserId"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsOrganisation")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId");
|
||||||
|
|
||||||
|
b.ToTable("WebUsers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("SkillId")
|
b.Property<int>("SkillId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
@@ -367,7 +455,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<string>", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -376,7 +464,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -385,7 +473,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -394,13 +482,13 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<string>", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -409,7 +497,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -476,6 +564,15 @@ namespace WebApp.Migrations
|
|||||||
b.Navigation("User");
|
b.Navigation("User");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.User", null)
|
||||||
|
.WithMany("Tokens")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.Skill", "Skill")
|
b.HasOne("WebApp.Entities.Skill", "Skill")
|
||||||
@@ -518,6 +615,8 @@ namespace WebApp.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("EventRegistrations");
|
b.Navigation("EventRegistrations");
|
||||||
|
|
||||||
|
b.Navigation("Tokens");
|
||||||
|
|
||||||
b.Navigation("VolunteerSkills");
|
b.Navigation("VolunteerSkills");
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
@@ -5,18 +5,24 @@
|
|||||||
namespace WebApp.Migrations
|
namespace WebApp.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class ESUOrev2 : Migration
|
public partial class EventImageURL : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ImageURL",
|
||||||
|
table: "Events",
|
||||||
|
type: "text",
|
||||||
|
nullable: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ImageURL",
|
||||||
|
table: "Events");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("Id")
|
b.Property<string>("Id")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -73,203 +73,7 @@ namespace WebApp.Migrations
|
|||||||
b.ToTable("AspNetRoleClaims", (string)null);
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserClaims", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderKey")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderDisplayName")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("LoginProvider", "ProviderKey");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserLogins", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "RoleId");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserRoles", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasMaxLength(128)
|
|
||||||
.HasColumnType("character varying(128)");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "LoginProvider", "Name");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserTokens", (string)null);
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("EventId"));
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("EventDate")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("Location")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("OrganisationId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Title")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("EventId");
|
|
||||||
|
|
||||||
b.HasIndex("OrganisationId");
|
|
||||||
|
|
||||||
b.ToTable("Events");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<DateTime>("RegisteredAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "EventId");
|
|
||||||
|
|
||||||
b.HasIndex("EventId");
|
|
||||||
|
|
||||||
b.ToTable("EventRegistrations");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("EventId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("SkillId")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("EventId", "SkillId");
|
|
||||||
|
|
||||||
b.HasIndex("SkillId");
|
|
||||||
|
|
||||||
b.ToTable("EventSkills");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("OrganisationId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OrganisationId"));
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Website")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("OrganisationId");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("Organisations");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("SkillId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SkillId"));
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("SkillId");
|
|
||||||
|
|
||||||
b.ToTable("Skills");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.User", b =>
|
|
||||||
{
|
{
|
||||||
b.Property<string>("Id")
|
b.Property<string>("Id")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -281,9 +85,6 @@ namespace WebApp.Migrations
|
|||||||
.IsConcurrencyToken()
|
.IsConcurrencyToken()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("character varying(256)");
|
.HasColumnType("character varying(256)");
|
||||||
@@ -291,17 +92,6 @@ namespace WebApp.Migrations
|
|||||||
b.Property<bool>("EmailConfirmed")
|
b.Property<bool>("EmailConfirmed")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("IsOrganisation")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
b.Property<bool>("LockoutEnabled")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
@@ -347,11 +137,309 @@ namespace WebApp.Migrations
|
|||||||
b.ToTable("AspNetUsers", (string)null);
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("UserId")
|
b.Property<string>("UserId")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Event", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("EventId"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EventDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Location")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("OrganisationId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("EventId");
|
||||||
|
|
||||||
|
b.HasIndex("OrganisationId");
|
||||||
|
|
||||||
|
b.ToTable("Events");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventRegistration", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("RegisteredAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "EventId");
|
||||||
|
|
||||||
|
b.HasIndex("EventId");
|
||||||
|
|
||||||
|
b.ToTable("EventRegistrations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.EventSkill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("EventId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("EventId", "SkillId");
|
||||||
|
|
||||||
|
b.HasIndex("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("EventSkills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Message", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("MessageId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("MessageId"));
|
||||||
|
|
||||||
|
b.Property<string>("Content")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("EventType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<bool>("IsMsgFromVolunteer")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTime>("IsoDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int>("OrganizationId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VolunteerId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("MessageId");
|
||||||
|
|
||||||
|
b.ToTable("Messages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.MessageActivity", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Sender")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Recipient")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("RecipientLastActive")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Sender", "Recipient");
|
||||||
|
|
||||||
|
b.ToTable("MessagesActivities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Organisation", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("OrganisationId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("OrganisationId"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Website")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("OrganisationId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Organisations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Skill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("SkillId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("SkillId"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("SkillId");
|
||||||
|
|
||||||
|
b.ToTable("Skills");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("TokenId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("TokenId"));
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ValidUntil")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("TokenId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Tokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserId"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsOrganisation")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId");
|
||||||
|
|
||||||
|
b.ToTable("WebUsers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("SkillId")
|
b.Property<int>("SkillId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
@@ -364,7 +452,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<string>", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -373,7 +461,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -382,7 +470,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -391,13 +479,13 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<string>", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -406,7 +494,7 @@ namespace WebApp.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.User", null)
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -473,6 +561,15 @@ namespace WebApp.Migrations
|
|||||||
b.Navigation("User");
|
b.Navigation("User");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebApp.Entities.Token", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebApp.Entities.User", null)
|
||||||
|
.WithMany("Tokens")
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
modelBuilder.Entity("WebApp.Entities.VolunteerSkill", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("WebApp.Entities.Skill", "Skill")
|
b.HasOne("WebApp.Entities.Skill", "Skill")
|
||||||
@@ -515,6 +612,8 @@ namespace WebApp.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("EventRegistrations");
|
b.Navigation("EventRegistrations");
|
||||||
|
|
||||||
|
b.Navigation("Tokens");
|
||||||
|
|
||||||
b.Navigation("VolunteerSkills");
|
b.Navigation("VolunteerSkills");
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
|
|||||||
@@ -1,25 +1,33 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using WebApp.Data;
|
using WebApp.Data;
|
||||||
|
using WebApp.Endpoints;
|
||||||
using WebApp.Entities;
|
using WebApp.Entities;
|
||||||
|
|
||||||
|
// Create WebAppliaction Builder
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Configure Database Conecction
|
||||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
||||||
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
||||||
options.UseNpgsql(connectionString));
|
options.UseNpgsql(connectionString));
|
||||||
|
|
||||||
|
// Add Developer Exception Filter
|
||||||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||||
|
|
||||||
builder.Services.AddDefaultIdentity<User>(options => options.SignIn.RequireConfirmedAccount = true)
|
// Configure Identity
|
||||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
//builder.Services.AddDefaultIdentity<User>(options => options.SignIn.RequireConfirmedAccount = true)
|
||||||
builder.Services.AddControllersWithViews();
|
// .AddEntityFrameworkStores<ApplicationDbContext>();
|
||||||
|
|
||||||
|
// API Services For Swagger
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen(c =>
|
builder.Services.AddSwaggerGen(c =>
|
||||||
{
|
{
|
||||||
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "hermes", Version = "v1" });
|
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "hermes", Version = "v1" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.AddScoped<GeneralUseHelpers>();
|
||||||
|
|
||||||
|
// Build Application
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@@ -31,22 +39,22 @@ if (app.Environment.IsDevelopment())
|
|||||||
}
|
}
|
||||||
else
|
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.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
// Middleware Configuration
|
||||||
app.UseDefaultFiles();
|
app.UseHttpsRedirection(); // Redirects all HTTP requests to HTTPS
|
||||||
app.UseStaticFiles();
|
app.UseDefaultFiles(); // Serves default files (index.html) if no specific file is requested
|
||||||
|
app.UseStaticFiles(); // Serves static files(CSS, JS, Img) from the wwwroot folder.
|
||||||
|
app.UseRouting(); // Enables routing to match incoming request to endpoints
|
||||||
|
//app.UseAuthorization();
|
||||||
|
|
||||||
app.UseRouting();
|
// Map Minimal API Endpoints
|
||||||
|
app.MapEventsEndpoints();
|
||||||
app.UseAuthorization();
|
app.MapOrganizationsEndpoints();
|
||||||
|
app.MapAuthEndpoints();
|
||||||
app.MapControllerRoute(
|
app.MapSkillsEndpoints();
|
||||||
name: "default",
|
app.MapEventsRegistrationEndpoints();
|
||||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
app.MapMessagesEndpoints();
|
||||||
app.MapRazorPages();
|
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.OpenApi" Version="1.6.24" />
|
<PackageReference Include="Microsoft.OpenApi" Version="1.6.24" />
|
||||||
|
<PackageReference Include="MinimalApis.Extensions" Version="0.11.0" />
|
||||||
<PackageReference Include="Npgsql" Version="9.0.3" />
|
<PackageReference Include="Npgsql" Version="9.0.3" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
|
||||||
|
|||||||
57
WebApp/ts/auth.ts
Normal file
57
WebApp/ts/auth.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
// /js/auth.ts
|
||||||
|
|
||||||
|
function deleteCookie(name: string): void {
|
||||||
|
document.cookie = `${name}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function logoutUser(): Promise<void> {
|
||||||
|
await fetch("/api/auth/logout", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteCookie('token');
|
||||||
|
|
||||||
|
window.location.href = "/index.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirectToLogin(): void {
|
||||||
|
window.location.href = 'login.html';
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkAuth(): boolean {
|
||||||
|
// Basic auth check via presence of token cookie
|
||||||
|
return document.cookie.includes('token=');
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupAuthUI(): void {
|
||||||
|
const joinNowBtn = document.getElementById('joinnow-btn');
|
||||||
|
const signInBtn = document.getElementById('signin-btn');
|
||||||
|
const logoutBtn = document.getElementById('logout-btn');
|
||||||
|
|
||||||
|
const isAuthenticated = checkAuth();
|
||||||
|
|
||||||
|
if (joinNowBtn) {
|
||||||
|
joinNowBtn.classList.toggle('d-none', isAuthenticated);
|
||||||
|
joinNowBtn.addEventListener('click', redirectToLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (signInBtn) {
|
||||||
|
signInBtn.classList.toggle('d-none', isAuthenticated);
|
||||||
|
signInBtn.addEventListener('click', redirectToLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logoutBtn) {
|
||||||
|
logoutBtn.classList.toggle('d-none', !isAuthenticated);
|
||||||
|
logoutBtn.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
logoutUser();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize on load
|
||||||
|
document.addEventListener('DOMContentLoaded', setupAuthUI);
|
||||||
53
WebApp/ts/calendar.ts
Normal file
53
WebApp/ts/calendar.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { unhideElementById, getMyAccount } from './generalUseHelpers.js';
|
||||||
|
|
||||||
|
|
||||||
|
async function getRegisteredEvents(): Promise<any[]> {
|
||||||
|
const res = await fetch("/api/events/registered");
|
||||||
|
if (!res.ok) throw new Error("Couldn't load joined events");
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
return data.map((ev: any) => ({
|
||||||
|
title: ev.title,
|
||||||
|
start: ev.eventDate,
|
||||||
|
url: `/view.html?event=${ev.eventId}`
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
|
|
||||||
|
try {
|
||||||
|
var user = await getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendarEl = document.getElementById("calendar") as HTMLElement;
|
||||||
|
if (!calendarEl) return;
|
||||||
|
|
||||||
|
const events = await getRegisteredEvents();
|
||||||
|
|
||||||
|
const calendar = new (window as any).FullCalendar.Calendar(calendarEl, {
|
||||||
|
initialView: 'dayGridMonth',
|
||||||
|
headerToolbar: {
|
||||||
|
left: 'prev,next today',
|
||||||
|
center: 'title',
|
||||||
|
right: 'dayGridMonth,timeGridWeek,listWeek'
|
||||||
|
},
|
||||||
|
themeSystem: 'bootstrap5',
|
||||||
|
events: events,
|
||||||
|
eventClick: function (info: any) {
|
||||||
|
if (info.event.url) {
|
||||||
|
window.location.href = info.event.url;
|
||||||
|
info.jsEvent.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
calendar.render();
|
||||||
|
});
|
||||||
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
console.log("TypeScript działa!");
|
|
||||||
function createEvent() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// Pobieranie danych z formularza
|
|
||||||
const title = document.getElementById('title').value;
|
|
||||||
const location = document.getElementById('location').value;
|
|
||||||
const description = document.getElementById('description').value;
|
|
||||||
const eventDateRaw = document.getElementById('eventDate').value;
|
|
||||||
const organisationIdRaw = document.getElementById('organisationId').value;
|
|
||||||
// Walidacja prostych pól
|
|
||||||
if (!title || !location || !eventDateRaw || !organisationIdRaw) {
|
|
||||||
alert("Uzupełnij wszystkie wymagane pola!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const eventDate = new Date(eventDateRaw).toISOString();
|
|
||||||
const organisationId = parseInt(organisationIdRaw);
|
|
||||||
const payload = {
|
|
||||||
title,
|
|
||||||
location,
|
|
||||||
description,
|
|
||||||
eventDate,
|
|
||||||
organisationId
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
const response = yield fetch('/api/events', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify(payload)
|
|
||||||
});
|
|
||||||
if (!response.ok) {
|
|
||||||
const errorText = yield response.text();
|
|
||||||
throw new Error(errorText);
|
|
||||||
}
|
|
||||||
alert("Wydarzenie zostało utworzone!");
|
|
||||||
window.location.href = "/"; // Przekierowanie do strony głównej
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.error("Błąd podczas tworzenia:", error);
|
|
||||||
alert("Nie udało się utworzyć wydarzenia: " + error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
const saveBtn = document.getElementById("saveBtn");
|
|
||||||
if (saveBtn) {
|
|
||||||
saveBtn.addEventListener("click", (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
createEvent();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,28 +1,29 @@
|
|||||||
console.log("TypeScript działa!");
|
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function createEvent() {
|
async function createEvent() {
|
||||||
// Pobieranie danych z formularza
|
// Pobieranie danych z formularza
|
||||||
const title = (document.getElementById('title') as HTMLInputElement).value;
|
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||||
const location = (document.getElementById('location') as HTMLInputElement).value;
|
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||||
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||||
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
const imageURL = (document.getElementById('imageURL') as HTMLInputElement).value;
|
||||||
const organisationIdRaw = (document.getElementById('organisationId') as HTMLInputElement).value;
|
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||||
|
|
||||||
// Walidacja prostych pól
|
// Walidacja prostych pól
|
||||||
if (!title || !location || !eventDateRaw || !organisationIdRaw) {
|
if (!title || !location || !eventDateRaw) {
|
||||||
alert("Uzupełnij wszystkie wymagane pola!");
|
alert("Please fill out all of the required fields!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventDate = new Date(eventDateRaw).toISOString();
|
const eventDate = new Date(eventDateRaw).toISOString();
|
||||||
const organisationId = parseInt(organisationIdRaw);
|
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
title,
|
title,
|
||||||
location,
|
location,
|
||||||
description,
|
description,
|
||||||
|
imageURL,
|
||||||
eventDate,
|
eventDate,
|
||||||
organisationId
|
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -37,20 +38,32 @@ async function createEvent() {
|
|||||||
throw new Error(errorText);
|
throw new Error(errorText);
|
||||||
}
|
}
|
||||||
|
|
||||||
alert("Wydarzenie zostało utworzone!");
|
alert("Event created successfully!");
|
||||||
window.location.href = "/"; // Przekierowanie do strony głównej
|
window.location.href = "/"; // Przekierowanie do strony głównej
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Błąd podczas tworzenia:", error);
|
console.error("Couldn't create event:", error);
|
||||||
alert("Nie udało się utworzyć wydarzenia: " + error);
|
alert("Couldn't create new event: " + error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
const saveBtn = document.getElementById("saveBtn");
|
const saveBtn = document.getElementById("saveBtn");
|
||||||
|
|
||||||
|
var user = await getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
if (user.isOrganisation) {
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
}
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
} else {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
|
||||||
if (saveBtn) {
|
if (saveBtn) {
|
||||||
saveBtn.addEventListener("click", (e) => {
|
saveBtn.addEventListener("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
createEvent();
|
createEvent();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,32 +1,40 @@
|
|||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
// Obsługuje kliknięcie na przycisk "Usuń"
|
// Obsługuje kliknięcie na przycisk "Usuń"
|
||||||
document.body.addEventListener("click", async (e) => {
|
document.body.addEventListener("click", async (e) => {
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
|
|
||||||
if (!target.matches(".delete-btn")) return; // Sprawdza, czy kliknięto przycisk "Usuń"
|
if (!target.matches(".mod-btn")) return; // Sprawdza, czy kliknięto przycisk "Usuń" lub "Edytuj"
|
||||||
|
|
||||||
const id = target.getAttribute("data-id"); // Pobiera ID wydarzenia
|
const id = target.getAttribute("data-id"); // Pobiera ID wydarzenia
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
|
||||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?"); // Potwierdzenie usunięcia
|
switch (target.id) {
|
||||||
if (!confirmed) return;
|
case "edit-btn":
|
||||||
|
window.location.href = "/modify.html?event=" + id;
|
||||||
|
break;
|
||||||
|
case "remove-btn":
|
||||||
|
const confirmed = confirm("Are you sure?"); // Potwierdzenie usunięcia
|
||||||
|
if (!confirmed) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Wysyła żądanie DELETE do API
|
// Wysyła żądanie DELETE do API
|
||||||
const response = await fetch(`/api/events/${id}`, {
|
const response = await fetch(`/api/events/${id}`, {
|
||||||
method: "DELETE"
|
method: "DELETE"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
// Usuwa kartę z DOM (bez przeładowania strony)
|
// Usuwa kartę z DOM (bez przeładowania strony)
|
||||||
const card = target.closest(".event-card");
|
const card = target.closest(".event-card");
|
||||||
if (card) card.remove();
|
if (card) card.remove();
|
||||||
} else {
|
} else {
|
||||||
alert("Błąd podczas usuwania wydarzenia.");
|
alert("Couldn't delete that event.");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert("Błąd połączenia z serwerem.");
|
alert("Server connection failure.");
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,32 +1,208 @@
|
|||||||
document.addEventListener("DOMContentLoaded", async () => {
|
import { getEvent, getMyAccount, unhideElementById, hideElementById } from './generalUseHelpers.js';
|
||||||
const container = document.getElementById("eventList");
|
|
||||||
if (!container) return;
|
var isAscending: boolean = false;
|
||||||
|
var optionsVisibility: boolean = false;
|
||||||
|
|
||||||
|
function toggleListSortOrder(org_id: number) {
|
||||||
|
isAscending = !isAscending;
|
||||||
|
loadEvents(org_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleOptionsVisibility() {
|
||||||
|
optionsVisibility = !optionsVisibility;
|
||||||
|
if (optionsVisibility) {
|
||||||
|
unhideElementById(document, "fDate");
|
||||||
|
unhideElementById(document, "tDate");
|
||||||
|
unhideElementById(document, "flabel");
|
||||||
|
unhideElementById(document, "tlabel");
|
||||||
|
} else {
|
||||||
|
hideElementById(document, "fDate");
|
||||||
|
hideElementById(document, "tDate");
|
||||||
|
hideElementById(document, "flabel");
|
||||||
|
hideElementById(document, "tlabel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getEvents(titleOrDescription?: string, fDate?: Date, tDate?: Date) {
|
||||||
|
|
||||||
|
var res: Response;
|
||||||
|
var searchbar = document.getElementById("searchbar") as HTMLInputElement;
|
||||||
|
var eventDateFrom = (document.getElementById('fDate') as HTMLInputElement).value;
|
||||||
|
var eventDateTo = (document.getElementById('tDate') as HTMLInputElement).value;
|
||||||
|
|
||||||
|
if (titleOrDescription == null) {
|
||||||
|
titleOrDescription = searchbar.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optionsVisibility) {
|
||||||
|
var payload_visible = {
|
||||||
|
titleOrDescription,
|
||||||
|
eventDateFrom,
|
||||||
|
eventDateTo
|
||||||
|
};
|
||||||
|
res = await fetch('/api/events/search' + (isAscending ? "?sort=asc" : ""), {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload_visible)
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error("Failed to get search results");
|
||||||
|
} else {
|
||||||
|
var payload_invisible = {
|
||||||
|
titleOrDescription
|
||||||
|
};
|
||||||
|
res = await fetch('/api/events/search' + (isAscending ? "?sort=asc" : ""), {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload_invisible)
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error("Failed to get search results");
|
||||||
|
}
|
||||||
|
|
||||||
|
const events = await res.json();
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendMessageForEvent(eventId: number) {
|
||||||
|
const messageContent = `Help me with <a href="/view.html?event=${eventId}">this event</a>`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/api/events");
|
const response = await fetch('/api/messages/sendFromOrgToVolunteers', {
|
||||||
if (!res.ok) throw new Error("Błąd pobierania wydarzeń");
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ eventId, content: messageContent })
|
||||||
|
});
|
||||||
|
|
||||||
const events = await res.json();
|
if (response.ok) {
|
||||||
|
alert('Message sent successfully to all volunteers!');
|
||||||
|
} else {
|
||||||
|
let error = await response.text();
|
||||||
|
if (!error) error = `Status code: ${response.status}`;
|
||||||
|
alert('Failed to send message: ' + error);
|
||||||
|
console.error('Send message failed', response.status, error);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert('Error sending message: ' + error);
|
||||||
|
console.error('Fetch error:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadEvents(org_id: number, evs?: Promise<any>) {
|
||||||
|
const container = document.getElementById("eventList");
|
||||||
|
if (!container) return;
|
||||||
|
var events: any;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (evs == null) {
|
||||||
|
events = await getEvents();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
events = await evs;
|
||||||
|
}
|
||||||
|
|
||||||
if (events.length === 0) {
|
if (events.length === 0) {
|
||||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
container.innerHTML = "<p class='text-muted'>No events to display at this moment.</p>";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wyczyść kontener przed dodaniem nowych
|
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
|
|
||||||
for (const ev of events) {
|
for (const ev of events) {
|
||||||
const card = document.createElement("div");
|
const card = document.createElement("div");
|
||||||
card.className = "event-card filled";
|
card.className = "event-card filled";
|
||||||
card.innerHTML = `
|
|
||||||
<span>${ev.title}</span>
|
let formattedDate: string = new Intl.DateTimeFormat('en-US', {
|
||||||
<button class="remove-btn delete-btn" data-id="${ev.eventId}">−</button>
|
weekday: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
}).format(new Date(ev.eventDate));
|
||||||
|
|
||||||
|
const eventInfoSpan = document.createElement("span");
|
||||||
|
eventInfoSpan.innerHTML = `
|
||||||
|
<a href="/view.html?event=${ev.eventId}" style="color: #2898BD">${ev.title}</a>
|
||||||
|
<p style="margin: 0">👥 ${ev.organisation} | 📍 ${ev.location} | 📅 ${formattedDate}</p>
|
||||||
`;
|
`;
|
||||||
|
card.appendChild(eventInfoSpan);
|
||||||
|
|
||||||
|
if (org_id == ev.organisationId) {
|
||||||
|
const buttonsDiv = document.createElement("div");
|
||||||
|
buttonsDiv.className = "d-flex gap-2 mt-2";
|
||||||
|
|
||||||
|
const editBtn = document.createElement("button");
|
||||||
|
editBtn.className = "edit-btn mod-btn";
|
||||||
|
editBtn.id = "edit-btn";
|
||||||
|
editBtn.setAttribute("data-id", ev.eventId);
|
||||||
|
editBtn.title = "Edit event";
|
||||||
|
editBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#FFFFFF"><path d="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"/></svg>`;
|
||||||
|
|
||||||
|
const removeBtn = document.createElement("button");
|
||||||
|
removeBtn.className = "remove-btn mod-btn";
|
||||||
|
removeBtn.id = "remove-btn";
|
||||||
|
removeBtn.setAttribute("data-id", ev.eventId);
|
||||||
|
removeBtn.title = "Remove event";
|
||||||
|
removeBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#FFFFFF"><path d="M280-440h400v-80H280v80ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>`;
|
||||||
|
|
||||||
|
const sendMsgBtn = document.createElement("button");
|
||||||
|
sendMsgBtn.className = "btn btn-sm btn-info";
|
||||||
|
sendMsgBtn.textContent = "Send Message";
|
||||||
|
sendMsgBtn.setAttribute("data-id", ev.eventId);
|
||||||
|
sendMsgBtn.title = "Send message about this event";
|
||||||
|
sendMsgBtn.addEventListener("click", async () => {
|
||||||
|
await sendMessageForEvent(ev.eventId);
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonsDiv.appendChild(editBtn);
|
||||||
|
buttonsDiv.appendChild(removeBtn);
|
||||||
|
buttonsDiv.appendChild(sendMsgBtn);
|
||||||
|
|
||||||
|
card.appendChild(buttonsDiv);
|
||||||
|
}
|
||||||
|
|
||||||
container.appendChild(card);
|
container.appendChild(card);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
container.innerHTML = `<p class="text-danger">Błąd ładowania danych.</p>`;
|
container.innerHTML = `<p class="text-danger">General failure when trying to load data.</p>`;
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
|
|
||||||
|
var org_id: number = -1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
var user = await getMyAccount();
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
if (user.isOrganisation) {
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
unhideElementById(document, "addnewevent-btn");
|
||||||
|
org_id = user.organisationId;
|
||||||
|
}
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
|
||||||
|
loadEvents(org_id);
|
||||||
|
|
||||||
|
const listSortToggleButton = document.getElementById("list-sort-btn");
|
||||||
|
if (listSortToggleButton) {
|
||||||
|
listSortToggleButton.addEventListener("click", () => toggleListSortOrder(org_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
const optionsToggleButton = document.getElementById("optionsbtn");
|
||||||
|
if (optionsToggleButton) {
|
||||||
|
optionsToggleButton.addEventListener("click", () => toggleOptionsVisibility());
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchBar = document.getElementById('searchbar') as HTMLInputElement;
|
||||||
|
searchBar.addEventListener('keydown', (event) => {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
var searchResults = getEvents(searchBar.value);
|
||||||
|
loadEvents(org_id, searchResults);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
106
WebApp/ts/eventModify.ts
Normal file
106
WebApp/ts/eventModify.ts
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||||
|
|
||||||
|
const queryString = window.location.search;
|
||||||
|
const urlParams = new URLSearchParams(queryString);
|
||||||
|
const eventId = urlParams.get('event');
|
||||||
|
|
||||||
|
async function modifyEvent()
|
||||||
|
{
|
||||||
|
// Pobieranie danych z formularza
|
||||||
|
const title = (document.getElementById('title') as HTMLInputElement).value;
|
||||||
|
const location = (document.getElementById('location') as HTMLInputElement).value;
|
||||||
|
const description = (document.getElementById('description') as HTMLTextAreaElement).value;
|
||||||
|
const imageURL = (document.getElementById('imageURL') as HTMLInputElement).value;
|
||||||
|
const eventDateRaw = (document.getElementById('eventDate') as HTMLInputElement).value;
|
||||||
|
|
||||||
|
// Walidacja prostych pól
|
||||||
|
if (!title || !location || !eventDateRaw)
|
||||||
|
{
|
||||||
|
alert("Please fill out all of the required fields!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const eventDate = new Date(eventDateRaw).toISOString();
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
title,
|
||||||
|
location,
|
||||||
|
imageURL,
|
||||||
|
description,
|
||||||
|
eventDate,
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const response = await fetch('/api/events/' + eventId, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok)
|
||||||
|
{
|
||||||
|
const errorText = await response.text();
|
||||||
|
throw new Error(errorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
alert("Event modified!");
|
||||||
|
window.location.href = "/"; // Przekierowanie do strony głównej
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error occurred while trying to modify event:", error);
|
||||||
|
alert("Couldn't modify event, an error occurred: " + error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
|
var container = document.getElementById("mainContainer");
|
||||||
|
const saveBtn = document.getElementById("saveBtn");
|
||||||
|
|
||||||
|
try {
|
||||||
|
var user = await getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
if (user.isOrganisation) {
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
}
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveBtn)
|
||||||
|
{
|
||||||
|
saveBtn.addEventListener("click", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
modifyEvent();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (eventId !== null && container !== null) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
const titleInput = document.getElementById( 'title') as HTMLInputElement;
|
||||||
|
const locationInput = document.getElementById( 'location') as HTMLInputElement;
|
||||||
|
const descriptionInput = document.getElementById('description') as HTMLInputElement;
|
||||||
|
const dateInput = document.getElementById( 'eventDate') as HTMLInputElement;
|
||||||
|
const imageInput = document.getElementById( 'imageURL') as HTMLInputElement;
|
||||||
|
var ev = await getEvent(eventId);
|
||||||
|
|
||||||
|
if (ev === null) {
|
||||||
|
container.innerHTML = "<p class='text-muted'>Failed to load event data.</p>";
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
titleInput.value = ev.title || '';
|
||||||
|
locationInput.value = ev.location || '';
|
||||||
|
descriptionInput.value = ev.description || '';
|
||||||
|
dateInput.value = ev.eventDate.slice(0, 16) || '';
|
||||||
|
imageInput.value = ev.imageURL || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
container.innerHTML = `<p class="text-danger">` + err + `</p>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
178
WebApp/ts/eventView.ts
Normal file
178
WebApp/ts/eventView.ts
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
import { getEvent, getMyAccount, unhideElementById, getMyRegisteredEventIds } from './generalUseHelpers.js';
|
||||||
|
|
||||||
|
const queryString = window.location.search;
|
||||||
|
const urlParams = new URLSearchParams(queryString);
|
||||||
|
const eventId = urlParams.get('event');
|
||||||
|
var redirected = false;
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
|
|
||||||
|
var container = document.getElementById("mainContainer");
|
||||||
|
const modifyBtn = document.getElementById("editBtn");
|
||||||
|
const removeBtn = document.getElementById("removeBtn");
|
||||||
|
const applyBtn = document.getElementById("applyBtn");
|
||||||
|
const leaveBtn = document.getElementById("leaveBtn");
|
||||||
|
var org_id: number = -1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
var user = await getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
if (user.isOrganisation) {
|
||||||
|
org_id = user.organisationId;
|
||||||
|
}
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
|
||||||
|
var thisEvent = null;
|
||||||
|
try {
|
||||||
|
if (eventId) thisEvent = await getEvent(eventId);
|
||||||
|
} catch (err) {
|
||||||
|
if (container !== null) container.innerHTML = `<p class="text-danger">To wydarzenie nie istnieje! <a href="/" style="color:#2898BD;">Powr<77>t -></a></p>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisEvent == null) {
|
||||||
|
if (container !== null) container.innerHTML = `<p class="text-danger">Błąd we wczytywaniu wydarzenia. <a href="/" style="color:#2898BD;">Powrót -></a></p>`;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const titleText = document.getElementById( "titleText") as HTMLElement;
|
||||||
|
const locationText = document.getElementById( "locationText") as HTMLElement;
|
||||||
|
const descText = document.getElementById( "descText") as HTMLElement;
|
||||||
|
const dateText = document.getElementById( "dateText") as HTMLElement;
|
||||||
|
const organizerText = document.getElementById("organizerText") as HTMLElement;
|
||||||
|
const coverImage = document.getElementById( "coverImage") as HTMLImageElement;
|
||||||
|
const newdateText = new Date(thisEvent.eventDate).toLocaleDateString('pl-PL');
|
||||||
|
const newtimeText = new Date(thisEvent.eventDate).toLocaleTimeString('pl-PL');
|
||||||
|
|
||||||
|
|
||||||
|
titleText.innerHTML = thisEvent.title + ` (#${eventId})`;
|
||||||
|
locationText.innerHTML = "📍 Place: " + thisEvent.location;
|
||||||
|
descText.innerHTML = thisEvent.description;
|
||||||
|
dateText.innerHTML = "📅 When: " + newdateText + " " + newtimeText; //thisEvent.eventDate;
|
||||||
|
organizerText.innerHTML = "👥 Organized by: " + thisEvent.organisationName;
|
||||||
|
coverImage.src = thisEvent.imageURL
|
||||||
|
|
||||||
|
console.log(thisEvent.imageURL);
|
||||||
|
if (thisEvent.imageURL !== "") unhideElementById(document, "imgdiv");
|
||||||
|
|
||||||
|
if (org_id == thisEvent.organisationId) {
|
||||||
|
// Użytkownik jest organizacją, która
|
||||||
|
// stworzyła to wydarzenie
|
||||||
|
unhideElementById(document, "editBtn");
|
||||||
|
unhideElementById(document, "removeBtn");
|
||||||
|
} else if (org_id == -1) {
|
||||||
|
// Użytkownik jest wolontariuszem
|
||||||
|
try {
|
||||||
|
const registeredIds = await getMyRegisteredEventIds();
|
||||||
|
const isRegistered = registeredIds.includes(Number(eventId));
|
||||||
|
|
||||||
|
if (isRegistered) {
|
||||||
|
unhideElementById(document, "leaveBtn");
|
||||||
|
} else {
|
||||||
|
unhideElementById(document, "applyBtn");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
unhideElementById(document, "applyBtn");
|
||||||
|
(applyBtn as HTMLButtonElement).textContent = "log in to apply";
|
||||||
|
(applyBtn as HTMLButtonElement).addEventListener("click", async (e) => {
|
||||||
|
redirected = true;
|
||||||
|
window.location.href = "login.html";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modifyBtn) {
|
||||||
|
modifyBtn.addEventListener("click", (e) => {
|
||||||
|
window.location.href = "/modify.html?event=" + eventId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removeBtn) {
|
||||||
|
removeBtn.addEventListener("click", async (e) => {
|
||||||
|
const confirmed = confirm("Really delete?");
|
||||||
|
if (!confirmed) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Wysyła żądanie DELETE do API
|
||||||
|
const response = await fetch(`/api/events/${eventId}`, {
|
||||||
|
method: "DELETE"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
alert("Event deleted.");
|
||||||
|
window.location.href = "/";
|
||||||
|
} else {
|
||||||
|
alert("Couldn't delete event.");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
alert("Couldn't connect.");
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (applyBtn) {
|
||||||
|
applyBtn.addEventListener("click", async (e) => {
|
||||||
|
if (redirected) return;
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/events/join/${eventId}`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result: {
|
||||||
|
success: boolean;
|
||||||
|
error_msg?: string;
|
||||||
|
} = await response.json();
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
window.location.href = `/view.html?event=${eventId}`;
|
||||||
|
} else {
|
||||||
|
alert(`Error: ${result.error_msg ?? "Unknown error occurred."}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to apply:", error);
|
||||||
|
alert("Failed to apply.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leaveBtn) {
|
||||||
|
leaveBtn.addEventListener("click", async (e) => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/events/leave/${eventId}`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result: {
|
||||||
|
success: boolean;
|
||||||
|
error_msg?: string;
|
||||||
|
} = await response.json();
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
window.location.href = `/view.html?event=${eventId}`;
|
||||||
|
} else {
|
||||||
|
alert(`Error: ${result.error_msg ?? "Unknown error occurred."}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to leave:", error)
|
||||||
|
alert("Failed to leave.")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
63
WebApp/ts/generalUseHelpers.ts
Normal file
63
WebApp/ts/generalUseHelpers.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
interface EventData {
|
||||||
|
title: string;
|
||||||
|
location: string;
|
||||||
|
description: string;
|
||||||
|
imageURL: string;
|
||||||
|
eventDate: string;
|
||||||
|
organisationName: string,
|
||||||
|
organisationId: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MyAccount {
|
||||||
|
userId: number;
|
||||||
|
email: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
createdAt: string;
|
||||||
|
isOrganisation: boolean;
|
||||||
|
organisationId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function unhideElementById(document: Document, e: string) {
|
||||||
|
var element = document.getElementById(e);
|
||||||
|
if (element) {
|
||||||
|
element.classList.remove('hidden-before-load');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function hideElementById(document: Document, e: string) {
|
||||||
|
var element = document.getElementById(e);
|
||||||
|
if (element) {
|
||||||
|
element.classList.add('hidden-before-load');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getEvent(id: string): Promise<EventData> {
|
||||||
|
const res = await fetch("/api/events/" + id);
|
||||||
|
if (!res.ok) {
|
||||||
|
throw Error("To wydarzenie nie istnieje");
|
||||||
|
}
|
||||||
|
const events = await res.json();
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getMyAccount(): Promise<MyAccount> {
|
||||||
|
const res = await fetch("/api/auth/my_account");
|
||||||
|
if (!res.ok) {
|
||||||
|
throw Error("Użytkownik niezalogowany!");
|
||||||
|
}
|
||||||
|
const data = await res.json();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getMyRegisteredEventIds(): Promise<number[]> {
|
||||||
|
const res = await fetch("/api/auth/my_events");
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
throw Error("Użytkownik niezalogowany!");
|
||||||
|
}
|
||||||
|
|
||||||
|
const events = await res.json();
|
||||||
|
|
||||||
|
return events.map((event: { eventId: number }) => event.eventId);
|
||||||
|
}
|
||||||
38
WebApp/ts/login.ts
Normal file
38
WebApp/ts/login.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const form = document.getElementById("loginForm") as HTMLFormElement;
|
||||||
|
const message = document.getElementById("message") as HTMLParagraphElement;
|
||||||
|
|
||||||
|
form.addEventListener("submit", async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
message.textContent = "";
|
||||||
|
|
||||||
|
const email = (document.getElementById("email") as HTMLInputElement).value;
|
||||||
|
const password = (document.getElementById("password") as HTMLInputElement).value;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/auth/login", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ email, password }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
message.textContent = data.message || "Login failed.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.cookie = `token=${data.token}; path=/; SameSite=Lax; Secure`;
|
||||||
|
message.style.color = "green";
|
||||||
|
message.textContent = "Login successful!";
|
||||||
|
|
||||||
|
window.location.href = "/index.html";
|
||||||
|
} catch (error) {
|
||||||
|
message.textContent = "Something went wrong.";
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
103
WebApp/ts/messages.ts
Normal file
103
WebApp/ts/messages.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import { getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||||
|
// messages.ts
|
||||||
|
|
||||||
|
async function getMyMessages() {
|
||||||
|
const res = await fetch('/api/messages/my', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error('Failed to load messages');
|
||||||
|
return await res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(dateStr: string): string {
|
||||||
|
const date = new Date(dateStr);
|
||||||
|
return date.toLocaleString(undefined, {
|
||||||
|
year: 'numeric', month: 'short', day: 'numeric',
|
||||||
|
hour: '2-digit', minute: '2-digit'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createMessageCard(msg: any) {
|
||||||
|
const card = document.createElement('div');
|
||||||
|
card.className = 'messages-card';
|
||||||
|
|
||||||
|
const sender = msg.isMsgFromVolunteer
|
||||||
|
? `Volunteer #${msg.volunteerId}`
|
||||||
|
: `Organization #${msg.organizationId}`;
|
||||||
|
|
||||||
|
// Safely inject content as HTML because it contains links
|
||||||
|
const contentHtml = msg.content ?? '';
|
||||||
|
|
||||||
|
card.innerHTML = `
|
||||||
|
<button class="delete-btn" title="Delete message" data-id="${msg.messageId}">×</button>
|
||||||
|
<div class="message-header">${sender}</div>
|
||||||
|
<div class="message-date">${formatDate(msg.isoDate)}</div>
|
||||||
|
<div class="message-content">${contentHtml}</div>
|
||||||
|
<small><em>Regarding Event #${msg.eventType}</em></small>
|
||||||
|
`;
|
||||||
|
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteMessage(messageId: number) {
|
||||||
|
if (!confirm('Are you sure you want to delete this message?')) return;
|
||||||
|
|
||||||
|
const res = await fetch(`/api/messages/${messageId}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
alert('Failed to delete message.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload messages after delete
|
||||||
|
loadMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadMessages() {
|
||||||
|
const container = document.getElementById('messagesContainer');
|
||||||
|
if (!container) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const messages = await getMyMessages();
|
||||||
|
|
||||||
|
container.innerHTML = '';
|
||||||
|
if (messages.length === 0) {
|
||||||
|
container.innerHTML = `<p class="no-messages">No messages to display.</p>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
messages.forEach((msg: any) => {
|
||||||
|
const card = createMessageCard(msg);
|
||||||
|
container.appendChild(card);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Attach delete handlers
|
||||||
|
container.querySelectorAll('.delete-btn').forEach(btn => {
|
||||||
|
btn.addEventListener('click', () => {
|
||||||
|
const idStr = btn.getAttribute('data-id');
|
||||||
|
if (idStr) deleteMessage(parseInt(idStr));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
container.innerHTML = `<p class="no-messages text-danger">Failed to load messages.</p>`;
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
try {
|
||||||
|
var user = await getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
loadMessages();
|
||||||
|
});
|
||||||
192
WebApp/ts/userSkills.ts
Normal file
192
WebApp/ts/userSkills.ts
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
import { getEvent, getMyAccount, unhideElementById, getMyRegisteredEventIds } from './generalUseHelpers.js';
|
||||||
|
|
||||||
|
var redirected = false;
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
|
|
||||||
|
var container = document.getElementById("mainContainer");
|
||||||
|
const modifyBtn = document.getElementById("editBtn");
|
||||||
|
const removeBtn = document.getElementById("removeBtn");
|
||||||
|
const applyBtn = document.getElementById("applyBtn");
|
||||||
|
const leaveBtn = document.getElementById("leaveBtn");
|
||||||
|
var org_id: number = -1;
|
||||||
|
var org_name: string = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
var user = await getMyAccount();
|
||||||
|
if (user && user.isOrganisation) {
|
||||||
|
const org_id = user.organisationId;
|
||||||
|
fetch('/api/organizations/' + org_id)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
org_name = data.name;
|
||||||
|
unhideElementById(document, "orgname");
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Failed to fetch organization:', error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
unhideElementById(document, "orgno");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
window.location.href = "login.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
var thisAccount = null;
|
||||||
|
thisAccount = await getMyAccount();
|
||||||
|
if (thisAccount.isOrganisation) org_id = thisAccount.organisationId;
|
||||||
|
|
||||||
|
if (thisAccount == null) {
|
||||||
|
if (container !== null) container.innerHTML = `<p class="text-danger">Błąd we wczytywaniu wydarzenia. <a href="/" style="color:#2898BD;">Powrót -></a></p>`;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const nameText = document.getElementById("nameText") as HTMLElement;
|
||||||
|
const orgnameText = document.getElementById("orgname") as HTMLElement;
|
||||||
|
const dateText = document.getElementById("dateText") as HTMLElement;
|
||||||
|
const newdateText = new Date(thisAccount.createdAt).toLocaleDateString('pl-PL');
|
||||||
|
const newtimeText = new Date(thisAccount.createdAt).toLocaleTimeString('pl-PL');
|
||||||
|
|
||||||
|
|
||||||
|
nameText.innerHTML = thisAccount.firstName + " " + thisAccount.lastName + " (" + thisAccount.email + ")";
|
||||||
|
dateText.innerHTML = "📅 Account creation date: " + newdateText + " " + newtimeText;
|
||||||
|
orgnameText.innerHTML = "👥 Organization: " + org_name;
|
||||||
|
|
||||||
|
if (org_id == -1) {
|
||||||
|
unhideElementById(document, "skillscont");
|
||||||
|
} else if (org_id == -1) {
|
||||||
|
// Użytkownik jest wolontariuszem
|
||||||
|
try {
|
||||||
|
const registeredIds = await getMyRegisteredEventIds();
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
window.onload = () => {
|
||||||
|
const selectedSkillsContainer = document.getElementById('selected-skills') as HTMLDivElement;
|
||||||
|
const dropdown = document.getElementById('skill-dropdown') as HTMLSelectElement;
|
||||||
|
|
||||||
|
dropdown.addEventListener('change', () => {
|
||||||
|
const skillName = dropdown.options[dropdown.selectedIndex].text;
|
||||||
|
const skillId = dropdown.options[dropdown.selectedIndex].value;
|
||||||
|
if (skillName) {
|
||||||
|
addSkill(skillName, Number(skillId), false);
|
||||||
|
dropdown.value = ''; // Reset dropdown
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function fetchSkills() {
|
||||||
|
fetch('/api/skills')
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Network response was not ok');
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
populateDropdown(data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was a problem with the fetch operation:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchUserSkills() {
|
||||||
|
fetch('/api/auth/skills')
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Network response was not ok');
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
populateSkills(data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was a problem with the fetch operation:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate dropdown with fetched skills
|
||||||
|
function populateDropdown(skills: { skillId: number; skillName: string; }[]) {
|
||||||
|
skills.forEach(skill => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = skill.skillId.toString();
|
||||||
|
option.textContent = skill.skillName;
|
||||||
|
dropdown.appendChild(option);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateSkills(skills: { skillId: number; skillName: string; }[]) {
|
||||||
|
skills.forEach(skill => {
|
||||||
|
addSkill(skill.skillName, skill.skillId, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call fetchSkills to populate dropdown on load, same for fetchUserSkills()
|
||||||
|
fetchSkills();
|
||||||
|
fetchUserSkills();
|
||||||
|
|
||||||
|
function getRandomColor(): string {
|
||||||
|
|
||||||
|
const r = Math.floor(Math.random() * 256);
|
||||||
|
const g = Math.floor(Math.random() * 256);
|
||||||
|
const b = Math.floor(Math.random() * 256);
|
||||||
|
|
||||||
|
return `rgb(${r}, ${g}, ${b})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addSkill(skillName: string, skillId: number, dummy_add: boolean) {
|
||||||
|
if (!document.querySelector(`#selected-skills .skill[data-skill="${skillName}"]`)) {
|
||||||
|
const skillDiv = document.createElement('div');
|
||||||
|
skillDiv.className = 'skill';
|
||||||
|
skillDiv.textContent = skillName;
|
||||||
|
skillDiv.setAttribute('data-skill', skillName);
|
||||||
|
skillDiv.style.backgroundColor = getRandomColor();
|
||||||
|
|
||||||
|
if (!dummy_add) {
|
||||||
|
var skill = skillId;
|
||||||
|
var payload = {
|
||||||
|
skill
|
||||||
|
};
|
||||||
|
|
||||||
|
var res = await fetch('/api/auth/add_skill', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
var data = await res.json();
|
||||||
|
if (res.ok) skillDiv.remove();
|
||||||
|
else alert(data.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeButton = document.createElement('button');
|
||||||
|
removeButton.textContent = 'X';
|
||||||
|
removeButton.addEventListener('click', async () => {
|
||||||
|
var skill = skillId;
|
||||||
|
var payload = {
|
||||||
|
skill
|
||||||
|
};
|
||||||
|
|
||||||
|
var res = await fetch('/api/auth/remove_skill', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
var data = await res.json();
|
||||||
|
if (res.ok) skillDiv.remove();
|
||||||
|
else alert(data.message);
|
||||||
|
});
|
||||||
|
|
||||||
|
skillDiv.appendChild(removeButton);
|
||||||
|
selectedSkillsContainer.appendChild(skillDiv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
78
WebApp/wwwroot/calendar.html
Normal file
78
WebApp/wwwroot/calendar.html
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Event calendar</title>
|
||||||
|
|
||||||
|
<!-- Styles -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||||
|
<link href="/css/panel.css" rel="stylesheet" />
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.css" rel="stylesheet" />
|
||||||
|
</head>
|
||||||
|
<body class="bg-light">
|
||||||
|
|
||||||
|
<div class="d-flex">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="sidebar">
|
||||||
|
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="index.html" class="nav-link text-info mb-3">
|
||||||
|
<!-- Home icon -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Home</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="messages.html" class="nav-link text-info mb-3">
|
||||||
|
<!-- Chats icon -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Chats</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="calendar.html" class="nav-link text-info mb-3">
|
||||||
|
<!-- Calendar icon -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Calendar</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box mt-auto mb-4">
|
||||||
|
<a href="user.html" class="nav-link text-info mb-3">
|
||||||
|
<!-- Settings icon -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Settings</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Top Nav -->
|
||||||
|
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||||
|
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||||
|
<div>
|
||||||
|
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||||
|
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Main Content -->
|
||||||
|
<div class="main p-4">
|
||||||
|
<div class="events-card bg-white p-4 rounded-4 shadow position-relative">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||||
|
<h2 class="eventsText">My calendar</h2>
|
||||||
|
</div>
|
||||||
|
<div id="calendar"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js"></script>
|
||||||
|
<script type="module" src="/js/calendar.js"></script>
|
||||||
|
<script type="module" src="js/auth.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,44 +1,91 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="pl">
|
<html lang="pl">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Nowe wydarzenie</title>
|
<title>New event</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="/css/style.css" />
|
<link rel="stylesheet" href="/css/style.css" />
|
||||||
|
<link rel="stylesheet" href="/css/panel.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<body class="bg-light">
|
<body class="bg-light">
|
||||||
<div class="container mt-5">
|
<div class="">
|
||||||
<h1 class="mb-4">Utwórz wydarzenie</h1>
|
<!-- Sidebar -->
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="text-center mb-4">
|
||||||
|
</div>
|
||||||
|
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="index.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Home</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="messages.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Chats</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="calendar.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Calendar</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box mt-auto mb-4">
|
||||||
|
<a href="user.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Settings</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<!-- Top Nav -->
|
||||||
|
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||||
|
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||||
|
<div>
|
||||||
|
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||||
|
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="main hidden-before-load" id="mainContainer">
|
||||||
|
<h1 class="mb-4">Create a new event</h1>
|
||||||
|
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="title">Title</label>
|
||||||
|
<input id="title" class="form-control input-field" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="location">Location</label>
|
||||||
|
<input id="location" class="form-control input-field" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="description">Description</label>
|
||||||
|
<textarea id="description" class="form-control input-field"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="eventDate">Date</label>
|
||||||
|
<input id="eventDate" type="datetime-local" class="form-control input-field" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="imageURL">Poster Image URL (optional)</label>
|
||||||
|
<input id="imageURL" class="form-control input-field" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button id="saveBtn" class="button"><span>Save</span><span>⮞</span></button>
|
||||||
|
|
||||||
<div class="form-group mb-2">
|
|
||||||
<label for="title">Tytuł</label>
|
|
||||||
<input id="title" class="form-control" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group mb-2">
|
|
||||||
<label for="location">Lokalizacja</label>
|
|
||||||
<input id="location" class="form-control" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group mb-2">
|
|
||||||
<label for="description">Opis</label>
|
|
||||||
<textarea id="description" class="form-control"></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="form-group mb-2">
|
|
||||||
<label for="eventDate">Data</label>
|
|
||||||
<input id="eventDate" type="datetime-local" class="form-control" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group mb-4">
|
|
||||||
<label for="organisationId">ID Organizacji</label>
|
|
||||||
<input id="organisationId" type="number" class="form-control" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button id="saveBtn" class="button"><span>Zapisz</span><span>⮞</span></button>
|
<script type="module" src="/js/eventCreate.js"></script>
|
||||||
|
<script type="module" src="/js/generalUseHelpers.js"></script>
|
||||||
|
<script type="module" src="/js/auth.js"></script>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="module" src="/js/eventCreate.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,156 @@
|
|||||||
|
.logo {
|
||||||
|
font-family: 'Nunito', sans-serif;
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden-before-load {
|
||||||
|
display: none !important;
|
||||||
|
visibility: hidden !important;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Segoe UI', sans-serif;
|
font-family: 'Segoe UI', sans-serif;
|
||||||
}
|
}
|
||||||
|
.sidebar {
|
||||||
|
width: 120px;
|
||||||
|
position: fixed;
|
||||||
|
top: 113px;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: white;
|
||||||
|
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
.sidebar .nav-link {
|
||||||
|
text-align: center;
|
||||||
|
padding: 20px 0;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
.iconText {
|
||||||
|
color: #666666;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.topnav {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 113px;
|
||||||
|
background-color: white;
|
||||||
|
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
|
||||||
|
z-index: 1050;
|
||||||
|
padding: 0 70px;
|
||||||
|
}
|
||||||
|
.button-join {
|
||||||
|
width: 150px;
|
||||||
|
height: 50px;
|
||||||
|
background-color: #2898BD;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50px;
|
||||||
|
color: white;
|
||||||
|
font-weight:500;
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
.button-join:hover {
|
||||||
|
width: 150px;
|
||||||
|
height: 50px;
|
||||||
|
background-color: #2485A6;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50px;
|
||||||
|
color: white;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
.button-sign {
|
||||||
|
width: 150px;
|
||||||
|
height: 50px;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 2px, solid, #2898BD;
|
||||||
|
border-radius: 50px;
|
||||||
|
color: #2898BD;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
.button-sign:hover {
|
||||||
|
width: 150px;
|
||||||
|
height: 50px;
|
||||||
|
background-color: #2898BD;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50px;
|
||||||
|
color: white;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-box {
|
||||||
|
width: 90px;
|
||||||
|
height: 90px;
|
||||||
|
border-radius: 30px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 24px;
|
||||||
|
transition: box-shadow 0.2s ease;
|
||||||
|
cursor: pointer;
|
||||||
|
padding-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-box:hover {
|
||||||
|
box-shadow: 0 7px 10px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
margin-left: 10%; /* exact width of .sidebar */
|
||||||
|
margin-top: 113px; /* exact height of .topnav */
|
||||||
|
padding: 30px;
|
||||||
|
justify-content: center;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
.search-bar {
|
||||||
|
margin-left: 12%;
|
||||||
|
position: relative;
|
||||||
|
width: 60%;
|
||||||
|
}
|
||||||
|
.search-bar input {
|
||||||
|
height: 70px;
|
||||||
|
border: 2px solid #2898BD;
|
||||||
|
border-radius: 50px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-right: 3rem; /* Make space for the icon */
|
||||||
|
}
|
||||||
|
.search-bar input:focus {
|
||||||
|
height: 70px;
|
||||||
|
border: 3px solid #2898BD;
|
||||||
|
border-radius: 50px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-right: 3rem; /* Make space for the icon */
|
||||||
|
outline: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
.button-add {
|
||||||
|
background-color: #2898BD;
|
||||||
|
width: 70px;
|
||||||
|
height: 70px;
|
||||||
|
/* padding: 30px; */
|
||||||
|
z-index: 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.events-card {
|
||||||
|
width: 75%; /* or whatever your design max is */
|
||||||
|
margin: 0 auto; /* center it horizontally */
|
||||||
|
background-color: white;
|
||||||
|
padding: 3rem;
|
||||||
|
border-radius: 30px;
|
||||||
|
box-shadow: 0 7px 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.eventsText {
|
||||||
|
color: #2898BD;
|
||||||
|
}
|
||||||
|
|
||||||
#eventList .event-card {
|
#eventList .event-card {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 2px dashed #17a2b8;
|
border: 2px dashed #2898BD;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -17,12 +163,54 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#eventList .event-card .remove-btn {
|
#eventList .event-card .remove-btn {
|
||||||
background-color: #ff4d4d;
|
background-color: #F05234;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 50%;
|
border-radius: 30px;
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
width: 36px;
|
width: 99px;
|
||||||
height: 36px;
|
height: 50px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
margin: 0 5px 0 5px;
|
||||||
}
|
}
|
||||||
|
#eventList .event-card .remove-btn:hover {
|
||||||
|
background-color: #CD4A31;
|
||||||
|
border: none;
|
||||||
|
border-radius: 30px;
|
||||||
|
color: white;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
width: 99px;
|
||||||
|
height: 50px;
|
||||||
|
line-height: 1;
|
||||||
|
margin: 0 5px 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#eventList .event-card .edit-btn {
|
||||||
|
background-color: #9B9B9B;
|
||||||
|
border: none;
|
||||||
|
border-radius: 30px;
|
||||||
|
color: white;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
width: 99px;
|
||||||
|
height: 50px;
|
||||||
|
line-height: 1;
|
||||||
|
margin: 0 5px 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#eventList .event-card .edit-btn:hover {
|
||||||
|
background-color: #777;
|
||||||
|
border: none;
|
||||||
|
border-radius: 30px;
|
||||||
|
color: white;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
width: 99px;
|
||||||
|
height: 50px;
|
||||||
|
line-height: 1;
|
||||||
|
margin: 0 5px 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center-text {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
@@ -2,6 +2,11 @@ html {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hidden-before-load {
|
||||||
|
display: none !important;
|
||||||
|
visibility: hidden !important;
|
||||||
|
}
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
html {
|
html {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|||||||
@@ -1,6 +1,38 @@
|
|||||||
.button {
|
body {
|
||||||
border-radius: 4px;
|
color: #2898BD;
|
||||||
background-color: #f4511e;
|
}
|
||||||
|
|
||||||
|
#imgdiv {
|
||||||
|
padding-right: 2%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#coverImage {
|
||||||
|
min-width: 30em;
|
||||||
|
max-width: 50em;
|
||||||
|
border: 3px dashed #2898BD;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden-before-load {
|
||||||
|
display: none !important;
|
||||||
|
visibility: hidden !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-field {
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 2px solid #2898BD;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
.input-field:focus {
|
||||||
|
outline: none;
|
||||||
|
box-shadow: none;
|
||||||
|
border: 3px solid #2898BD;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
border-radius: 30px;
|
||||||
|
background-color: #2898BD;
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
@@ -35,3 +67,26 @@
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.selected-skills div {
|
||||||
|
padding: 5px 10px;
|
||||||
|
margin: 5px;
|
||||||
|
display: inline-block;
|
||||||
|
color: white;
|
||||||
|
border-radius: 5px;
|
||||||
|
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-skills div button {
|
||||||
|
margin-left: 10px;
|
||||||
|
color: red;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skill-dropdown {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|||||||
BIN
WebApp/wwwroot/img/friendly_help.jfif
Normal file
BIN
WebApp/wwwroot/img/friendly_help.jfif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
@@ -1,58 +1,101 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="pl">
|
<html lang="pl">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Events Panel</title>
|
<title>Events Panel</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||||
<link href="/css/panel.css" rel="stylesheet" />
|
<link href="/css/panel.css" rel="stylesheet" />
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-light">
|
<body class="bg-light">
|
||||||
|
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
<div class="bg-white border-end p-3 vh-100" style="width: 80px;">
|
<div class="sidebar">
|
||||||
<div class="text-center mb-4">
|
<div class="text-center mb-4">
|
||||||
<img src="/img/logo.svg" alt="Logo" style="width: 40px;">
|
</div>
|
||||||
|
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="index.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Home</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="messages.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Chats</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="calendar.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Calendar</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box mt-auto mb-4">
|
||||||
|
<a href="user.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Settings</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<nav class="nav flex-column text-center">
|
|
||||||
<a href="#" class="nav-link text-info mb-3">🏠</a>
|
|
||||||
<a href="#" class="nav-link text-info mb-3">💬</a>
|
|
||||||
<a href="#" class="nav-link text-info mb-3">📅</a>
|
|
||||||
<a href="#" class="nav-link text-info mt-auto">⚙️</a>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Main content -->
|
<!-- Top Nav -->
|
||||||
<div class="flex-grow-1 p-4">
|
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||||
<h2 class="text-primary">Events</h2>
|
|
||||||
<div>
|
<div>
|
||||||
<button class="btn btn-outline-info me-2">Join now</button>
|
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||||
<button class="btn btn-outline-secondary">Sign In</button>
|
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||||
|
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-group mb-4">
|
<!-- Main content -->
|
||||||
<input type="text" class="form-control rounded-start" placeholder="Search events..." />
|
<div class="main">
|
||||||
<span class="input-group-text bg-white"><i class="bi bi-search"></i></span>
|
<div class="position-relative search-bar">
|
||||||
</div>
|
<input type="text" class="form-control pe-5" placeholder="" id="searchbar" />
|
||||||
|
<span class="position-absolute top-50 end-0 translate-middle-y me-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z" /></svg>
|
||||||
|
</span>
|
||||||
|
|
||||||
<div id="eventList" class="d-grid gap-3">
|
|
||||||
<!-- Karty wydarzeń będą ładowane tutaj -->
|
|
||||||
<div class="event-card filled">
|
|
||||||
<span>Event Title</span>
|
|
||||||
<button class="remove-btn delete-btn" data-id="5">−</button> <!-- Przyciski usuwania z ID -->
|
|
||||||
</div>
|
</div>
|
||||||
|
<!--<a href="/create.html" class="button-add text-decoration-none">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#FFFFFF"><path d="M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z" /></svg>
|
||||||
|
</a>-->
|
||||||
|
<div class="events-card bg-white p-4 rounded-4 shadow position-relative">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||||
|
<h2 class="eventsText">Events</h2>
|
||||||
|
<span class="position-absolute end-0 translate-middle-y me-4" style="margin-top: 20px;">
|
||||||
|
<label for="fDate" id="flabel" class="hidden-before-load">From </label>
|
||||||
|
<input type="date" id="fDate" name="fDate" class="hidden-before-load">
|
||||||
|
<label for="tDate" id="tlabel" class="hidden-before-load"> To </label>
|
||||||
|
<input type="date" id="tDate" name="tDate" class="hidden-before-load">
|
||||||
|
<button class="btn btn-link" onclick="" id="optionsbtn">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z" /></svg>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-link" id="list-sort-btn" onclick=""><svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M320-440v-287L217-624l-57-56 200-200 200 200-57 56-103-103v287h-80ZM600-80 400-280l57-56 103 103v-287h80v287l103-103 57 56L600-80Z" /></svg></button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="eventList" class="d-grid gap-3">
|
||||||
|
<!-- Karty wydarzeń będą ładowane tutaj -->
|
||||||
|
<div class="event-card filled">
|
||||||
|
<span>Loading events... please wait.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module" src="/js/eventList.js"></script>
|
||||||
|
<script type="module" src="/js/eventDelete.js"></script>
|
||||||
|
<script type="module" src="/js/generalUseHelpers.js"></script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<a href="/create.html" class="button-add mt-xl-auto rounded-5 align-content-center center-text hidden-before-load" id="addnewevent-btn">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#FFFFFF"><path d="M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z" /></svg>
|
||||||
<!-- Dodaj nowe -->
|
</a>
|
||||||
<a href="/create.html" class="btn btn-success">+ Dodaj nowe</a>
|
<script type="module" src="/js/auth.js"></script>
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="module" src="/js/eventList.js"></script>
|
|
||||||
<script type="module" src="/js/eventDelete.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
56
WebApp/wwwroot/js/auth.js
Normal file
56
WebApp/wwwroot/js/auth.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
"use strict";
|
||||||
|
// /js/auth.ts
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
function deleteCookie(name) {
|
||||||
|
document.cookie = `${name}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`;
|
||||||
|
}
|
||||||
|
function logoutUser() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield fetch("/api/auth/logout", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
deleteCookie('token');
|
||||||
|
window.location.href = "/index.html";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function redirectToLogin() {
|
||||||
|
window.location.href = 'login.html';
|
||||||
|
}
|
||||||
|
function checkAuth() {
|
||||||
|
// Basic auth check via presence of token cookie
|
||||||
|
return document.cookie.includes('token=');
|
||||||
|
}
|
||||||
|
function setupAuthUI() {
|
||||||
|
const joinNowBtn = document.getElementById('joinnow-btn');
|
||||||
|
const signInBtn = document.getElementById('signin-btn');
|
||||||
|
const logoutBtn = document.getElementById('logout-btn');
|
||||||
|
const isAuthenticated = checkAuth();
|
||||||
|
if (joinNowBtn) {
|
||||||
|
joinNowBtn.classList.toggle('d-none', isAuthenticated);
|
||||||
|
joinNowBtn.addEventListener('click', redirectToLogin);
|
||||||
|
}
|
||||||
|
if (signInBtn) {
|
||||||
|
signInBtn.classList.toggle('d-none', isAuthenticated);
|
||||||
|
signInBtn.addEventListener('click', redirectToLogin);
|
||||||
|
}
|
||||||
|
if (logoutBtn) {
|
||||||
|
logoutBtn.classList.toggle('d-none', !isAuthenticated);
|
||||||
|
logoutBtn.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
logoutUser();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Initialize on load
|
||||||
|
document.addEventListener('DOMContentLoaded', setupAuthUI);
|
||||||
56
WebApp/wwwroot/js/calendar.js
Normal file
56
WebApp/wwwroot/js/calendar.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { unhideElementById, getMyAccount } from './generalUseHelpers.js';
|
||||||
|
function getRegisteredEvents() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const res = yield fetch("/api/events/registered");
|
||||||
|
if (!res.ok)
|
||||||
|
throw new Error("Couldn't load joined events");
|
||||||
|
const data = yield res.json();
|
||||||
|
return data.map((ev) => ({
|
||||||
|
title: ev.title,
|
||||||
|
start: ev.eventDate,
|
||||||
|
url: `/view.html?event=${ev.eventId}`
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
try {
|
||||||
|
var user = yield getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
const calendarEl = document.getElementById("calendar");
|
||||||
|
if (!calendarEl)
|
||||||
|
return;
|
||||||
|
const events = yield getRegisteredEvents();
|
||||||
|
const calendar = new window.FullCalendar.Calendar(calendarEl, {
|
||||||
|
initialView: 'dayGridMonth',
|
||||||
|
headerToolbar: {
|
||||||
|
left: 'prev,next today',
|
||||||
|
center: 'title',
|
||||||
|
right: 'dayGridMonth,timeGridWeek,listWeek'
|
||||||
|
},
|
||||||
|
themeSystem: 'bootstrap5',
|
||||||
|
events: events,
|
||||||
|
eventClick: function (info) {
|
||||||
|
if (info.event.url) {
|
||||||
|
window.location.href = info.event.url;
|
||||||
|
info.jsEvent.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
calendar.render();
|
||||||
|
}));
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,28 +7,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
console.log("TypeScript działa!");
|
import { getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||||
function createEvent() {
|
function createEvent() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Pobieranie danych z formularza
|
// Pobieranie danych z formularza
|
||||||
const title = document.getElementById('title').value;
|
const title = document.getElementById('title').value;
|
||||||
const location = document.getElementById('location').value;
|
const location = document.getElementById('location').value;
|
||||||
const description = document.getElementById('description').value;
|
const description = document.getElementById('description').value;
|
||||||
|
const imageURL = document.getElementById('imageURL').value;
|
||||||
const eventDateRaw = document.getElementById('eventDate').value;
|
const eventDateRaw = document.getElementById('eventDate').value;
|
||||||
const organisationIdRaw = document.getElementById('organisationId').value;
|
|
||||||
// Walidacja prostych pól
|
// Walidacja prostych pól
|
||||||
if (!title || !location || !eventDateRaw || !organisationIdRaw) {
|
if (!title || !location || !eventDateRaw) {
|
||||||
alert("Uzupełnij wszystkie wymagane pola!");
|
alert("Please fill out all of the required fields!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const eventDate = new Date(eventDateRaw).toISOString();
|
const eventDate = new Date(eventDateRaw).toISOString();
|
||||||
const organisationId = parseInt(organisationIdRaw);
|
|
||||||
const payload = {
|
const payload = {
|
||||||
title,
|
title,
|
||||||
location,
|
location,
|
||||||
description,
|
description,
|
||||||
|
imageURL,
|
||||||
eventDate,
|
eventDate,
|
||||||
organisationId
|
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const response = yield fetch('/api/events', {
|
const response = yield fetch('/api/events', {
|
||||||
@@ -41,21 +39,32 @@ function createEvent() {
|
|||||||
const errorText = yield response.text();
|
const errorText = yield response.text();
|
||||||
throw new Error(errorText);
|
throw new Error(errorText);
|
||||||
}
|
}
|
||||||
alert("Wydarzenie zostało utworzone!");
|
alert("Event created successfully!");
|
||||||
window.location.href = "/"; // Przekierowanie do strony głównej
|
window.location.href = "/"; // Przekierowanie do strony głównej
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error("Błąd podczas tworzenia:", error);
|
console.error("Couldn't create event:", error);
|
||||||
alert("Nie udało się utworzyć wydarzenia: " + error);
|
alert("Couldn't create new event: " + error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const saveBtn = document.getElementById("saveBtn");
|
const saveBtn = document.getElementById("saveBtn");
|
||||||
|
var user = yield getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
if (user.isOrganisation) {
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
}
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
if (saveBtn) {
|
if (saveBtn) {
|
||||||
saveBtn.addEventListener("click", (e) => {
|
saveBtn.addEventListener("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
createEvent();
|
createEvent();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|||||||
@@ -12,32 +12,39 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
// Obsługuje kliknięcie na przycisk "Usuń"
|
// Obsługuje kliknięcie na przycisk "Usuń"
|
||||||
document.body.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
document.body.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const target = e.target;
|
const target = e.target;
|
||||||
if (!target.matches(".delete-btn"))
|
if (!target.matches(".mod-btn"))
|
||||||
return; // Sprawdza, czy kliknięto przycisk "Usuń"
|
return; // Sprawdza, czy kliknięto przycisk "Usuń" lub "Edytuj"
|
||||||
const id = target.getAttribute("data-id"); // Pobiera ID wydarzenia
|
const id = target.getAttribute("data-id"); // Pobiera ID wydarzenia
|
||||||
if (!id)
|
if (!id)
|
||||||
return;
|
return;
|
||||||
const confirmed = confirm("Na pewno chcesz usunąć to wydarzenie?"); // Potwierdzenie usunięcia
|
switch (target.id) {
|
||||||
if (!confirmed)
|
case "edit-btn":
|
||||||
return;
|
window.location.href = "/modify.html?event=" + id;
|
||||||
try {
|
break;
|
||||||
// Wysyła żądanie DELETE do API
|
case "remove-btn":
|
||||||
const response = yield fetch(`/api/events/${id}`, {
|
const confirmed = confirm("Are you sure?"); // Potwierdzenie usunięcia
|
||||||
method: "DELETE"
|
if (!confirmed)
|
||||||
});
|
return;
|
||||||
if (response.ok) {
|
try {
|
||||||
// Usuwa kartę z DOM (bez przeładowania strony)
|
// Wysyła żądanie DELETE do API
|
||||||
const card = target.closest(".event-card");
|
const response = yield fetch(`/api/events/${id}`, {
|
||||||
if (card)
|
method: "DELETE"
|
||||||
card.remove();
|
});
|
||||||
}
|
if (response.ok) {
|
||||||
else {
|
// Usuwa kartę z DOM (bez przeładowania strony)
|
||||||
alert("Błąd podczas usuwania wydarzenia.");
|
const card = target.closest(".event-card");
|
||||||
}
|
if (card)
|
||||||
}
|
card.remove();
|
||||||
catch (err) {
|
}
|
||||||
alert("Błąd połączenia z serwerem.");
|
else {
|
||||||
console.error(err);
|
alert("Couldn't delete that event.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
alert("Server connection failure.");
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,33 +7,194 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
import { getMyAccount, unhideElementById, hideElementById } from './generalUseHelpers.js';
|
||||||
const container = document.getElementById("eventList");
|
var isAscending = false;
|
||||||
if (!container)
|
var optionsVisibility = false;
|
||||||
return;
|
function toggleListSortOrder(org_id) {
|
||||||
try {
|
isAscending = !isAscending;
|
||||||
const res = yield fetch("/api/events");
|
loadEvents(org_id);
|
||||||
if (!res.ok)
|
}
|
||||||
throw new Error("Błąd pobierania wydarzeń");
|
function toggleOptionsVisibility() {
|
||||||
|
optionsVisibility = !optionsVisibility;
|
||||||
|
if (optionsVisibility) {
|
||||||
|
unhideElementById(document, "fDate");
|
||||||
|
unhideElementById(document, "tDate");
|
||||||
|
unhideElementById(document, "flabel");
|
||||||
|
unhideElementById(document, "tlabel");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hideElementById(document, "fDate");
|
||||||
|
hideElementById(document, "tDate");
|
||||||
|
hideElementById(document, "flabel");
|
||||||
|
hideElementById(document, "tlabel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getEvents(titleOrDescription, fDate, tDate) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
var res;
|
||||||
|
var searchbar = document.getElementById("searchbar");
|
||||||
|
var eventDateFrom = document.getElementById('fDate').value;
|
||||||
|
var eventDateTo = document.getElementById('tDate').value;
|
||||||
|
if (titleOrDescription == null) {
|
||||||
|
titleOrDescription = searchbar.value;
|
||||||
|
}
|
||||||
|
if (optionsVisibility) {
|
||||||
|
var payload_visible = {
|
||||||
|
titleOrDescription,
|
||||||
|
eventDateFrom,
|
||||||
|
eventDateTo
|
||||||
|
};
|
||||||
|
res = yield fetch('/api/events/search' + (isAscending ? "?sort=asc" : ""), {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload_visible)
|
||||||
|
});
|
||||||
|
if (!res.ok)
|
||||||
|
throw new Error("Failed to get search results");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var payload_invisible = {
|
||||||
|
titleOrDescription
|
||||||
|
};
|
||||||
|
res = yield fetch('/api/events/search' + (isAscending ? "?sort=asc" : ""), {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload_invisible)
|
||||||
|
});
|
||||||
|
if (!res.ok)
|
||||||
|
throw new Error("Failed to get search results");
|
||||||
|
}
|
||||||
const events = yield res.json();
|
const events = yield res.json();
|
||||||
if (events.length === 0) {
|
return events;
|
||||||
container.innerHTML = "<p class='text-muted'>Brak wydarzeń do wyświetlenia.</p>";
|
});
|
||||||
|
}
|
||||||
|
function sendMessageForEvent(eventId) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const messageContent = `Help me with <a href="/view.html?event=${eventId}">this event</a>`;
|
||||||
|
try {
|
||||||
|
const response = yield fetch('/api/messages/sendFromOrgToVolunteers', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ eventId, content: messageContent })
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
alert('Message sent successfully to all volunteers!');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let error = yield response.text();
|
||||||
|
if (!error)
|
||||||
|
error = `Status code: ${response.status}`;
|
||||||
|
alert('Failed to send message: ' + error);
|
||||||
|
console.error('Send message failed', response.status, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
alert('Error sending message: ' + error);
|
||||||
|
console.error('Fetch error:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function loadEvents(org_id, evs) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const container = document.getElementById("eventList");
|
||||||
|
if (!container)
|
||||||
return;
|
return;
|
||||||
}
|
var events;
|
||||||
// Wyczyść kontener przed dodaniem nowych
|
try {
|
||||||
container.innerHTML = '';
|
if (evs == null) {
|
||||||
for (const ev of events) {
|
events = yield getEvents();
|
||||||
const card = document.createElement("div");
|
}
|
||||||
card.className = "event-card filled";
|
else {
|
||||||
card.innerHTML = `
|
events = yield evs;
|
||||||
<span>${ev.title}</span>
|
}
|
||||||
<button class="remove-btn delete-btn" data-id="${ev.eventId}">−</button>
|
if (events.length === 0) {
|
||||||
|
container.innerHTML = "<p class='text-muted'>No events to display at this moment.</p>";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
container.innerHTML = '';
|
||||||
|
for (const ev of events) {
|
||||||
|
const card = document.createElement("div");
|
||||||
|
card.className = "event-card filled";
|
||||||
|
let formattedDate = new Intl.DateTimeFormat('en-US', {
|
||||||
|
weekday: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
}).format(new Date(ev.eventDate));
|
||||||
|
const eventInfoSpan = document.createElement("span");
|
||||||
|
eventInfoSpan.innerHTML = `
|
||||||
|
<a href="/view.html?event=${ev.eventId}" style="color: #2898BD">${ev.title}</a>
|
||||||
|
<p style="margin: 0">👥 ${ev.organisation} | 📍 ${ev.location} | 📅 ${formattedDate}</p>
|
||||||
`;
|
`;
|
||||||
container.appendChild(card);
|
card.appendChild(eventInfoSpan);
|
||||||
|
if (org_id == ev.organisationId) {
|
||||||
|
const buttonsDiv = document.createElement("div");
|
||||||
|
buttonsDiv.className = "d-flex gap-2 mt-2";
|
||||||
|
const editBtn = document.createElement("button");
|
||||||
|
editBtn.className = "edit-btn mod-btn";
|
||||||
|
editBtn.id = "edit-btn";
|
||||||
|
editBtn.setAttribute("data-id", ev.eventId);
|
||||||
|
editBtn.title = "Edit event";
|
||||||
|
editBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#FFFFFF"><path d="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"/></svg>`;
|
||||||
|
const removeBtn = document.createElement("button");
|
||||||
|
removeBtn.className = "remove-btn mod-btn";
|
||||||
|
removeBtn.id = "remove-btn";
|
||||||
|
removeBtn.setAttribute("data-id", ev.eventId);
|
||||||
|
removeBtn.title = "Remove event";
|
||||||
|
removeBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#FFFFFF"><path d="M280-440h400v-80H280v80ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/></svg>`;
|
||||||
|
const sendMsgBtn = document.createElement("button");
|
||||||
|
sendMsgBtn.className = "btn btn-sm btn-info";
|
||||||
|
sendMsgBtn.textContent = "Send Message";
|
||||||
|
sendMsgBtn.setAttribute("data-id", ev.eventId);
|
||||||
|
sendMsgBtn.title = "Send message about this event";
|
||||||
|
sendMsgBtn.addEventListener("click", () => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield sendMessageForEvent(ev.eventId);
|
||||||
|
}));
|
||||||
|
buttonsDiv.appendChild(editBtn);
|
||||||
|
buttonsDiv.appendChild(removeBtn);
|
||||||
|
buttonsDiv.appendChild(sendMsgBtn);
|
||||||
|
card.appendChild(buttonsDiv);
|
||||||
|
}
|
||||||
|
container.appendChild(card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
container.innerHTML = `<p class="text-danger">General failure when trying to load data.</p>`;
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var org_id = -1;
|
||||||
|
try {
|
||||||
|
var user = yield getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
if (user.isOrganisation) {
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
unhideElementById(document, "addnewevent-btn");
|
||||||
|
org_id = user.organisationId;
|
||||||
|
}
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (_a) {
|
||||||
container.innerHTML = `<p class="text-danger">Błąd ładowania danych.</p>`;
|
unhideElementById(document, "joinnow-btn");
|
||||||
console.error(err);
|
unhideElementById(document, "signin-btn");
|
||||||
}
|
}
|
||||||
|
loadEvents(org_id);
|
||||||
|
const listSortToggleButton = document.getElementById("list-sort-btn");
|
||||||
|
if (listSortToggleButton) {
|
||||||
|
listSortToggleButton.addEventListener("click", () => toggleListSortOrder(org_id));
|
||||||
|
}
|
||||||
|
const optionsToggleButton = document.getElementById("optionsbtn");
|
||||||
|
if (optionsToggleButton) {
|
||||||
|
optionsToggleButton.addEventListener("click", () => toggleOptionsVisibility());
|
||||||
|
}
|
||||||
|
const searchBar = document.getElementById('searchbar');
|
||||||
|
searchBar.addEventListener('keydown', (event) => {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
var searchResults = getEvents(searchBar.value);
|
||||||
|
loadEvents(org_id, searchResults);
|
||||||
|
}
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|||||||
101
WebApp/wwwroot/js/eventModify.js
Normal file
101
WebApp/wwwroot/js/eventModify.js
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { getEvent, getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||||
|
const queryString = window.location.search;
|
||||||
|
const urlParams = new URLSearchParams(queryString);
|
||||||
|
const eventId = urlParams.get('event');
|
||||||
|
function modifyEvent() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// Pobieranie danych z formularza
|
||||||
|
const title = document.getElementById('title').value;
|
||||||
|
const location = document.getElementById('location').value;
|
||||||
|
const description = document.getElementById('description').value;
|
||||||
|
const imageURL = document.getElementById('imageURL').value;
|
||||||
|
const eventDateRaw = document.getElementById('eventDate').value;
|
||||||
|
// Walidacja prostych pól
|
||||||
|
if (!title || !location || !eventDateRaw) {
|
||||||
|
alert("Please fill out all of the required fields!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const eventDate = new Date(eventDateRaw).toISOString();
|
||||||
|
const payload = {
|
||||||
|
title,
|
||||||
|
location,
|
||||||
|
imageURL,
|
||||||
|
description,
|
||||||
|
eventDate,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const response = yield fetch('/api/events/' + eventId, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = yield response.text();
|
||||||
|
throw new Error(errorText);
|
||||||
|
}
|
||||||
|
alert("Event modified!");
|
||||||
|
window.location.href = "/"; // Przekierowanie do strony głównej
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error("Error occurred while trying to modify event:", error);
|
||||||
|
alert("Couldn't modify event, an error occurred: " + error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var container = document.getElementById("mainContainer");
|
||||||
|
const saveBtn = document.getElementById("saveBtn");
|
||||||
|
try {
|
||||||
|
var user = yield getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
if (user.isOrganisation) {
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
}
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
if (saveBtn) {
|
||||||
|
saveBtn.addEventListener("click", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
modifyEvent();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (eventId !== null && container !== null) {
|
||||||
|
try {
|
||||||
|
const titleInput = document.getElementById('title');
|
||||||
|
const locationInput = document.getElementById('location');
|
||||||
|
const descriptionInput = document.getElementById('description');
|
||||||
|
const dateInput = document.getElementById('eventDate');
|
||||||
|
const imageInput = document.getElementById('imageURL');
|
||||||
|
var ev = yield getEvent(eventId);
|
||||||
|
if (ev === null) {
|
||||||
|
container.innerHTML = "<p class='text-muted'>Failed to load event data.</p>";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
titleInput.value = ev.title || '';
|
||||||
|
locationInput.value = ev.location || '';
|
||||||
|
descriptionInput.value = ev.description || '';
|
||||||
|
dateInput.value = ev.eventDate.slice(0, 16) || '';
|
||||||
|
imageInput.value = ev.imageURL || '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
container.innerHTML = `<p class="text-danger">` + err + `</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
174
WebApp/wwwroot/js/eventView.js
Normal file
174
WebApp/wwwroot/js/eventView.js
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { getEvent, getMyAccount, unhideElementById, getMyRegisteredEventIds } from './generalUseHelpers.js';
|
||||||
|
const queryString = window.location.search;
|
||||||
|
const urlParams = new URLSearchParams(queryString);
|
||||||
|
const eventId = urlParams.get('event');
|
||||||
|
var redirected = false;
|
||||||
|
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var container = document.getElementById("mainContainer");
|
||||||
|
const modifyBtn = document.getElementById("editBtn");
|
||||||
|
const removeBtn = document.getElementById("removeBtn");
|
||||||
|
const applyBtn = document.getElementById("applyBtn");
|
||||||
|
const leaveBtn = document.getElementById("leaveBtn");
|
||||||
|
var org_id = -1;
|
||||||
|
try {
|
||||||
|
var user = yield getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
if (user.isOrganisation) {
|
||||||
|
org_id = user.organisationId;
|
||||||
|
}
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
var thisEvent = null;
|
||||||
|
try {
|
||||||
|
if (eventId)
|
||||||
|
thisEvent = yield getEvent(eventId);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
if (container !== null)
|
||||||
|
container.innerHTML = `<p class="text-danger">To wydarzenie nie istnieje! <a href="/" style="color:#2898BD;">Powr<77>t -></a></p>`;
|
||||||
|
}
|
||||||
|
if (thisEvent == null) {
|
||||||
|
if (container !== null)
|
||||||
|
container.innerHTML = `<p class="text-danger">Błąd we wczytywaniu wydarzenia. <a href="/" style="color:#2898BD;">Powrót -></a></p>`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const titleText = document.getElementById("titleText");
|
||||||
|
const locationText = document.getElementById("locationText");
|
||||||
|
const descText = document.getElementById("descText");
|
||||||
|
const dateText = document.getElementById("dateText");
|
||||||
|
const organizerText = document.getElementById("organizerText");
|
||||||
|
const coverImage = document.getElementById("coverImage");
|
||||||
|
const newdateText = new Date(thisEvent.eventDate).toLocaleDateString('pl-PL');
|
||||||
|
const newtimeText = new Date(thisEvent.eventDate).toLocaleTimeString('pl-PL');
|
||||||
|
titleText.innerHTML = thisEvent.title + ` (#${eventId})`;
|
||||||
|
locationText.innerHTML = "📍 Place: " + thisEvent.location;
|
||||||
|
descText.innerHTML = thisEvent.description;
|
||||||
|
dateText.innerHTML = "📅 When: " + newdateText + " " + newtimeText; //thisEvent.eventDate;
|
||||||
|
organizerText.innerHTML = "👥 Organized by: " + thisEvent.organisationName;
|
||||||
|
coverImage.src = thisEvent.imageURL;
|
||||||
|
console.log(thisEvent.imageURL);
|
||||||
|
if (thisEvent.imageURL !== "")
|
||||||
|
unhideElementById(document, "imgdiv");
|
||||||
|
if (org_id == thisEvent.organisationId) {
|
||||||
|
// Użytkownik jest organizacją, która
|
||||||
|
// stworzyła to wydarzenie
|
||||||
|
unhideElementById(document, "editBtn");
|
||||||
|
unhideElementById(document, "removeBtn");
|
||||||
|
}
|
||||||
|
else if (org_id == -1) {
|
||||||
|
// Użytkownik jest wolontariuszem
|
||||||
|
try {
|
||||||
|
const registeredIds = yield getMyRegisteredEventIds();
|
||||||
|
const isRegistered = registeredIds.includes(Number(eventId));
|
||||||
|
if (isRegistered) {
|
||||||
|
unhideElementById(document, "leaveBtn");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unhideElementById(document, "applyBtn");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (_b) {
|
||||||
|
unhideElementById(document, "applyBtn");
|
||||||
|
applyBtn.textContent = "log in to apply";
|
||||||
|
applyBtn.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
redirected = true;
|
||||||
|
window.location.href = "login.html";
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
}
|
||||||
|
if (modifyBtn) {
|
||||||
|
modifyBtn.addEventListener("click", (e) => {
|
||||||
|
window.location.href = "/modify.html?event=" + eventId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (removeBtn) {
|
||||||
|
removeBtn.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const confirmed = confirm("Really delete?");
|
||||||
|
if (!confirmed)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
// Wysyła żądanie DELETE do API
|
||||||
|
const response = yield fetch(`/api/events/${eventId}`, {
|
||||||
|
method: "DELETE"
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
alert("Event deleted.");
|
||||||
|
window.location.href = "/";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alert("Couldn't delete event.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
alert("Couldn't connect.");
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (applyBtn) {
|
||||||
|
applyBtn.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var _c;
|
||||||
|
if (redirected)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
const response = yield fetch(`/api/events/join/${eventId}`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const result = yield response.json();
|
||||||
|
if (result.success) {
|
||||||
|
window.location.href = `/view.html?event=${eventId}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alert(`Error: ${(_c = result.error_msg) !== null && _c !== void 0 ? _c : "Unknown error occurred."}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error("Failed to apply:", error);
|
||||||
|
alert("Failed to apply.");
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (leaveBtn) {
|
||||||
|
leaveBtn.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var _d;
|
||||||
|
try {
|
||||||
|
const response = yield fetch(`/api/events/leave/${eventId}`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const result = yield response.json();
|
||||||
|
if (result.success) {
|
||||||
|
window.location.href = `/view.html?event=${eventId}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alert(`Error: ${(_d = result.error_msg) !== null && _d !== void 0 ? _d : "Unknown error occurred."}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error("Failed to leave:", error);
|
||||||
|
alert("Failed to leave.");
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}));
|
||||||
55
WebApp/wwwroot/js/generalUseHelpers.js
Normal file
55
WebApp/wwwroot/js/generalUseHelpers.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function unhideElementById(document, e) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
var element = document.getElementById(e);
|
||||||
|
if (element) {
|
||||||
|
element.classList.remove('hidden-before-load');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function hideElementById(document, e) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
var element = document.getElementById(e);
|
||||||
|
if (element) {
|
||||||
|
element.classList.add('hidden-before-load');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function getEvent(id) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const res = yield fetch("/api/events/" + id);
|
||||||
|
if (!res.ok) {
|
||||||
|
throw Error("To wydarzenie nie istnieje");
|
||||||
|
}
|
||||||
|
const events = yield res.json();
|
||||||
|
return events;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function getMyAccount() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const res = yield fetch("/api/auth/my_account");
|
||||||
|
if (!res.ok) {
|
||||||
|
throw Error("Użytkownik niezalogowany!");
|
||||||
|
}
|
||||||
|
const data = yield res.json();
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function getMyRegisteredEventIds() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const res = yield fetch("/api/auth/my_events");
|
||||||
|
if (!res.ok) {
|
||||||
|
throw Error("Użytkownik niezalogowany!");
|
||||||
|
}
|
||||||
|
const events = yield res.json();
|
||||||
|
return events.map((event) => event.eventId);
|
||||||
|
});
|
||||||
|
}
|
||||||
42
WebApp/wwwroot/js/login.js
Normal file
42
WebApp/wwwroot/js/login.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const form = document.getElementById("loginForm");
|
||||||
|
const message = document.getElementById("message");
|
||||||
|
form.addEventListener("submit", (e) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
e.preventDefault();
|
||||||
|
message.textContent = "";
|
||||||
|
const email = document.getElementById("email").value;
|
||||||
|
const password = document.getElementById("password").value;
|
||||||
|
try {
|
||||||
|
const response = yield fetch("/api/auth/login", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ email, password }),
|
||||||
|
});
|
||||||
|
const data = yield response.json();
|
||||||
|
if (!response.ok) {
|
||||||
|
message.textContent = data.message || "Login failed.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.cookie = `token=${data.token}; path=/; SameSite=Lax; Secure`;
|
||||||
|
message.style.color = "green";
|
||||||
|
message.textContent = "Login successful!";
|
||||||
|
window.location.href = "/index.html";
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
message.textContent = "Something went wrong.";
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
107
WebApp/wwwroot/js/messages.js
Normal file
107
WebApp/wwwroot/js/messages.js
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { getMyAccount, unhideElementById } from './generalUseHelpers.js';
|
||||||
|
// messages.ts
|
||||||
|
function getMyMessages() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const res = yield fetch('/api/messages/my', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
});
|
||||||
|
if (!res.ok)
|
||||||
|
throw new Error('Failed to load messages');
|
||||||
|
return yield res.json();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function formatDate(dateStr) {
|
||||||
|
const date = new Date(dateStr);
|
||||||
|
return date.toLocaleString(undefined, {
|
||||||
|
year: 'numeric', month: 'short', day: 'numeric',
|
||||||
|
hour: '2-digit', minute: '2-digit'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function createMessageCard(msg) {
|
||||||
|
var _a;
|
||||||
|
const card = document.createElement('div');
|
||||||
|
card.className = 'messages-card';
|
||||||
|
const sender = msg.isMsgFromVolunteer
|
||||||
|
? `Volunteer #${msg.volunteerId}`
|
||||||
|
: `Organization #${msg.organizationId}`;
|
||||||
|
// Safely inject content as HTML because it contains links
|
||||||
|
const contentHtml = (_a = msg.content) !== null && _a !== void 0 ? _a : '';
|
||||||
|
card.innerHTML = `
|
||||||
|
<button class="delete-btn" title="Delete message" data-id="${msg.messageId}">×</button>
|
||||||
|
<div class="message-header">${sender}</div>
|
||||||
|
<div class="message-date">${formatDate(msg.isoDate)}</div>
|
||||||
|
<div class="message-content">${contentHtml}</div>
|
||||||
|
<small><em>Regarding Event #${msg.eventType}</em></small>
|
||||||
|
`;
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
function deleteMessage(messageId) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (!confirm('Are you sure you want to delete this message?'))
|
||||||
|
return;
|
||||||
|
const res = yield fetch(`/api/messages/${messageId}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
alert('Failed to delete message.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Reload messages after delete
|
||||||
|
loadMessages();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function loadMessages() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const container = document.getElementById('messagesContainer');
|
||||||
|
if (!container)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
const messages = yield getMyMessages();
|
||||||
|
container.innerHTML = '';
|
||||||
|
if (messages.length === 0) {
|
||||||
|
container.innerHTML = `<p class="no-messages">No messages to display.</p>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
messages.forEach((msg) => {
|
||||||
|
const card = createMessageCard(msg);
|
||||||
|
container.appendChild(card);
|
||||||
|
});
|
||||||
|
// Attach delete handlers
|
||||||
|
container.querySelectorAll('.delete-btn').forEach(btn => {
|
||||||
|
btn.addEventListener('click', () => {
|
||||||
|
const idStr = btn.getAttribute('data-id');
|
||||||
|
if (idStr)
|
||||||
|
deleteMessage(parseInt(idStr));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
container.innerHTML = `<p class="no-messages text-danger">Failed to load messages.</p>`;
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
document.addEventListener('DOMContentLoaded', () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
try {
|
||||||
|
var user = yield getMyAccount();
|
||||||
|
if (user) {
|
||||||
|
unhideElementById(document, "logout-btn");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
unhideElementById(document, "joinnow-btn");
|
||||||
|
unhideElementById(document, "signin-btn");
|
||||||
|
}
|
||||||
|
loadMessages();
|
||||||
|
}));
|
||||||
183
WebApp/wwwroot/js/userSkills.js
Normal file
183
WebApp/wwwroot/js/userSkills.js
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { getMyAccount, unhideElementById, getMyRegisteredEventIds } from './generalUseHelpers.js';
|
||||||
|
var redirected = false;
|
||||||
|
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var container = document.getElementById("mainContainer");
|
||||||
|
const modifyBtn = document.getElementById("editBtn");
|
||||||
|
const removeBtn = document.getElementById("removeBtn");
|
||||||
|
const applyBtn = document.getElementById("applyBtn");
|
||||||
|
const leaveBtn = document.getElementById("leaveBtn");
|
||||||
|
var org_id = -1;
|
||||||
|
var org_name = "";
|
||||||
|
try {
|
||||||
|
var user = yield getMyAccount();
|
||||||
|
if (user && user.isOrganisation) {
|
||||||
|
const org_id = user.organisationId;
|
||||||
|
fetch('/api/organizations/' + org_id)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
org_name = data.name;
|
||||||
|
unhideElementById(document, "orgname");
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Failed to fetch organization:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unhideElementById(document, "orgno");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
window.location.href = "login.html";
|
||||||
|
}
|
||||||
|
var thisAccount = null;
|
||||||
|
thisAccount = yield getMyAccount();
|
||||||
|
if (thisAccount.isOrganisation)
|
||||||
|
org_id = thisAccount.organisationId;
|
||||||
|
if (thisAccount == null) {
|
||||||
|
if (container !== null)
|
||||||
|
container.innerHTML = `<p class="text-danger">Błąd we wczytywaniu wydarzenia. <a href="/" style="color:#2898BD;">Powrót -></a></p>`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const nameText = document.getElementById("nameText");
|
||||||
|
const orgnameText = document.getElementById("orgname");
|
||||||
|
const dateText = document.getElementById("dateText");
|
||||||
|
const newdateText = new Date(thisAccount.createdAt).toLocaleDateString('pl-PL');
|
||||||
|
const newtimeText = new Date(thisAccount.createdAt).toLocaleTimeString('pl-PL');
|
||||||
|
nameText.innerHTML = thisAccount.firstName + " " + thisAccount.lastName + " (" + thisAccount.email + ")";
|
||||||
|
dateText.innerHTML = "📅 Account creation date: " + newdateText + " " + newtimeText;
|
||||||
|
orgnameText.innerHTML = "👥 Organization: " + org_name;
|
||||||
|
if (org_id == -1) {
|
||||||
|
unhideElementById(document, "skillscont");
|
||||||
|
}
|
||||||
|
else if (org_id == -1) {
|
||||||
|
// Użytkownik jest wolontariuszem
|
||||||
|
try {
|
||||||
|
const registeredIds = yield getMyRegisteredEventIds();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unhideElementById(document, "mainContainer");
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
window.onload = () => {
|
||||||
|
const selectedSkillsContainer = document.getElementById('selected-skills');
|
||||||
|
const dropdown = document.getElementById('skill-dropdown');
|
||||||
|
dropdown.addEventListener('change', () => {
|
||||||
|
const skillName = dropdown.options[dropdown.selectedIndex].text;
|
||||||
|
const skillId = dropdown.options[dropdown.selectedIndex].value;
|
||||||
|
if (skillName) {
|
||||||
|
addSkill(skillName, Number(skillId), false);
|
||||||
|
dropdown.value = ''; // Reset dropdown
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function fetchSkills() {
|
||||||
|
fetch('/api/skills')
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Network response was not ok');
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
populateDropdown(data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was a problem with the fetch operation:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function fetchUserSkills() {
|
||||||
|
fetch('/api/auth/skills')
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Network response was not ok');
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
populateSkills(data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was a problem with the fetch operation:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Populate dropdown with fetched skills
|
||||||
|
function populateDropdown(skills) {
|
||||||
|
skills.forEach(skill => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = skill.skillId.toString();
|
||||||
|
option.textContent = skill.skillName;
|
||||||
|
dropdown.appendChild(option);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function populateSkills(skills) {
|
||||||
|
skills.forEach(skill => {
|
||||||
|
addSkill(skill.skillName, skill.skillId, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Call fetchSkills to populate dropdown on load, same for fetchUserSkills()
|
||||||
|
fetchSkills();
|
||||||
|
fetchUserSkills();
|
||||||
|
function getRandomColor() {
|
||||||
|
const r = Math.floor(Math.random() * 256);
|
||||||
|
const g = Math.floor(Math.random() * 256);
|
||||||
|
const b = Math.floor(Math.random() * 256);
|
||||||
|
return `rgb(${r}, ${g}, ${b})`;
|
||||||
|
}
|
||||||
|
function addSkill(skillName, skillId, dummy_add) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (!document.querySelector(`#selected-skills .skill[data-skill="${skillName}"]`)) {
|
||||||
|
const skillDiv = document.createElement('div');
|
||||||
|
skillDiv.className = 'skill';
|
||||||
|
skillDiv.textContent = skillName;
|
||||||
|
skillDiv.setAttribute('data-skill', skillName);
|
||||||
|
skillDiv.style.backgroundColor = getRandomColor();
|
||||||
|
if (!dummy_add) {
|
||||||
|
var skill = skillId;
|
||||||
|
var payload = {
|
||||||
|
skill
|
||||||
|
};
|
||||||
|
var res = yield fetch('/api/auth/add_skill', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
var data = yield res.json();
|
||||||
|
if (res.ok)
|
||||||
|
skillDiv.remove();
|
||||||
|
else
|
||||||
|
alert(data.message);
|
||||||
|
}
|
||||||
|
const removeButton = document.createElement('button');
|
||||||
|
removeButton.textContent = 'X';
|
||||||
|
removeButton.addEventListener('click', () => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
var skill = skillId;
|
||||||
|
var payload = {
|
||||||
|
skill
|
||||||
|
};
|
||||||
|
var res = yield fetch('/api/auth/remove_skill', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
var data = yield res.json();
|
||||||
|
if (res.ok)
|
||||||
|
skillDiv.remove();
|
||||||
|
else
|
||||||
|
alert(data.message);
|
||||||
|
}));
|
||||||
|
skillDiv.appendChild(removeButton);
|
||||||
|
selectedSkillsContainer.appendChild(skillDiv);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
91
WebApp/wwwroot/login.html
Normal file
91
WebApp/wwwroot/login.html
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Sign in</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="/css/style.css" />
|
||||||
|
<link rel="stylesheet" href="/css/panel.css" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<body class="bg-light">
|
||||||
|
<div class="">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="text-center mb-4">
|
||||||
|
</div>
|
||||||
|
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="index.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Home</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="#" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Chats</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="calendar.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Calendar</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box mt-auto mb-4">
|
||||||
|
<a href="messages.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Settings</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<!-- Top Nav -->
|
||||||
|
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||||
|
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||||
|
<div>
|
||||||
|
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||||
|
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="main" id="mainContainer">
|
||||||
|
<h1 class="mb-4">Sign in to your organizational/volunteer account</h1>
|
||||||
|
|
||||||
|
<form id="loginForm">
|
||||||
|
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="email">Login</label>
|
||||||
|
<input type="email" id="email" class="form-control input-field" required />
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input type="password" id="password" class="form-control input-field" required />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<button id="logInBtn" class="button" type="submit">
|
||||||
|
<span>Log in</span>
|
||||||
|
<span>⮞</span>
|
||||||
|
</button>
|
||||||
|
<button id="signUpBtn" class="button" type="button" onclick="alert('Coming soon!')">
|
||||||
|
<span>Sign up</span>
|
||||||
|
<span>⮞</span>
|
||||||
|
</button>
|
||||||
|
<p id="message" style="color: red;"></p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module" src="/js/login.js"></script> <!-- defer? -->
|
||||||
|
<script type="module" src="/js/generalUseHelpers.js"></script>
|
||||||
|
<script type="module" src="/js/auth.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
112
WebApp/wwwroot/messages.html
Normal file
112
WebApp/wwwroot/messages.html
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Messages Panel</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet" />
|
||||||
|
<link href="/css/panel.css" rel="stylesheet" />
|
||||||
|
<style>
|
||||||
|
body.bg-light {
|
||||||
|
background-color: #f8f9fa !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.messages-card {
|
||||||
|
background: white;
|
||||||
|
padding: 1.5rem;
|
||||||
|
border-radius: 15px;
|
||||||
|
box-shadow: 0 0 10px rgb(0 0 0 / 0.1);
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-header {
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-date {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #888;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-content a {
|
||||||
|
color: #2898BD;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-btn {
|
||||||
|
float: right;
|
||||||
|
cursor: pointer;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: #dc3545;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-messages {
|
||||||
|
color: #777;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="bg-light">
|
||||||
|
|
||||||
|
<div class="d-flex">
|
||||||
|
<!-- Sidebar (z index.html) -->
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="text-center mb-4"></div>
|
||||||
|
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="index.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Home</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="messages.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Chats</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="calendar.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Calendar</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box mt-auto mb-4">
|
||||||
|
<a href="user.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Settings</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Top Nav (z index.html) -->
|
||||||
|
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||||
|
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||||
|
<div>
|
||||||
|
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||||
|
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Main content (WIADOMOŚCI zamiast eventList) -->
|
||||||
|
<div class="main p-4">
|
||||||
|
<h2 class="mb-4">Messages</h2>
|
||||||
|
<div id="messagesContainer" class="messages-card">
|
||||||
|
<p class="no-messages">Loading messages... please wait.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module" src="/js/messages.js"></script>
|
||||||
|
<script type="module" src="js/auth.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
93
WebApp/wwwroot/modify.html
Normal file
93
WebApp/wwwroot/modify.html
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Modify existing event</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="/css/style.css" />
|
||||||
|
<link rel="stylesheet" href="/css/panel.css" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<body class="bg-light">
|
||||||
|
<div class="">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="text-center mb-4">
|
||||||
|
</div>
|
||||||
|
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="index.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Home</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="messages.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Chats</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="calendar.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Calendar</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box mt-auto mb-4">
|
||||||
|
<a href="#" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Settings</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<!-- Top Nav -->
|
||||||
|
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||||
|
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||||
|
<div>
|
||||||
|
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||||
|
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="main hidden-before-load" id="mainContainer">
|
||||||
|
<h1 class="mb-4">Modify an existing event</h1>
|
||||||
|
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="title">Title</label>
|
||||||
|
<input id="title" class="form-control input-field" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="location">Location</label>
|
||||||
|
<input id="location" class="form-control input-field" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="description">Description</label>
|
||||||
|
<textarea id="description" class="form-control input-field"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="eventDate">Date</label>
|
||||||
|
<input id="eventDate" type="datetime-local" class="form-control input-field" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group mb-2">
|
||||||
|
<label for="imageURL">Poster Image URL (optional)</label>
|
||||||
|
<input id="imageURL" class="form-control input-field" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button id="saveBtn" class="button"><span>Update</span><span>⮞</span></button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module" src="/js/eventModify.js"></script>
|
||||||
|
<script type="module" src="/js/generalUseHelpers.js"></script>
|
||||||
|
<script type="module" src="/js/auth.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
||||||
85
WebApp/wwwroot/user.html
Normal file
85
WebApp/wwwroot/user.html
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>My account</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="/css/style.css" />
|
||||||
|
<link rel="stylesheet" href="/css/panel.css" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<body class="bg-light">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="text-center mb-4">
|
||||||
|
</div>
|
||||||
|
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="index.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Home</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="messages.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Chats</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="calendar.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Calendar</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box mt-auto mb-4">
|
||||||
|
<a href="user.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Settings</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<!-- Top Nav -->
|
||||||
|
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||||
|
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||||
|
<div>
|
||||||
|
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||||
|
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="main hidden-before-load" id="mainContainer">
|
||||||
|
<div>
|
||||||
|
<h1 class="mb-4">My profile</h1>
|
||||||
|
|
||||||
|
<h2 id="nameText">John Smith (email)</h2>
|
||||||
|
<h2 id="orgname" class="hidden-before-load">Account type: Organization</h2>
|
||||||
|
<h2 id="orgno" class="hidden-before-load">Account type: Volunteer</h2>
|
||||||
|
<h2 id="dateText">Created at: a long time ago</h2>
|
||||||
|
|
||||||
|
<div id="skillscont" class="skills-container hidden-before-load">
|
||||||
|
<h3>Skills:</h3>
|
||||||
|
<div id="selected-skills" class="selected-skills"></div>
|
||||||
|
<select id="skill-dropdown" class="skill-dropdown">
|
||||||
|
<option value="">Select a new skill</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module" src="/js/userSkills.js"></script>
|
||||||
|
<script type="module" src="/js/generalUseHelpers.js"></script>
|
||||||
|
<script type="module" src="/js/auth.js" defer></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
||||||
86
WebApp/wwwroot/view.html
Normal file
86
WebApp/wwwroot/view.html
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>View event details</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="/css/style.css" />
|
||||||
|
<link rel="stylesheet" href="/css/panel.css" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<body class="bg-light">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="text-center mb-4">
|
||||||
|
</div>
|
||||||
|
<nav class="sidebar d-flex flex-column align-items-center pt-3">
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="index.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Home</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="messages.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M880-80 720-240H320q-33 0-56.5-23.5T240-320v-40h440q33 0 56.5-23.5T760-440v-280h40q33 0 56.5 23.5T880-640v560ZM160-473l47-47h393v-280H160v327ZM80-280v-520q0-33 23.5-56.5T160-880h440q33 0 56.5 23.5T680-800v280q0 33-23.5 56.5T600-440H240L80-280Zm80-240v-280 280Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Chats</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box my-2">
|
||||||
|
<a href="calendar.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="M580-240q-42 0-71-29t-29-71q0-42 29-71t71-29q42 0 71 29t29 71q0 42-29 71t-71 29ZM200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Calendar</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="icon-box mt-auto mb-4">
|
||||||
|
<a href="user.html" class="nav-link text-info mb-3">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 -960 960 960" width="30px" fill="#2898BD"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z" /></svg>
|
||||||
|
<br /><h8 class="iconText">Settings</h8>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<!-- Top Nav -->
|
||||||
|
<div class="topnav d-flex justify-content-between align-items-center shadow">
|
||||||
|
<a href="index.html" class="eventsText m-0 logo text-decoration-none">Lend a Hand</a>
|
||||||
|
<div>
|
||||||
|
<button class="button-join hidden-before-load" id="joinnow-btn">Join now</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="signin-btn">Sign In</button>
|
||||||
|
<button class="button-sign hidden-before-load" id="logout-btn">Log out</button>
|
||||||
|
<svg class="position-relative" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#2898BD"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z" /></svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="main hidden-before-load" id="mainContainer" style="display: flex;">
|
||||||
|
<div class="hidden-before-load" id="imgdiv">
|
||||||
|
<img id="coverImage" src="/img/no_image.jpg" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1 class="mb-4" id="titleText">Event title</h1>
|
||||||
|
|
||||||
|
<h2 id="organizerText">Organized by: dummy organization</h2>
|
||||||
|
<h2 id="locationText">Place: 127.0.0.1</h2>
|
||||||
|
<h2 id="dateText">When: now or never!</h2>
|
||||||
|
<h3>Description:</h3>
|
||||||
|
<h4 id="descText"></h4><br />
|
||||||
|
|
||||||
|
<button id="applyBtn" class="button hidden-before-load"><span>Apply</span><span>⮞</span></button>
|
||||||
|
<button id="leaveBtn" class="button hidden-before-load"><span>Leave</span><span>⮞</span></button>
|
||||||
|
<button id="editBtn" class="button hidden-before-load"><span>Modify</span><span>⮞</span></button>
|
||||||
|
<button id="removeBtn" class="button hidden-before-load" style="background-color: red;"><span>Remove permanently</span><span>⮞</span></button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module" src="/js/eventView.js"></script>
|
||||||
|
<script type="module" src="/js/generalUseHelpers.js"></script>
|
||||||
|
<script type="module" src="/js/auth.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -5,7 +5,8 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"outDir": "WebApp/wwwroot/js",
|
"outDir": "WebApp/wwwroot/js",
|
||||||
"lib": [ "es2015", "dom" ]
|
"lib": [ "es2017", "dom" ]
|
||||||
},
|
},
|
||||||
"include": [ "WebApp/ts/**/*" ]
|
"include": [ "WebApp/ts/**/*" ],
|
||||||
|
"compileOnSave": true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user