From 0f42ba4a6a0da7fabebe7b78729e4b96dd5fb9be Mon Sep 17 00:00:00 2001 From: "[Diana.deac]" <[diana.deac@qubiz.com]> Date: Mon, 9 Dec 2024 15:34:52 +0200 Subject: [PATCH 1/3] Add backround service for reset reminders --- .../Qubiz.GoogleKeep.Api/Program.cs | 31 +++++++++- .../ReminderCommandHandler.cs | 40 ++++++++++++- .../ReminderCommands/ReminderCommands.cs | 4 ++ .../Services/CurrentUserService.cs | 37 ++++++++++++ .../Qubiz.GoogleKeep.Common/Identity/Roles.cs | 1 + .../ReminderResetService.cs | 60 +++++++++++++++++++ 6 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Services/CurrentUserService.cs create mode 100644 Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Services/BackgroundServices/ReminderResetService.cs diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Program.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Program.cs index d3a07b2..9cb6236 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Program.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Program.cs @@ -1,10 +1,14 @@ using FluentValidation; +using Microsoft.AspNetCore.Identity; using Microsoft.OpenApi.Models; using Qubiz.GoogleKeep.Api.Filters; using Qubiz.GoogleKeep.Api.Initialization; using Qubiz.GoogleKeep.Application.Bootstrap; using Qubiz.GoogleKeep.Application.Common; +using Qubiz.GoogleKeep.Common.Identity; +using Qubiz.GoogleKeep.Domain.Entities; using Qubiz.GoogleKeep.Infrastructure.Bootstrap; +using Qubiz.GoogleKeep.Infrastructure.Services.BackgroundServices; using Qubiz.GoogleKeep.Persistence.Bootstrap; var builder = WebApplication.CreateBuilder(args); @@ -46,14 +50,37 @@ builder.Services.AddSwaggerGen(options => }); }); - - builder.Services.RegisterApplicationServices(); builder.Services.RegisterInfrastructureServices(); builder.Services.RegisterPersistenceServices(); +builder.Services.AddHostedService<ReminderResetService>(); + var app = builder.Build(); + +IServiceScope scope = app.Services.CreateScope(); + +using (var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>()) +{ + var SysUser = new ApplicationUser + { + Email = "system@gmail.com", + UserName = "system", + FirstName = "System", + LastName = "System", + DisplayName = "System", + EmailConfirmed = true + }; + + var user = await userManager.FindByEmailAsync(SysUser.Email); + if (user == null) + { + await userManager.CreateAsync(SysUser, "Systempassword"); + await userManager.AddToRoleAsync(SysUser, Roles.System); + } +} + // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommandHandler.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommandHandler.cs index a92aea5..08590d0 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommandHandler.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommandHandler.cs @@ -10,7 +10,8 @@ namespace Qubiz.GoogleKeep.Application.Commands.ReminderCommands; public class ReminderCommandHandler(IRepository<Reminder> reminderRepository) : IRequestHandler<CreateReminderCommand, CommandResponse<ReminderDto>>, IRequestHandler<UpdateReminderCommand, CommandResponse>, -IRequestHandler<DeleteReminderCommand, CommandResponse> +IRequestHandler<DeleteReminderCommand, CommandResponse>, +IRequestHandler<SetDateReminderCommand, CommandResponse> { public async Task<CommandResponse<ReminderDto>> Handle(CreateReminderCommand request, CancellationToken cancellationToken) @@ -67,4 +68,41 @@ IRequestHandler<DeleteReminderCommand, CommandResponse> return CommandResponse.Ok(); } + + public async Task<CommandResponse> Handle(SetDateReminderCommand request, CancellationToken cancellationToken) + { + try + { + IQueryable<Domain.Entities.Reminder> reminders = reminderRepository.Query(); + foreach (var reminder in reminders) + { + if (reminder.Date < DateOnly.FromDateTime(DateTime.Now) || + (reminder.Date == DateOnly.FromDateTime(DateTime.Now) && reminder.Hour < TimeOnly.FromDateTime(DateTime.Now))) + { + switch (reminder.RepeatingType) + { + case RepeatingType.Daily: + reminder.Date = reminder.Date.AddDays(1); + break; + case RepeatingType.Weekly: + reminder.Date = reminder.Date.AddDays(7); + break; + case RepeatingType.Monthly: + reminder.Date = reminder.Date.AddMonths(1); + break; + case RepeatingType.Yearly: + reminder.Date = reminder.Date.AddYears(1); + break; + } + } + } + await reminderRepository.SaveChangesAsync(cancellationToken); + + return CommandResponse.Ok(); + } + catch (Exception ex) + { + throw; + } + } } diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommands.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommands.cs index c8fe6a0..cc1623a 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommands.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommands.cs @@ -18,5 +18,9 @@ namespace Qubiz.GoogleKeep.Application.Commands.ReminderCommands { public Guid Id { get; set; } } + public class SetDateReminderCommand : BaseRequest<CommandResponse> + { + + } } } diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Services/CurrentUserService.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Services/CurrentUserService.cs new file mode 100644 index 0000000..d4774f1 --- /dev/null +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Services/CurrentUserService.cs @@ -0,0 +1,37 @@ +using System.Security.Claims; +using MediatR; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Qubiz.GoogleKeep.Application.Services.Interfaces; +using Qubiz.GoogleKeep.Domain.Entities; + +namespace Qubiz.GoogleKeep.Application.Services; +public class CurrentUserService(IHttpContextAccessor httpContextAccessor, + UserManager<ApplicationUser> userManager) : ICurrentUserService +{ + public async Task<CurrentUser> GetCurrentUser() + { + ApplicationUser user; + if (httpContextAccessor.HttpContext == null) + { + user = await userManager.FindByEmailAsync("system@gmail.com"); + } + else + { + if (!httpContextAccessor.HttpContext.User.Identity.IsAuthenticated) + { + return null; + } + user = await userManager.FindByIdAsync(httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value); + } + return user == null + ? null + : new CurrentUser() + { + Id = user.Id, + }; + } +} diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Common/Identity/Roles.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Common/Identity/Roles.cs index 47b6c0d..4a7f4b5 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Common/Identity/Roles.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Common/Identity/Roles.cs @@ -3,4 +3,5 @@ public class Roles { public const string User = "User"; + public const string System = "System"; } diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Services/BackgroundServices/ReminderResetService.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Services/BackgroundServices/ReminderResetService.cs new file mode 100644 index 0000000..99254ad --- /dev/null +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Services/BackgroundServices/ReminderResetService.cs @@ -0,0 +1,60 @@ +using MediatR; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Qubiz.GoogleKeep.Application.Services.Interfaces; +using static Qubiz.GoogleKeep.Application.Commands.ReminderCommands.ReminderComands; + +namespace Qubiz.GoogleKeep.Infrastructure.Services.BackgroundServices; + +public class ReminderResetService : BackgroundService +{ + private readonly IServiceScopeFactory serviceScopeFactory; + private readonly ILogger<ReminderResetService> logger; + + public ReminderResetService( + ILogger<ReminderResetService> logger, + IServiceScopeFactory serviceScopeFactory) + { + this.logger = logger; + this.serviceScopeFactory = serviceScopeFactory; + } + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + logger.LogInformation("starting service..."); + + while (!stoppingToken.IsCancellationRequested) + { + + logger.LogInformation($"executing reminder logic at time : {DateTime.Now}"); + + var now = DateTime.UtcNow; + var midnight = now.Date.AddDays(1); //resetez time la 00:00 cu .Date deci plus o zi va fi miezul noptii de maine + var timeUntilMidnight = midnight - now; + + if (timeUntilMidnight.TotalMicroseconds > 0) + { + logger.LogInformation("service will run (again) at midnight"); + await Task.Delay(timeUntilMidnight); + } + logger.LogInformation("resetting reminders date..."); + + try + { + using (var scope = serviceScopeFactory.CreateScope()) + { + var mediator = scope.ServiceProvider.GetRequiredService<IMediator>(); + var currentUserService = scope.ServiceProvider.GetRequiredService<ICurrentUserService>(); + + var commandResponse = await mediator.Send(new SetDateReminderCommand(), stoppingToken); + logger.LogInformation($"task executed successfully: {commandResponse}"); + } + } + catch (Exception ex) + { + logger.LogError(ex, "an error occured while resetting the reminders"); + } + } + logger.LogInformation("ReminderResetService is stopping."); + } +} -- GitLab From dba9171734a4f620962d446be470d16a65f13467 Mon Sep 17 00:00:00 2001 From: "[Diana.deac]" <[diana.deac@qubiz.com]> Date: Thu, 12 Dec 2024 09:36:43 +0200 Subject: [PATCH 2/3] controller fixes --- .../Controllers/AuthController.cs | 4 ++-- .../Controllers/CheckboxController.cs | 2 +- .../Controllers/LabelController.cs | 7 ++++--- .../Controllers/NotesController.cs | 2 +- .../Controllers/ReminderController.cs | 2 +- .../Qubiz.GoogleKeep.Api/Program.cs | 19 ++++++++++++++----- .../Commands/LabelCommands/LabelCommand.cs | 4 +--- .../LabelCommands/LabelCommandHandler.cs | 2 +- .../LabelCommands/LabelCommandValidator.cs | 8 +------- .../ReminderCommandHandler.cs | 2 +- .../Dto/ReminderDto.cs | 1 - .../Bootstrap/Bootstrap.cs | 2 +- .../ReminderResetService.cs | 1 + 13 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/AuthController.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/AuthController.cs index d0aed48..2d32594 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/AuthController.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/AuthController.cs @@ -18,7 +18,7 @@ public class AuthController : BaseController } [HttpPost("Login")] - [ProducesResponseType((int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(TokenResponse), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(CommandResponse), (int)HttpStatusCode.BadRequest)] public async Task<IActionResult> Login([FromBody] UserLoginCommand userLoginCommand) { @@ -27,7 +27,7 @@ public class AuthController : BaseController } [HttpPost("Refresh")] - [ProducesResponseType((int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(TokenResponse), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(CommandResponse), (int)HttpStatusCode.BadRequest)] public async Task<IActionResult> Refresh([FromBody] RefreshTokenCommand refreshTokenCommand) { diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/CheckboxController.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/CheckboxController.cs index 8e2aa09..9bab85d 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/CheckboxController.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/CheckboxController.cs @@ -46,7 +46,7 @@ namespace Qubiz.GoogleKeep.Api.Controllers } [HttpPut("{Id}")] - [ProducesResponseType(typeof(CommandResponse<CheckboxDto>), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(CommandResponse), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] [ProducesResponseType((int)HttpStatusCode.NotFound)] public async Task<IActionResult> UpdateCheckboxText([FromRoute] Guid id, [FromBody] CheckboxDto checkboxDto) diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/LabelController.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/LabelController.cs index 3b0d29b..b3ccd87 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/LabelController.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/LabelController.cs @@ -1,10 +1,11 @@ using System.Net; using Microsoft.AspNetCore.Mvc; +using Qubiz.GoogleKeep.Application.Commands.LabelCommands; using Qubiz.GoogleKeep.Application.Common; using Qubiz.GoogleKeep.Application.Dto; using Qubiz.GoogleKeep.Application.Queries.Label; using Qubiz.GoogleKeep.Web.Controllers.Base; -using static Qubiz.GoogleKeep.Application.Commands.LabelCommands.LabelCommand; + namespace Qubiz.GoogleKeep.Api.Controllers { @@ -13,7 +14,7 @@ namespace Qubiz.GoogleKeep.Api.Controllers public class LabelController : BaseController { [HttpPost("")] - [ProducesResponseType(typeof(CommandResponse<LabelDto>), (int)HttpStatusCode.Created)] + [ProducesResponseType(typeof(CommandResponse<LabelDto>), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] public async Task<IActionResult> CreateLabel([FromBody] LabelDto labelDto) { @@ -25,7 +26,7 @@ namespace Qubiz.GoogleKeep.Api.Controllers } [HttpPut("{id}")] - [ProducesResponseType(typeof(CommandResponse<LabelDto>), (int)HttpStatusCode.NoContent)] + [ProducesResponseType(typeof(CommandResponse), (int)HttpStatusCode.NoContent)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] [ProducesResponseType((int)HttpStatusCode.NotFound)] public async Task<IActionResult> UpdateLabel([FromRoute] Guid id, [FromBody] LabelDto labelDto) diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/NotesController.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/NotesController.cs index 2475cfc..a683d67 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/NotesController.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/NotesController.cs @@ -58,7 +58,7 @@ public class NotesController : BaseController : NotFound(); } [HttpPut()] - [ProducesResponseType(typeof(CommandResponse<NoteDto>), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(CommandResponse), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] [ProducesResponseType((int)HttpStatusCode.NotFound)] public async Task<IActionResult> UpdateNote([FromRoute] Guid id, [FromBody] NoteDto noteDto) diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/ReminderController.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/ReminderController.cs index 094f4fa..6d292c3 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/ReminderController.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Controllers/ReminderController.cs @@ -13,7 +13,7 @@ namespace Qubiz.GoogleKeep.Api.Controllers; public class ReminderController : BaseController { [HttpPost("")] - [ProducesResponseType(typeof(CommandResponse), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(CommandResponse<ReminderDto>), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] public async Task<IActionResult> CreateReminder([FromBody] ReminderDto reminderDto) { diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Program.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Program.cs index 9cb6236..bf0807f 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Program.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Api/Program.cs @@ -15,7 +15,15 @@ var builder = WebApplication.CreateBuilder(args); builder.ConfigureDbContext(); builder.ConfigureIdentity(); - +builder.Services.AddCors(options => +{ + options.AddPolicy("AllowAnyOrigin", policy => + { + policy.AllowAnyOrigin() + .AllowAnyHeader() + .AllowAnyMethod(); + }); +}); builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(BaseResponse).Assembly)); builder.Services.AddValidatorsFromAssembly(typeof(BaseResponse).Assembly); @@ -29,8 +37,9 @@ builder.Services.AddSwaggerGen(options => Name = "Authorization", Description = "Enter the Bearer Authorization string as following: `Bearer Generated-JWT-Token`. You need to execute one of the Login methods to get the token.", In = ParameterLocation.Header, - Type = SecuritySchemeType.ApiKey, - Scheme = "Bearer" + Type = SecuritySchemeType.Http, + Scheme = "Bearer", + BearerFormat = "JWT", }); options.AddSecurityRequirement(new OpenApiSecurityRequirement { @@ -58,7 +67,7 @@ builder.Services.AddHostedService<ReminderResetService>(); var app = builder.Build(); - +app.UseCors("AllowAnyOrigin"); IServiceScope scope = app.Services.CreateScope(); using (var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>()) @@ -91,7 +100,7 @@ if (app.Environment.IsDevelopment()) app.UseHttpsRedirection(); app.UseAuthorization(); - +app.UseAuthentication(); app.MapControllers(); app.Run(); diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommand.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommand.cs index 8f6841a..ccde5d7 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommand.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommand.cs @@ -2,8 +2,7 @@ using Qubiz.GoogleKeep.Application.Dto; namespace Qubiz.GoogleKeep.Application.Commands.LabelCommands; -public class LabelCommand -{ + public class CreateLabelCommand : BaseRequest<CommandResponse<LabelDto>> { public LabelDto LabelDto { get; set; } @@ -17,4 +16,3 @@ public class LabelCommand { public Guid Id { get; set; } } -} diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommandHandler.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommandHandler.cs index 52917ee..7d4b557 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommandHandler.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommandHandler.cs @@ -4,7 +4,7 @@ using Qubiz.GoogleKeep.Application.Common; using Qubiz.GoogleKeep.Application.Dto; using Qubiz.GoogleKeep.Domain.Entities; using Qubiz.GoogleKeep.Domain.Repositories; -using static Qubiz.GoogleKeep.Application.Commands.LabelCommands.LabelCommand; + namespace Qubiz.GoogleKeep.Application.Commands.LabelCommands { diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommandValidator.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommandValidator.cs index 33675cb..89da80d 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommandValidator.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/LabelCommands/LabelCommandValidator.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FluentValidation; -using static Qubiz.GoogleKeep.Application.Commands.LabelCommands.LabelCommand; +using FluentValidation; namespace Qubiz.GoogleKeep.Application.Commands.LabelCommands { diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommandHandler.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommandHandler.cs index 08590d0..84abd7d 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommandHandler.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/ReminderCommands/ReminderCommandHandler.cs @@ -26,7 +26,7 @@ IRequestHandler<SetDateReminderCommand, CommandResponse> RepeatingType = request.ReminderDto.RepeatingType, }; - request.ReminderDto.Id = newReminder.NoteId; + request.ReminderDto.NoteId = newReminder.NoteId; reminderRepository.Add(newReminder); await reminderRepository.SaveChangesAsync(cancellationToken); diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Dto/ReminderDto.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Dto/ReminderDto.cs index 291f75a..7092eb2 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Dto/ReminderDto.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Dto/ReminderDto.cs @@ -4,7 +4,6 @@ namespace Qubiz.GoogleKeep.Application.Dto { public class ReminderDto { - public Guid Id { get; set; } public Guid NoteId { get; set; } public RepeatingType RepeatingType { get; set; } public DateOnly Date { get; set; } diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Bootstrap/Bootstrap.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Bootstrap/Bootstrap.cs index 6471cb8..0000200 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Bootstrap/Bootstrap.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Bootstrap/Bootstrap.cs @@ -21,7 +21,7 @@ public static class ServiceBuilderExtensions .AsImplementedInterfaces() .WithScopedLifetime()); - services.AddScoped<ICurrentUserService, CurrentUserService>(); + services.AddScoped<ICurrentUserService, Application.Services.CurrentUserService>(); services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CurrentUserBehavior<,>)); services.AddTransient(typeof(IPipelineBehavior<,>), typeof(RequestValidationBehavior<,>)); } diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Services/BackgroundServices/ReminderResetService.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Services/BackgroundServices/ReminderResetService.cs index 99254ad..298178e 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Services/BackgroundServices/ReminderResetService.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Infrastructure/Services/BackgroundServices/ReminderResetService.cs @@ -53,6 +53,7 @@ public class ReminderResetService : BackgroundService catch (Exception ex) { logger.LogError(ex, "an error occured while resetting the reminders"); + } } logger.LogInformation("ReminderResetService is stopping."); -- GitLab From c60a0298da46d5d494974e7bd4354d4c6381e839 Mon Sep 17 00:00:00 2001 From: "[Diana.deac]" <[diana.deac@qubiz.com]> Date: Mon, 16 Dec 2024 09:36:39 +0200 Subject: [PATCH 3/3] add is deleted in notes --- .../.vite/deps_temp_ffa87ec9/package.json | 3 + .../NoteCommands/NoteCommandHandler.cs | 4 +- .../Dto/NoteDto.cs | 2 + .../Queries/Label/LabelQueriesHandler.cs | 7 +- .../Queries/Note/NoteQueryHandler.cs | 9 +- .../Qubiz.GoogleKeep.Domain/Entities/Note.cs | 3 + ...1213123214_AddIsDeletedInNotes.Designer.cs | 516 ++++++++++++++++++ .../20241213123214_AddIsDeletedInNotes.cs | 29 + .../AssetsDbContextModelSnapshot.cs | 3 + 9 files changed, 573 insertions(+), 3 deletions(-) create mode 100644 Qubiz.GoogleKeep.UI/.vite/deps_temp_ffa87ec9/package.json create mode 100644 Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/20241213123214_AddIsDeletedInNotes.Designer.cs create mode 100644 Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/20241213123214_AddIsDeletedInNotes.cs diff --git a/Qubiz.GoogleKeep.UI/.vite/deps_temp_ffa87ec9/package.json b/Qubiz.GoogleKeep.UI/.vite/deps_temp_ffa87ec9/package.json new file mode 100644 index 0000000..3dbc1ca --- /dev/null +++ b/Qubiz.GoogleKeep.UI/.vite/deps_temp_ffa87ec9/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/NoteCommands/NoteCommandHandler.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/NoteCommands/NoteCommandHandler.cs index a827412..a2e69d7 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/NoteCommands/NoteCommandHandler.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Commands/NoteCommands/NoteCommandHandler.cs @@ -24,7 +24,8 @@ public class NoteCommandHandler(IRepository<Note> noteRepository) : Created = request.NoteDto.Created, Updated = request.NoteDto.Updated, IsPinned = request.NoteDto.IsPinned, - UserId = request.User.Id, + UserId = new Guid("422E64C3-A2EA-4696-0D42-08DD0AC2735E"), + IsDeleted = request.NoteDto.IsDeleted, }; noteRepository.Add(newNote); await noteRepository.SaveChangesAsync(cancellationToken); @@ -65,6 +66,7 @@ public class NoteCommandHandler(IRepository<Note> noteRepository) : existingNote.Created = request.NoteDto.Created; existingNote.Updated = request.NoteDto.Updated; existingNote.IsPinned = request.NoteDto.IsPinned; + existingNote.IsDeleted = request.NoteDto.IsDeleted; await noteRepository.SaveChangesAsync(cancellationToken); diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Dto/NoteDto.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Dto/NoteDto.cs index 8538001..720622e 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Dto/NoteDto.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Dto/NoteDto.cs @@ -7,4 +7,6 @@ public class NoteDto public DateTime Created { get; set; } public DateTime Updated { get; set; } public bool IsPinned { get; set; } + + public bool IsDeleted { get; set; } } diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Queries/Label/LabelQueriesHandler.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Queries/Label/LabelQueriesHandler.cs index b9bf7ab..4354532 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Queries/Label/LabelQueriesHandler.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Queries/Label/LabelQueriesHandler.cs @@ -22,6 +22,9 @@ public class LabelQueryHandler(IRepository<Domain.Entities.Label> labelRepositor { Id = p.Id, Name = p.Name, + CreatedDate = p.CreatedDate, + UpdatedDate = p.UpdatedDate + }); List<LabelDto> labelItems = await labelsDto.ToListAsync(cancellationToken); @@ -36,7 +39,9 @@ public class LabelQueryHandler(IRepository<Domain.Entities.Label> labelRepositor .Select(l => new LabelDto { Id = l.Id, - Name = l.Name + Name = l.Name, + CreatedDate = l.CreatedDate, + UpdatedDate = l.UpdatedDate }).FirstOrDefaultAsync(cancellationToken); return labelDto; diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Queries/Note/NoteQueryHandler.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Queries/Note/NoteQueryHandler.cs index 755b8ca..17b3e74 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Queries/Note/NoteQueryHandler.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Application/Queries/Note/NoteQueryHandler.cs @@ -20,6 +20,7 @@ public class NoteQueryHandler(IRepository<Domain.Entities.Note> noteRepository) IsPinned = note.IsPinned, Created = note.Created, Updated = note.Updated, + IsDeleted = note.IsDeleted, }).FirstOrDefaultAsync(cancellationToken); return noteDto; @@ -30,7 +31,13 @@ public class NoteQueryHandler(IRepository<Domain.Entities.Note> noteRepository) List<NoteDto> noteDtos = await noteRepository.Query().Select(t => new NoteDto { Id = t.Id, - Description = t.Description + Title = t.Title, + IsPinned = t.IsPinned, + Created = t.Created, + Updated = t.Updated, + Description = t.Description, + IsDeleted = t.IsDeleted, + }).ToListAsync(cancellationToken); return noteDtos; diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Domain/Entities/Note.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Domain/Entities/Note.cs index 191cba7..760d5ce 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Domain/Entities/Note.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Domain/Entities/Note.cs @@ -18,4 +18,7 @@ public class Note } public virtual Reminder Reminder { get; set; } public virtual ICollection<Checkbox> Checkboxes { get; set; } + + public bool IsDeleted { get; set; } + } diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/20241213123214_AddIsDeletedInNotes.Designer.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/20241213123214_AddIsDeletedInNotes.Designer.cs new file mode 100644 index 0000000..c6e4000 --- /dev/null +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/20241213123214_AddIsDeletedInNotes.Designer.cs @@ -0,0 +1,516 @@ +// <auto-generated /> +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Qubiz.GoogleKeep.Persistence; + +#nullable disable + +namespace Qubiz.GoogleKeep.Persistence.Migrations +{ + [DbContext(typeof(GoogleKeepDbContext))] + [Migration("20241213123214_AddIsDeletedInNotes")] + partial class AddIsDeletedInNotes + { + /// <inheritdoc /> + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); + + b.Property<string>("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property<Guid>("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); + + b.Property<string>("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property<Guid>("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => + { + b.Property<string>("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property<string>("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property<string>("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property<Guid>("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => + { + b.Property<Guid>("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property<string>("Name") + .HasColumnType("nvarchar(450)"); + + b.Property<string>("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.ApplicationUser", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<int>("AccessFailedCount") + .HasColumnType("int"); + + b.Property<string>("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property<bool>("EmailConfirmed") + .HasColumnType("bit"); + + b.Property<string>("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("LockoutEnabled") + .HasColumnType("bit"); + + b.Property<DateTimeOffset?>("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property<string>("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property<string>("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property<string>("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property<string>("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property<string>("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Checkbox", b => + { + b.Property<Guid>("Id") + .HasColumnType("uniqueidentifier"); + + b.Property<bool>("Checked") + .HasColumnType("bit"); + + b.Property<Guid>("NoteId") + .HasColumnType("uniqueidentifier"); + + b.Property<string>("Text") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("NoteId"); + + b.ToTable("Checkboxes"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Label", b => + { + b.Property<Guid>("Id") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("CreatedDate") + .HasColumnType("datetime2"); + + b.Property<string>("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property<DateTime>("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Labels"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Log", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("CallStack") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("ExceptionMessage") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("ExceptionSource") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Level") + .HasColumnType("nvarchar(max)"); + + b.Property<DateTime>("LoggedAt") + .HasColumnType("datetime2"); + + b.Property<string>("Logger") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("MachineName") + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Message") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Logs"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Note", b => + { + b.Property<Guid>("Id") + .HasColumnType("uniqueidentifier"); + + b.Property<DateTime>("Created") + .HasColumnType("datetime2"); + + b.Property<string>("Description") + .HasColumnType("nvarchar(max)"); + + b.Property<bool>("IsDeleted") + .HasColumnType("bit"); + + b.Property<bool>("IsPinned") + .HasColumnType("bit"); + + b.Property<string>("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property<DateTime>("Updated") + .HasColumnType("datetime2"); + + b.Property<Guid>("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Notes"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.NoteLabel", b => + { + b.Property<Guid>("NoteId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("LabelId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("NoteId", "LabelId"); + + b.HasIndex("LabelId"); + + b.ToTable("NoteLabels"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Reminder", b => + { + b.Property<Guid>("NoteId") + .HasColumnType("uniqueidentifier"); + + b.Property<DateOnly>("Date") + .HasColumnType("date"); + + b.Property<TimeOnly>("Hour") + .HasColumnType("time"); + + b.Property<int>("RepeatingType") + .HasColumnType("int"); + + b.Property<bool>("Seen") + .HasColumnType("bit"); + + b.HasKey("NoteId"); + + b.ToTable("Reminders"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Role", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property<string>("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property<string>("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property<string>("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.UserRole", b => + { + b.Property<Guid>("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property<Guid>("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.Role", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Checkbox", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.Note", "Note") + .WithMany("Checkboxes") + .HasForeignKey("NoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Note"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Note", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.ApplicationUser", "User") + .WithMany("Notes") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.NoteLabel", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.Label", "Label") + .WithMany("NoteLabels") + .HasForeignKey("LabelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.Note", "Note") + .WithMany("NoteLabels") + .HasForeignKey("NoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Label"); + + b.Navigation("Note"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Reminder", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.Note", "Note") + .WithOne("Reminder") + .HasForeignKey("Qubiz.GoogleKeep.Domain.Entities.Reminder", "NoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Note"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.UserRole", b => + { + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Qubiz.GoogleKeep.Domain.Entities.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.ApplicationUser", b => + { + b.Navigation("Notes"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Label", b => + { + b.Navigation("NoteLabels"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Note", b => + { + b.Navigation("Checkboxes"); + + b.Navigation("NoteLabels"); + + b.Navigation("Reminder"); + }); + + modelBuilder.Entity("Qubiz.GoogleKeep.Domain.Entities.Role", b => + { + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/20241213123214_AddIsDeletedInNotes.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/20241213123214_AddIsDeletedInNotes.cs new file mode 100644 index 0000000..265031c --- /dev/null +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/20241213123214_AddIsDeletedInNotes.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Qubiz.GoogleKeep.Persistence.Migrations +{ + /// <inheritdoc /> + public partial class AddIsDeletedInNotes : Migration + { + /// <inheritdoc /> + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn<bool>( + name: "IsDeleted", + table: "Notes", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// <inheritdoc /> + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "Notes"); + } + } +} diff --git a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/AssetsDbContextModelSnapshot.cs b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/AssetsDbContextModelSnapshot.cs index f9d97dc..059ce74 100644 --- a/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/AssetsDbContextModelSnapshot.cs +++ b/Qubiz.GoogleKeep/Qubiz.GoogleKeep.Persistence/Migrations/AssetsDbContextModelSnapshot.cs @@ -272,6 +272,9 @@ namespace Qubiz.GoogleKeep.Persistence.Migrations b.Property<string>("Description") .HasColumnType("nvarchar(max)"); + b.Property<bool>("IsDeleted") + .HasColumnType("bit"); + b.Property<bool>("IsPinned") .HasColumnType("bit"); -- GitLab