-
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 all commits
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
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,37 @@ | ||
using System; | ||
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 Notification | ||
{ | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public int? Id { get; set; } | ||
|
||
[Required] | ||
public string Message { get; set; } | ||
[Required] | ||
public DateTime ScheduledTime { get; set; } | ||
[Required] | ||
public NotificationType Type { get; set; } | ||
[Required] | ||
public int? EventId { get; set; } | ||
|
||
|
||
|
||
|
||
public enum NotificationType | ||
{ | ||
General, | ||
EventReminder, | ||
InternalMessage, | ||
} | ||
|
||
} | ||
} | ||
|
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,25 @@ | ||
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 UserNotification | ||
{ | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public int UserId { get; set; } | ||
[Required] | ||
[JsonIgnore] | ||
public User User { get; set; } | ||
[Required] | ||
public int NotificationId { get; set; } | ||
[Required] | ||
[JsonIgnore] | ||
public Notification Notification { get; set; } | ||
|
||
} | ||
} | ||
|
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,64 @@ | ||
using Nexpo.Models; | ||
using Microsoft.EntityFrameworkCore; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System; | ||
|
||
namespace Nexpo.Repositories | ||
{ | ||
public interface INotificationRepository | ||
{ | ||
public Task<Notification> Get(int id); | ||
public Task Add(Notification _notification); | ||
public Task Update(Notification _notification); | ||
public Task Remove(Notification _notification); | ||
public Task<List<Notification>> GetAllNotExpired(DateTime date, Notification.NotificationType type); | ||
} | ||
|
||
public class NotificationRepository : INotificationRepository | ||
{ | ||
private readonly ApplicationDbContext _context; | ||
|
||
public NotificationRepository(ApplicationDbContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public Task<Notification> Get(int id) | ||
{ | ||
return _context.Notification.FirstOrDefaultAsync(_notification => _notification.Id == id); | ||
} | ||
public async Task Add(Notification _notification) | ||
{ | ||
_context.Notification.Add(_notification); | ||
await _context.SaveChangesAsync(); | ||
} | ||
public async Task Remove(Notification _notification) | ||
{ | ||
_context.Notification.Remove(_notification); | ||
await _context.SaveChangesAsync(); | ||
} | ||
public Task Update(Notification _notification){ | ||
_context.Entry(_notification).State = EntityState.Modified; | ||
return _context.SaveChangesAsync(); | ||
|
||
} | ||
public async Task<List<Notification>> GetAllNotExpired(DateTime date, Notification.NotificationType type) | ||
{ | ||
return await _context.Notification.Where(_notification => _notification.ScheduledTime > date && _notification.Type == type).ToListAsync(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
} |
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,52 @@ | ||
using Nexpo.Models; | ||
using Microsoft.EntityFrameworkCore; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System; | ||
|
||
namespace Nexpo.Repositories | ||
{ | ||
public interface IUserNotificationRepository | ||
{ | ||
public Task<UserNotification> Get(int userId, int notificationId); | ||
public Task Add(UserNotification _userNotification); | ||
public Task Update(UserNotification _userNotification); | ||
public Task Remove(UserNotification _userNotification); | ||
|
||
} | ||
|
||
public class UserNotificationRepository : IUserNotificationRepository | ||
{ | ||
private readonly ApplicationDbContext _context; | ||
|
||
public UserNotificationRepository(ApplicationDbContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public Task<UserNotification> Get(int userId, int notificationId) | ||
{ | ||
return _context.UserNotification.FirstOrDefaultAsync(_userNotification => _userNotification.UserId == userId | ||
&& _userNotification.NotificationId == notificationId); | ||
} | ||
public async Task Add(UserNotification _userNotification) | ||
{ | ||
_context.UserNotification.Add(_userNotification); | ||
await _context.SaveChangesAsync(); | ||
} | ||
public async Task Remove(UserNotification _userNotification) | ||
{ | ||
_context.UserNotification.Remove(_userNotification); | ||
await _context.SaveChangesAsync(); | ||
} | ||
|
||
public Task Update(UserNotification _userNotification){ | ||
_context.Entry(_userNotification).State = EntityState.Modified; | ||
return _context.SaveChangesAsync(); | ||
|
||
} | ||
|
||
|
||
} | ||
} |
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
Oops, something went wrong.
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.
Se: careerfairsystems/nexpo-app#351 (review)
tl;dr, att skicka upp UserId:t såhär, nog inte bästa idéen.