mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-05 18:09:04 +00:00
DTO updates
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Repository\Infrastructure.Repository.csproj" />
|
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Repository\Infrastructure.Repository.csproj" />
|
||||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Jwt\Infrastructure.Jwt.csproj" />
|
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Jwt\Infrastructure.Jwt.csproj" />
|
||||||
<ProjectReference Include="..\..\Service\Service.Auth\Service.Auth.csproj" />
|
<ProjectReference Include="..\..\Service\Service.Auth\Service.Auth.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Service\Service.Breweries\Service.Breweries.csproj" />
|
||||||
<ProjectReference Include="..\..\Service\Service.UserManagement\Service.UserManagement.csproj" />
|
<ProjectReference Include="..\..\Service\Service.UserManagement\Service.UserManagement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace API.Core.Contracts.Breweries;
|
|
||||||
|
|
||||||
public class BreweryCreateDto
|
|
||||||
{
|
|
||||||
public Guid PostedById { get; set; }
|
|
||||||
public string BreweryName { get; set; } = string.Empty;
|
|
||||||
public string Description { get; set; } = string.Empty;
|
|
||||||
public BreweryLocationCreateDto Location { get; set; } = new BreweryLocationCreateDto();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace API.Core.Contracts.Breweries;
|
||||||
|
|
||||||
|
public class BreweryCreateDtoValidator : AbstractValidator<BreweryCreateDto>
|
||||||
|
{
|
||||||
|
public BreweryCreateDtoValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.PostedById)
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("PostedById is required.");
|
||||||
|
|
||||||
|
RuleFor(x => x.BreweryName)
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("Brewery name is required.")
|
||||||
|
.MaximumLength(256)
|
||||||
|
.WithMessage("Brewery name cannot exceed 256 characters.");
|
||||||
|
|
||||||
|
RuleFor(x => x.Description)
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("Description is required.")
|
||||||
|
.MaximumLength(512)
|
||||||
|
.WithMessage("Description cannot exceed 512 characters.");
|
||||||
|
|
||||||
|
RuleFor(x => x.Location)
|
||||||
|
.NotNull()
|
||||||
|
.WithMessage("Location is required.");
|
||||||
|
|
||||||
|
RuleFor(x => x.Location.CityId)
|
||||||
|
.NotEmpty()
|
||||||
|
.When(x => x.Location is not null)
|
||||||
|
.WithMessage("CityId is required.");
|
||||||
|
|
||||||
|
RuleFor(x => x.Location.AddressLine1)
|
||||||
|
.NotEmpty()
|
||||||
|
.When(x => x.Location is not null)
|
||||||
|
.WithMessage("Address line 1 is required.")
|
||||||
|
.MaximumLength(256)
|
||||||
|
.When(x => x.Location is not null)
|
||||||
|
.WithMessage("Address line 1 cannot exceed 256 characters.");
|
||||||
|
|
||||||
|
RuleFor(x => x.Location.PostalCode)
|
||||||
|
.NotEmpty()
|
||||||
|
.When(x => x.Location is not null)
|
||||||
|
.WithMessage("Postal code is required.")
|
||||||
|
.MaximumLength(20)
|
||||||
|
.When(x => x.Location is not null)
|
||||||
|
.WithMessage("Postal code cannot exceed 20 characters.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,41 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace API.Core.Contracts.Breweries;
|
namespace API.Core.Contracts.Breweries;
|
||||||
|
|
||||||
|
public class BreweryLocationCreateDto
|
||||||
|
{
|
||||||
|
public Guid CityId { get; set; }
|
||||||
|
public string AddressLine1 { get; set; } = string.Empty;
|
||||||
|
public string? AddressLine2 { get; set; }
|
||||||
|
public string PostalCode { get; set; } = string.Empty;
|
||||||
|
public byte[]? Coordinates { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BreweryLocationDto
|
||||||
|
{
|
||||||
|
public Guid BreweryPostLocationId { get; set; }
|
||||||
|
public Guid BreweryPostId { get; set; }
|
||||||
|
public Guid CityId { get; set; }
|
||||||
|
public string AddressLine1 { get; set; } = string.Empty;
|
||||||
|
public string? AddressLine2 { get; set; }
|
||||||
|
public string PostalCode { get; set; } = string.Empty;
|
||||||
|
public byte[]? Coordinates { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BreweryCreateDto
|
||||||
|
{
|
||||||
|
public Guid PostedById { get; set; }
|
||||||
|
public string BreweryName { get; set; } = string.Empty;
|
||||||
|
public string Description { get; set; } = string.Empty;
|
||||||
|
public BreweryLocationCreateDto Location { get; set; } = null!;
|
||||||
|
}
|
||||||
|
|
||||||
public class BreweryDto
|
public class BreweryDto
|
||||||
{
|
{
|
||||||
public Guid BreweryPostId { get; set; }
|
public Guid BreweryPostId { get; set; }
|
||||||
public Guid PostedById { get; set; }
|
public Guid PostedById { get; set; }
|
||||||
public string BreweryName { get; set; } = string.Empty;
|
public string BreweryName { get; set; } = string.Empty;
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
public DateTime? UpdatedAt { get; set; }
|
public DateTime? UpdatedAt { get; set; }
|
||||||
public byte[]? Timer { get; set; }
|
public byte[]? Timer { get; set; }
|
||||||
public BreweryLocationDto? Location { get; set; }
|
public BreweryLocationDto? Location { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace API.Core.Contracts.Breweries;
|
|
||||||
|
|
||||||
public class BreweryLocationCreateDto
|
|
||||||
{
|
|
||||||
public Guid CityId { get; set; }
|
|
||||||
public string AddressLine1 { get; set; } = string.Empty;
|
|
||||||
public string? AddressLine2 { get; set; }
|
|
||||||
public string PostalCode { get; set; } = string.Empty;
|
|
||||||
public byte[]? Coordinates { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace API.Core.Contracts.Breweries;
|
|
||||||
|
|
||||||
public class BreweryLocationDto
|
|
||||||
{
|
|
||||||
public Guid BreweryPostLocationId { get; set; }
|
|
||||||
public Guid BreweryPostId { get; set; }
|
|
||||||
public Guid CityId { get; set; }
|
|
||||||
public string AddressLine1 { get; set; } = string.Empty;
|
|
||||||
public string? AddressLine2 { get; set; }
|
|
||||||
public string PostalCode { get; set; } = string.Empty;
|
|
||||||
public byte[]? Coordinates { get; set; }
|
|
||||||
}
|
|
||||||
129
src/Core/API/API.Core/Controllers/BreweryController.cs
Normal file
129
src/Core/API/API.Core/Controllers/BreweryController.cs
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
using API.Core.Contracts.Breweries;
|
||||||
|
using API.Core.Contracts.Common;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Service.Breweries;
|
||||||
|
|
||||||
|
namespace API.Core.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[Authorize(AuthenticationSchemes = "JWT")]
|
||||||
|
public class BreweryController(IBreweryService breweryService) : ControllerBase
|
||||||
|
{
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpGet("{id:guid}")]
|
||||||
|
public async Task<ActionResult<ResponseBody<BreweryDto>>> GetById(Guid id)
|
||||||
|
{
|
||||||
|
var brewery = await breweryService.GetByIdAsync(id);
|
||||||
|
if (brewery is null)
|
||||||
|
return NotFound(new ResponseBody { Message = $"Brewery with ID {id} not found." });
|
||||||
|
|
||||||
|
return Ok(new ResponseBody<BreweryDto>
|
||||||
|
{
|
||||||
|
Message = "Brewery retrieved successfully.",
|
||||||
|
Payload = MapToDto(brewery),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<ResponseBody<IEnumerable<BreweryDto>>>> GetAll(
|
||||||
|
[FromQuery] int? limit,
|
||||||
|
[FromQuery] int? offset)
|
||||||
|
{
|
||||||
|
var breweries = await breweryService.GetAllAsync(limit, offset);
|
||||||
|
return Ok(new ResponseBody<IEnumerable<BreweryDto>>
|
||||||
|
{
|
||||||
|
Message = "Breweries retrieved successfully.",
|
||||||
|
Payload = breweries.Select(MapToDto),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<ResponseBody<BreweryDto>>> Create([FromBody] BreweryCreateDto dto)
|
||||||
|
{
|
||||||
|
var request = new BreweryCreateRequest(
|
||||||
|
dto.PostedById,
|
||||||
|
dto.BreweryName,
|
||||||
|
dto.Description,
|
||||||
|
new BreweryLocationCreateRequest(
|
||||||
|
dto.Location.CityId,
|
||||||
|
dto.Location.AddressLine1,
|
||||||
|
dto.Location.AddressLine2,
|
||||||
|
dto.Location.PostalCode,
|
||||||
|
dto.Location.Coordinates
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
var result = await breweryService.CreateAsync(request);
|
||||||
|
if (!result.Success)
|
||||||
|
return BadRequest(new ResponseBody { Message = result.Message });
|
||||||
|
|
||||||
|
return Created($"/api/brewery/{result.Brewery.BreweryPostId}", new ResponseBody<BreweryDto>
|
||||||
|
{
|
||||||
|
Message = "Brewery created successfully.",
|
||||||
|
Payload = MapToDto(result.Brewery),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("{id:guid}")]
|
||||||
|
public async Task<ActionResult<ResponseBody<BreweryDto>>> Update(Guid id, [FromBody] BreweryDto dto)
|
||||||
|
{
|
||||||
|
if (dto.BreweryPostId != id)
|
||||||
|
return BadRequest(new ResponseBody { Message = "Route ID does not match payload ID." });
|
||||||
|
|
||||||
|
var request = new BreweryUpdateRequest(
|
||||||
|
dto.BreweryPostId,
|
||||||
|
dto.PostedById,
|
||||||
|
dto.BreweryName,
|
||||||
|
dto.Description,
|
||||||
|
dto.Location is null ? null : new BreweryLocationUpdateRequest(
|
||||||
|
dto.Location.BreweryPostLocationId,
|
||||||
|
dto.Location.CityId,
|
||||||
|
dto.Location.AddressLine1,
|
||||||
|
dto.Location.AddressLine2,
|
||||||
|
dto.Location.PostalCode,
|
||||||
|
dto.Location.Coordinates
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
var result = await breweryService.UpdateAsync(request);
|
||||||
|
if (!result.Success)
|
||||||
|
return BadRequest(new ResponseBody { Message = result.Message });
|
||||||
|
|
||||||
|
return Ok(new ResponseBody<BreweryDto>
|
||||||
|
{
|
||||||
|
Message = "Brewery updated successfully.",
|
||||||
|
Payload = MapToDto(result.Brewery),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{id:guid}")]
|
||||||
|
public async Task<ActionResult<ResponseBody>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
await breweryService.DeleteAsync(id);
|
||||||
|
return Ok(new ResponseBody { Message = "Brewery deleted successfully." });
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BreweryDto MapToDto(Domain.Entities.BreweryPost b) => new()
|
||||||
|
{
|
||||||
|
BreweryPostId = b.BreweryPostId,
|
||||||
|
PostedById = b.PostedById,
|
||||||
|
BreweryName = b.BreweryName,
|
||||||
|
Description = b.Description,
|
||||||
|
CreatedAt = b.CreatedAt,
|
||||||
|
UpdatedAt = b.UpdatedAt,
|
||||||
|
Timer = b.Timer,
|
||||||
|
Location = b.Location is null ? null : new BreweryLocationDto
|
||||||
|
{
|
||||||
|
BreweryPostLocationId = b.Location.BreweryPostLocationId,
|
||||||
|
BreweryPostId = b.Location.BreweryPostId,
|
||||||
|
CityId = b.Location.CityId,
|
||||||
|
AddressLine1 = b.Location.AddressLine1,
|
||||||
|
AddressLine2 = b.Location.AddressLine2,
|
||||||
|
PostalCode = b.Location.PostalCode,
|
||||||
|
Coordinates = b.Location.Coordinates,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
<Project Path="Service/Service.Auth.Tests/Service.Auth.Tests.csproj" />
|
<Project Path="Service/Service.Auth.Tests/Service.Auth.Tests.csproj" />
|
||||||
<Project Path="Service/Service.Emails/Service.Emails.csproj" />
|
<Project Path="Service/Service.Emails/Service.Emails.csproj" />
|
||||||
<Project Path="Service/Service.UserManagement/Service.UserManagement.csproj" />
|
<Project Path="Service/Service.UserManagement/Service.UserManagement.csproj" />
|
||||||
<Project Path="Service\Service.Auth\Service.Auth.csproj" />
|
<Project Path="Service/Service.Auth/Service.Auth.csproj" />
|
||||||
|
<Project Path="Service/Service.Breweries/Service.Breweries.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
</Solution>
|
</Solution>
|
||||||
|
|||||||
@@ -1,72 +1,65 @@
|
|||||||
using Domain.Entities;
|
using Domain.Entities;
|
||||||
using Infrastructure.Repository.Breweries;
|
using Infrastructure.Repository.Breweries;
|
||||||
using API.Core.Contracts.Breweries;
|
|
||||||
|
|
||||||
namespace Service.Breweries;
|
namespace Service.Breweries;
|
||||||
|
|
||||||
public class BreweryService(IBreweryRepository repository) : IBreweryService
|
public class BreweryService(IBreweryRepository repository) : IBreweryService
|
||||||
{
|
{
|
||||||
private readonly IBreweryRepository _repository = repository;
|
public Task<BreweryPost?> GetByIdAsync(Guid id) =>
|
||||||
|
repository.GetByIdAsync(id);
|
||||||
|
|
||||||
public Task<BreweryPost?> GetByIdAsync(Guid id) => _repository.GetByIdAsync(id);
|
public Task<IEnumerable<BreweryPost>> GetAllAsync(int? limit = null, int? offset = null) =>
|
||||||
|
repository.GetAllAsync(limit, offset);
|
||||||
|
|
||||||
public Task<IEnumerable<BreweryPost>> GetAllAsync(int? limit = null, int? offset = null) => _repository.GetAllAsync(limit, offset);
|
public async Task<BreweryServiceReturn> CreateAsync(BreweryCreateRequest request)
|
||||||
|
{
|
||||||
|
var entity = new BreweryPost
|
||||||
|
{
|
||||||
|
BreweryPostId = Guid.NewGuid(),
|
||||||
|
PostedById = request.PostedById,
|
||||||
|
BreweryName = request.BreweryName,
|
||||||
|
Description = request.Description,
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
Location = new BreweryPostLocation
|
||||||
|
{
|
||||||
|
BreweryPostLocationId = Guid.NewGuid(),
|
||||||
|
CityId = request.Location.CityId,
|
||||||
|
AddressLine1 = request.Location.AddressLine1,
|
||||||
|
AddressLine2 = request.Location.AddressLine2,
|
||||||
|
PostalCode = request.Location.PostalCode,
|
||||||
|
Coordinates = request.Location.Coordinates,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
public async Task<BreweryServiceReturn> CreateAsync(BreweryCreateDto brewery)
|
await repository.CreateAsync(entity);
|
||||||
{
|
return new BreweryServiceReturn(entity);
|
||||||
if (brewery.Location is null)
|
}
|
||||||
return new BreweryServiceReturn("Location must be provided");
|
|
||||||
|
|
||||||
var entity = new BreweryPost
|
public async Task<BreweryServiceReturn> UpdateAsync(BreweryUpdateRequest request)
|
||||||
{
|
{
|
||||||
BreweryPostId = Guid.NewGuid(),
|
var entity = new BreweryPost
|
||||||
PostedById = brewery.PostedById,
|
{
|
||||||
BreweryName = brewery.BreweryName,
|
BreweryPostId = request.BreweryPostId,
|
||||||
Description = brewery.Description,
|
PostedById = request.PostedById,
|
||||||
CreatedAt = DateTime.UtcNow,
|
BreweryName = request.BreweryName,
|
||||||
Location = new BreweryPostLocation
|
Description = request.Description,
|
||||||
{
|
UpdatedAt = DateTime.UtcNow,
|
||||||
BreweryPostLocationId = Guid.NewGuid(),
|
Location = request.Location is null ? null : new BreweryPostLocation
|
||||||
CityId = brewery.Location.CityId,
|
{
|
||||||
AddressLine1 = brewery.Location.AddressLine1,
|
BreweryPostLocationId = request.Location.BreweryPostLocationId,
|
||||||
AddressLine2 = brewery.Location.AddressLine2,
|
BreweryPostId = request.BreweryPostId,
|
||||||
PostalCode = brewery.Location.PostalCode,
|
CityId = request.Location.CityId,
|
||||||
Coordinates = brewery.Location.Coordinates
|
AddressLine1 = request.Location.AddressLine1,
|
||||||
}
|
AddressLine2 = request.Location.AddressLine2,
|
||||||
};
|
PostalCode = request.Location.PostalCode,
|
||||||
|
Coordinates = request.Location.Coordinates,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
await _repository.CreateAsync(entity);
|
await repository.UpdateAsync(entity);
|
||||||
return new BreweryServiceReturn(entity);
|
return new BreweryServiceReturn(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<BreweryServiceReturn> UpdateAsync(BreweryDto brewery)
|
public Task DeleteAsync(Guid id) =>
|
||||||
{
|
repository.DeleteAsync(id);
|
||||||
if (brewery is null) return new BreweryServiceReturn("Brewery payload is null");
|
|
||||||
|
|
||||||
var entity = new BreweryPost
|
|
||||||
{
|
|
||||||
BreweryPostId = brewery.BreweryPostId,
|
|
||||||
PostedById = brewery.PostedById,
|
|
||||||
BreweryName = brewery.BreweryName,
|
|
||||||
Description = brewery.Description,
|
|
||||||
CreatedAt = brewery.CreatedAt,
|
|
||||||
UpdatedAt = brewery.UpdatedAt,
|
|
||||||
Timer = brewery.Timer,
|
|
||||||
Location = brewery.Location is null ? null : new BreweryPostLocation
|
|
||||||
{
|
|
||||||
BreweryPostLocationId = brewery.Location.BreweryPostLocationId,
|
|
||||||
BreweryPostId = brewery.BreweryPostId,
|
|
||||||
CityId = brewery.Location.CityId,
|
|
||||||
AddressLine1 = brewery.Location.AddressLine1,
|
|
||||||
AddressLine2 = brewery.Location.AddressLine2,
|
|
||||||
PostalCode = brewery.Location.PostalCode,
|
|
||||||
Coordinates = brewery.Location.Coordinates
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
await _repository.UpdateAsync(entity);
|
|
||||||
return new BreweryServiceReturn(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task DeleteAsync(Guid id) => _repository.DeleteAsync(id);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace Service.Breweries.DependencyInjection;
|
|
||||||
|
|
||||||
public static class BreweryServiceCollectionExtensions
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddBreweryServices(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddScoped<IBreweryService, BreweryService>();
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +1,64 @@
|
|||||||
using API.Core.Contracts.Breweries;
|
|
||||||
using Domain.Entities;
|
using Domain.Entities;
|
||||||
|
|
||||||
namespace Service.Breweries;
|
namespace Service.Breweries;
|
||||||
|
|
||||||
public interface IBreweryService
|
public record BreweryCreateRequest(
|
||||||
{
|
Guid PostedById,
|
||||||
Task<BreweryPost?> GetByIdAsync(Guid id);
|
string BreweryName,
|
||||||
Task<IEnumerable<BreweryPost>> GetAllAsync(int? limit = null, int? offset = null);
|
string Description,
|
||||||
Task<BreweryServiceReturn> CreateAsync(BreweryCreateDto brewery);
|
BreweryLocationCreateRequest Location
|
||||||
Task<BreweryServiceReturn> UpdateAsync(BreweryDto brewery);
|
);
|
||||||
Task DeleteAsync(Guid id);
|
|
||||||
}
|
public record BreweryLocationCreateRequest(
|
||||||
|
Guid CityId,
|
||||||
|
string AddressLine1,
|
||||||
|
string? AddressLine2,
|
||||||
|
string PostalCode,
|
||||||
|
byte[]? Coordinates
|
||||||
|
);
|
||||||
|
|
||||||
|
public record BreweryUpdateRequest(
|
||||||
|
Guid BreweryPostId,
|
||||||
|
Guid PostedById,
|
||||||
|
string BreweryName,
|
||||||
|
string Description,
|
||||||
|
BreweryLocationUpdateRequest? Location
|
||||||
|
);
|
||||||
|
|
||||||
|
public record BreweryLocationUpdateRequest(
|
||||||
|
Guid BreweryPostLocationId,
|
||||||
|
Guid CityId,
|
||||||
|
string AddressLine1,
|
||||||
|
string? AddressLine2,
|
||||||
|
string PostalCode,
|
||||||
|
byte[]? Coordinates
|
||||||
|
);
|
||||||
|
|
||||||
public record BreweryServiceReturn
|
public record BreweryServiceReturn
|
||||||
{
|
{
|
||||||
public bool Success { get; init; } = false;
|
public bool Success { get; init; }
|
||||||
public BreweryPost Brewery { get; init; }
|
public BreweryPost Brewery { get; init; }
|
||||||
public string Message { get; init; } = string.Empty;
|
public string Message { get; init; } = string.Empty;
|
||||||
|
|
||||||
public BreweryServiceReturn(BreweryPost brewery)
|
public BreweryServiceReturn(BreweryPost brewery)
|
||||||
{
|
{
|
||||||
Success = true;
|
Success = true;
|
||||||
Brewery = brewery;
|
Brewery = brewery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BreweryServiceReturn(string message)
|
public BreweryServiceReturn(string message)
|
||||||
{
|
{
|
||||||
Success = false;
|
Success = false;
|
||||||
Brewery = default!;
|
Brewery = default!;
|
||||||
Message = message;
|
Message = message;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IBreweryService
|
||||||
|
{
|
||||||
|
Task<BreweryPost?> GetByIdAsync(Guid id);
|
||||||
|
Task<IEnumerable<BreweryPost>> GetAllAsync(int? limit = null, int? offset = null);
|
||||||
|
Task<BreweryServiceReturn> CreateAsync(BreweryCreateRequest request);
|
||||||
|
Task<BreweryServiceReturn> UpdateAsync(BreweryUpdateRequest request);
|
||||||
|
Task DeleteAsync(Guid id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Domain\Domain.Entities\Domain.Entities.csproj" />
|
<ProjectReference Include="..\..\Domain\Domain.Entities\Domain.Entities.csproj" />
|
||||||
<ProjectReference
|
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Repository\Infrastructure.Repository.csproj" />
|
||||||
Include="..\..\Infrastructure\Infrastructure.Repository\Infrastructure.Repository.csproj" />
|
</ItemGroup>
|
||||||
<ProjectReference Include="..\..\API\API.Core\API.Core.csproj" />
|
|
||||||
<ProjectReference Include="..\Service.Auth\Service.Auth.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user