-
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.
added lazy loading, added craftsman services
- Loading branch information
1 parent
96f87fc
commit 65ee888
Showing
30 changed files
with
642 additions
and
899 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using crafts_api.Entities.Dto; | ||
using crafts_api.Entities.Models; | ||
using crafts_api.Interfaces; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace crafts_api.Controllers | ||
{ | ||
[Authorize] | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class CraftersController : ControllerBase | ||
{ | ||
private readonly ICraftersService _craftsmanService; | ||
|
||
public CraftersController(ICraftersService craftsmanService) => _craftsmanService = craftsmanService; | ||
|
||
|
||
[HttpGet ("get-craftsman")] | ||
public async Task<IActionResult> GetCraftsman(Guid craftsmanPublicId) | ||
{ | ||
// var token = Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); | ||
|
||
var craftsmanProfile = await _craftsmanService.GetCraftsmanProfile(craftsmanPublicId); | ||
return Ok(craftsmanProfile); | ||
} | ||
|
||
[HttpPost("add-service")] | ||
public async Task<IActionResult> AddService(AddServiceRequest addServiceRequest) | ||
{ | ||
var token = Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); | ||
|
||
await _craftsmanService.AddService(addServiceRequest, token); | ||
return Ok(); | ||
} | ||
} | ||
} |
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
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,17 @@ | ||
using crafts_api.Entities.Domain; | ||
|
||
namespace crafts_api.Entities.Dto | ||
{ | ||
public class CraftsmanProfileViewDto | ||
{ | ||
public Guid PublicId { get; set; } | ||
public string Bio { get; set; } | ||
public string PhoneNumber { get; set; } | ||
public string FirstName { get; set; } | ||
public string LastName { get; set; } | ||
public string UserName { get; set; } | ||
public DateTime CreatedAt { get; set; } | ||
public string ProfilePicture { get; set; } | ||
public List<CraftsmanServiceDto> CraftsmanServices { get; set; } = new List<CraftsmanServiceDto>(); | ||
} | ||
} |
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 crafts_api.Entities.Dto | ||
{ | ||
public class CraftsmanServiceDto | ||
{ | ||
// public id | ||
public Guid ServicePublicId { get; set; } | ||
// name | ||
public string Name { get; set; } | ||
// description | ||
public string Description { get; set; } | ||
// category | ||
public Guid CategoryPublicId { get; set; } | ||
public string CategoryName { get; set; } | ||
// price | ||
public decimal Price { get; set; } | ||
// duration | ||
public int Duration { get; set; } | ||
|
||
} | ||
} |
5 changes: 4 additions & 1 deletion
5
crafts-api/Entities/Dto/UserDto.cs → crafts-api/Entities/Dto/LoggedUserDto.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,11 +1,14 @@ | ||
using crafts_api.Entities.Enum; | ||
|
||
namespace crafts_api.models.dto; | ||
|
||
public class UserDto | ||
public class LoggedUserDto | ||
{ | ||
public Guid PublicId { get; set; } | ||
public string UserName { get; set; } | ||
public string FirstName { get; set; } | ||
public string LastName { get; set; } | ||
public string Email { get; set; } | ||
public DateTime CreatedAt { get; set; } | ||
public Role Role { 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 crafts_api.Entities.Models | ||
{ | ||
public class AddServiceRequest | ||
{ | ||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
public Guid CategoryPublicId { get; set; } | ||
public decimal Price { get; set; } | ||
public int Duration { 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
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,7 +1,10 @@ | ||
using crafts_api.Entities.Enum; | ||
|
||
namespace crafts_api.models.models; | ||
|
||
public class LoginRequest | ||
{ | ||
public required string Email { get; set; } | ||
public required string Password { get; set; } | ||
public Role Role { 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
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 @@ | ||
using crafts_api.Entities.Dto; | ||
using crafts_api.Entities.Models; | ||
|
||
namespace crafts_api.Interfaces | ||
{ | ||
public interface ICraftersService | ||
{ | ||
Task AddService(AddServiceRequest addServiceRequest, string token); | ||
Task<CraftsmanProfileViewDto> GetCraftsmanProfile(Guid craftsmanPublicId); | ||
} | ||
} |
Oops, something went wrong.