-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: setting up service for creating issues (#41)
* wip: setting up service for creating issues * wip: adding templates for emails * feat: finish report issue form * feat: add some error handling
- Loading branch information
1 parent
7ea6403
commit e2a517f
Showing
22 changed files
with
547 additions
and
15 deletions.
There are no files selected for viewing
24 changes: 14 additions & 10 deletions
24
backend/src/MethodConf.Cms/Controllers/ConferenceIssueController.cs
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 |
---|---|---|
@@ -1,26 +1,30 @@ | ||
using Asp.Versioning; | ||
using AutoMapper; | ||
using MethodConf.Cms.Domain; | ||
using MethodConf.Cms.Domain.Errors; | ||
using MethodConf.Cms.Dtos; | ||
using MethodConf.Cms.Services.Interfaces; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace MethodConf.Cms.Controllers; | ||
|
||
[ApiController] | ||
[ApiVersion("1.0")] | ||
[Route(RouteTemplates.ConferenceIssue)] | ||
public class ConferenceIssueController : Controller | ||
public class ConferenceIssueController(IConferenceIssueService conferenceIssueService, IMapper mapper) : Controller | ||
{ | ||
[HttpPost] | ||
public async Task<ActionResult<CreateIssueResponseDto>> CreateIssue(Guid conferenceId, CreateIssueRequestDto request) | ||
{ | ||
await Task.CompletedTask; | ||
return Ok(new CreateIssueResponseDto | ||
var createIssue = mapper.Map<CreateIssue>(request); | ||
|
||
var result = await conferenceIssueService.CreateIssue(conferenceId, createIssue); | ||
|
||
return result switch | ||
{ | ||
Message = request.Message, | ||
Resolution = request.Resolution, | ||
Name = request.Name, | ||
Email = request.Email, | ||
Phone = request.Phone, | ||
ResponseMarkup = """<p>This is some test markup with a <a href="https://google.com">link</a></p>""", | ||
}); | ||
{ IsFailed: true } when result.Errors.Any(e => e is InvalidEntityIdError) => NotFound(result.Errors), | ||
{ IsSuccess: true } => Ok(mapper.Map<CreateIssueResponseDto>(result.Value)), | ||
_ => StatusCode(500) | ||
}; | ||
} | ||
} |
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,14 @@ | ||
namespace MethodConf.Cms.Domain; | ||
|
||
public class CreateIssue | ||
{ | ||
public required string Message { get; set; } | ||
|
||
public string? Resolution { get; set; } | ||
|
||
public string? Name { get; set; } | ||
|
||
public string? Email { get; set; } | ||
|
||
public string? PhoneNumber { 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,25 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MethodConf.Cms.Domain; | ||
|
||
public class Issue | ||
{ | ||
public Guid Id { get; set; } | ||
|
||
public Guid ConferenceId { get; set; } | ||
|
||
[MaxLength(10_000)] | ||
public required string Message { get; set; } | ||
|
||
[MaxLength(10_000)] | ||
public string? Resolution { get; set; } | ||
|
||
[MaxLength(255)] | ||
public string? Name { get; set; } | ||
|
||
[MaxLength(255)] | ||
public string? Email { get; set; } | ||
|
||
[MaxLength(255)] | ||
public string? PhoneNumber { 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,20 @@ | ||
namespace MethodConf.Cms.Domain; | ||
|
||
public class IssueWithResponse | ||
{ | ||
public Guid Id { get; set; } | ||
|
||
public Guid ConferenceId { get; set; } | ||
|
||
public required string Message { get; set; } | ||
|
||
public string? Resolution { get; set; } | ||
|
||
public string? Name { get; set; } | ||
|
||
public string? Email { get; set; } | ||
|
||
public string? PhoneNumber { get; set; } | ||
|
||
public required string ResponseMarkup { 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
10 changes: 10 additions & 0 deletions
10
backend/src/MethodConf.Cms/Dtos/NewIssueAppResponseViewModel.cs
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,10 @@ | ||
namespace MethodConf.Cms.Dtos; | ||
|
||
public class NewIssueAppResponseViewModel | ||
{ | ||
public required string Message { get; set; } | ||
public string? Resolution { get; set; } | ||
public string? Name { get; set; } | ||
public string? Email { get; set; } | ||
public string? Phone { 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,11 @@ | ||
namespace MethodConf.Cms.Dtos; | ||
|
||
public class NewIssueEmailViewModel | ||
{ | ||
public string? Title { get; set; } | ||
public required string Message { get; set; } | ||
public string? Resolution { get; set; } | ||
public string? Name { get; set; } | ||
public string? Email { get; set; } | ||
public string? Phone { 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
95 changes: 95 additions & 0 deletions
95
backend/src/MethodConf.Cms/Infrastructure/Migrations/20241011010918_AddIssue.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
backend/src/MethodConf.Cms/Infrastructure/Migrations/20241011010918_AddIssue.cs
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,39 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace MethodConf.Cms.Infrastructure.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class AddIssue : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Issues", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(type: "TEXT", nullable: false), | ||
ConferenceId = table.Column<Guid>(type: "TEXT", nullable: false), | ||
Message = table.Column<string>(type: "TEXT", maxLength: 10000, nullable: false), | ||
Resolution = table.Column<string>(type: "TEXT", maxLength: 10000, nullable: true), | ||
Name = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true), | ||
Email = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true), | ||
PhoneNumber = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Issues", x => x.Id); | ||
}); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Issues"); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.