-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initiala ändringar för övergången från Firebase till Expo. #161
Draft
theolli999
wants to merge
3
commits into
development
Choose a base branch
from
notifications
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Nexpo.Models | ||
{ | ||
/// <summary> | ||
/// Represents a notification topic | ||
/// </summary> | ||
public class NotificationTopic | ||
{ | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public int? Id { get; set; } | ||
|
||
[Required] | ||
public TopicType Topic { get; set; } | ||
|
||
[Required] | ||
[JsonIgnore] | ||
public User User { get; set; } | ||
|
||
|
||
|
||
public enum TopicType | ||
{ | ||
All, | ||
Administratior, | ||
CompanyRepresentative, | ||
Student, | ||
|
||
Volunteer, | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Nexpo.Models; | ||
using Microsoft.EntityFrameworkCore; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using static Nexpo.Models.NotificationTopic; //Denna borde ha importerats från Nexpo.Models? | ||
|
||
namespace Nexpo.Repositories | ||
{ | ||
public interface INotificationTopicRepository | ||
{ | ||
//public Task<IEnumerable<Event>> GetAll(); | ||
public Task<List<NotificationTopic>> GetUserTopics(User _user); | ||
public Task<List<User>> GetTopicSubscribers(NotificationTopic _topic); | ||
public Task Add(TopicType _topic, User user); | ||
public Task Delete(NotificationTopic _notificationTopic); | ||
} | ||
|
||
public class NotificationTopicRepository : INotificationTopicRepository | ||
{ | ||
private readonly ApplicationDbContext _context; | ||
|
||
public NotificationTopicRepository(ApplicationDbContext context) | ||
{ | ||
_context = context; | ||
} | ||
/* | ||
public async Task<IEnumerable<Event>> GetAll() | ||
{ | ||
return await _context.Events.OrderBy(_event => _event.Date) | ||
.ThenBy(_event => _event.Start) | ||
.Select(_event => new Event | ||
{ | ||
Id = _event.Id, | ||
Name = _event.Name, | ||
Description = _event.Description, | ||
Date = _event.Date, | ||
Type = _event.Type, | ||
Start = _event.Start, | ||
End = _event.End, | ||
Location = _event.Location, | ||
Host = _event.Host, | ||
Language = _event.Language, | ||
Capacity = _event.Capacity, | ||
TicketCount = _event.Tickets.Count() | ||
}) | ||
.ToListAsync(); | ||
} | ||
*/ | ||
|
||
|
||
public async Task<List<NotificationTopic>> GetUserTopics(User user) | ||
{ | ||
return await _context.NotificationTopic.Where(_topic => _topic.User == user).ToListAsync(); | ||
} | ||
public async Task<List<User>> GetTopicSubscribers(NotificationTopic topic) | ||
{ | ||
return await _context.NotificationTopic.Where(_topic => _topic.Topic == topic.Topic).Select(_topic => _topic.User).ToListAsync(); | ||
} | ||
|
||
|
||
public async Task Add(TopicType topic, User user) | ||
{ | ||
_context.NotificationTopic.Add(new NotificationTopic { Topic = topic, User = user }); | ||
await _context.SaveChangesAsync(); | ||
} | ||
|
||
|
||
public async Task Delete(NotificationTopic NotificationTopic) | ||
{ | ||
_context.NotificationTopic.Remove(NotificationTopic); | ||
await _context.SaveChangesAsync(); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jag är lite osäker på vad jag känner inför denna data modelen. Jag ser mycket hellre att vi endast har endast en single source of truth. Så den utgår från användarobjektet för att ta reda på vilka topics användaren borde ta del av. Så att konceptet att "subscribea" till en topic inte kanske finns kvar. (Om det var det som var tanken här?)
Om vi vill låta användaren välja vilka typer av notiser som ska tas emot ser jag hellre två stycken grupper där en kanske är Essential (eller ngt bättre namn) och Marketing. Och att man då i appen kan opta ut från marketing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tanken är dels att kunna skicka påminnelse notiser till studenter som "subscribat" på events. för detta krävs ny tabell som håller koll på relationen. Håller med om att notiser till särskilda sorters användare inte borde gå till på detta sätt dock.
Tänker vi har borde gå tillväga att vi lägger till/ändrar modeler så vi har
notification
UserNotification - join table för many-to-many relation mellan vilka användare är länkade till vilka notiser
public enum NotificationType
I User får man även lägga till UserNotifications collection för att representera alla notiser som sagd användare ska få. Via den tabellen kan användaren även hämta dess egna notiser vilket ger history vilket var skevt implementerat innan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Är tanken sen att man ska kunna deep-linka med t.ex eventId i
notification
sedan? @LeoFjatstromThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
se här för hur man går tillväga med ändringar i databasen också
https://learn.microsoft.com/sv-se/ef/ef6/modeling/code-first/workflows/existing-database
allt med ef6 kan vara viktigt.
för bätte step-by-step utan att bli förvirrade se Update database i readmen