-
Notifications
You must be signed in to change notification settings - Fork 6
Feature/change db provider #47
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
Open
DevFinesse
wants to merge
14
commits into
develop
Choose a base branch
from
feature/change-db-provider
base: develop
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.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bff07b8
removed sensitive entries from config
classyk12 c4e2a28
add business availability : repos
classyk12 d0d8d9a
business availabilty: manager
classyk12 3a9968a
added business availability endpoints
classyk12 6ca24a1
business availability: controllers
classyk12 707e954
added flag to fetch all busines avaiability by businessId
classyk12 3e12ff0
fixed model binding issues
classyk12 cde482e
fixed datetime
classyk12 e8b94f7
fix: switched db provider for local
classyk12 662c8f6
Resolve merge conflicts: consolidate migration files and update confi…
DevFinesse 31e43ea
Revert "Resolve merge conflicts: consolidate migration files and upda…
DevFinesse 970034d
BusinessAvailability fixes
DevFinesse 4fbac1c
Refactored Industry and fixes
DevFinesse 73491a3
Resolve add/add conflict for src.sln
DevFinesse 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 hidden or 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 hidden or 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,69 @@ | ||
| using Microsoft.AspNetCore.Authorization; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using ProjectR.Backend.Application.Interfaces.Managers; | ||
| using ProjectR.Backend.Application.Models; | ||
|
|
||
| namespace ProjectR.Backend.Controllers | ||
| { | ||
| [Authorize] | ||
| [Route("api/[controller]")] | ||
| public class BusinessAvailabilityController : BaseController | ||
| { | ||
| private readonly IBusinessAvailabilityManager _manager; | ||
|
|
||
| public BusinessAvailabilityController(IBusinessAvailabilityManager manager) | ||
| { | ||
| _manager = manager; | ||
| } | ||
|
|
||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(BusinessAvailabilityModel[]))] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(BusinessAvailabilityModel[]))] | ||
| [HttpGet("GetByBusiness/{Id:guid}")] | ||
| public async Task<IActionResult> GetByBusiness(Guid Id, [FromQuery] bool includeAll = false) | ||
| { | ||
| BusinessAvailabilityModel[] result = await _manager.GetByBusinessId(Id, includeAll); | ||
| return Ok(result); | ||
| } | ||
|
|
||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ResponseModel<BusinessAvailabilityModel>))] | ||
| [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ResponseModel<BusinessAvailabilityModel>))] | ||
| [HttpGet("{id:guid}")] | ||
| public async Task<IActionResult> Get(Guid id) | ||
| { | ||
| ResponseModel<BusinessAvailabilityModel> result = await _manager.GetByIdAsync(id); | ||
| return result.Status ? Ok(result) : BadRequest(); | ||
| } | ||
|
|
||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status201Created, Type = typeof(ResponseModel<BusinessAvailabilityModel>))] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ResponseModel<BusinessAvailabilityModel>))] | ||
| [HttpPost] | ||
| public async Task<IActionResult> Add([FromBody] AddBusinessAvailabilityModel model) | ||
| { | ||
| if (model == null || !ModelState.IsValid) | ||
| { | ||
| return BadRequest(ModelState); | ||
| } | ||
|
|
||
| ResponseModel<BusinessAvailabilityModel> result = await _manager.AddAsync(model); | ||
| return result.Status ? Ok(result) : BadRequest(result); | ||
| } | ||
|
|
||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status201Created, Type = typeof(ResponseModel<BusinessAvailabilityModel>))] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ResponseModel<BusinessAvailabilityModel>))] | ||
| [HttpPut("{id:guid}")] | ||
| public async Task<IActionResult> Update(Guid id, [FromBody] UpdateBusinessAvailabilityModel model) | ||
| { | ||
| if (model == null || !ModelState.IsValid) | ||
| { | ||
| return BadRequest(ModelState); | ||
| } | ||
|
|
||
| ResponseModel<BusinessAvailabilityModel> result = await _manager.UpdateAsync(id, model); | ||
| return result.Status ? Ok(result) : BadRequest(result); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,57 +1,82 @@ | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using ProjectR.Backend.Application.Interfaces.Managers; | ||
| using ProjectR.Backend.Application.Models; | ||
| using ProjectR.Backend.Domain.Entities; | ||
| using ProjectR.Backend.Infrastructure.Managers; | ||
|
|
||
| namespace ProjectR.Backend.Controllers | ||
| { | ||
| [ApiController] | ||
| [Route("api/[controller]")] | ||
| public class IndustryController : ControllerBase | ||
| public class IndustryController : BaseController | ||
| { | ||
| private readonly IIndustryManager _manager; | ||
| private readonly IIndustryManager _industryManager; | ||
|
|
||
| public IndustryController(IIndustryManager manager) | ||
| public IndustryController(IIndustryManager industryManager) | ||
| { | ||
| _manager = manager; | ||
| _industryManager = industryManager; | ||
| } | ||
|
|
||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status201Created, Type = typeof(ResponseModel<IndustryModel>))] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ResponseModel<IndustryModel>))] | ||
| [HttpPost] | ||
| public async Task<IActionResult> Create([FromBody] IndustryModel industry) | ||
| public async Task<IActionResult> Add([FromBody] AddIndustryModel industry) | ||
| { | ||
| var id = await _manager.CreateIndustryAsync(industry.Name, industry.Description); | ||
| return CreatedAtAction(nameof(GetById), new { id }, null); | ||
| } | ||
|
|
||
| [HttpGet("{id}")] | ||
| public async Task<IActionResult> GetById(Guid id) | ||
| { | ||
| var industry = await _manager.GetIndustryByIdAsync(id); | ||
| if (industry == null) | ||
| if (industry == null || !ModelState.IsValid) | ||
| { | ||
| return NotFound(); | ||
| return BadRequest(ModelState); | ||
| } | ||
| return Ok(industry); | ||
|
|
||
| ResponseModel<IndustryModel> result = await _industryManager.AddAsync(industry); | ||
| return result.Status ? Ok(result) : BadRequest(result); | ||
| } | ||
|
|
||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ResponseModel<IndustryModel>))] | ||
| [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ResponseModel<IndustryModel>))] | ||
| [HttpGet("{id:guid}")] | ||
| public async Task<IActionResult> Get(Guid id) | ||
| { | ||
| ResponseModel<IndustryModel> result = await _industryManager.GetByIdAsync(id); | ||
| return result.Status ? Ok(result) : BadRequest(); | ||
| } | ||
|
|
||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ResponseModel<IndustryModel[]>))] | ||
| [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ResponseModel<IndustryModel[]>))] | ||
| [HttpGet] | ||
| public async Task<IActionResult> GetAll() | ||
| { | ||
| var industries = await _manager.GetAllIndustriesAsync(); | ||
| return Ok(industries); | ||
| IndustryModel[] result = await _industryManager.GetAllAsync(); | ||
| return Ok(result); | ||
| } | ||
|
|
||
| [HttpPut("{id}")] | ||
| public async Task<IActionResult> Update(Guid id, [FromBody] IndustryModel industry) | ||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status201Created, Type = typeof(ResponseModel<IndustryModel>))] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ResponseModel<IndustryModel>))] | ||
| [HttpPut] | ||
| public async Task<IActionResult> Update([FromBody] IndustryModel industry) | ||
| { | ||
| await _manager.UpdateIndustryAsync(id, industry.Name, industry.Description); | ||
| return NoContent(); | ||
| if (industry == null || !ModelState.IsValid) | ||
| { | ||
| return BadRequest(ModelState); | ||
| } | ||
|
|
||
| ResponseModel<IndustryModel> result = await _industryManager.UpdateAsync(industry); | ||
| return result.Status ? Ok(result) : BadRequest(result); | ||
|
|
||
| } | ||
|
|
||
| [Produces("application/json")] | ||
| [ProducesResponseType(StatusCodes.Status201Created, Type = typeof(ResponseModel<IndustryModel>))] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ResponseModel<IndustryModel>))] | ||
| [HttpDelete("{id}")] | ||
| public async Task<IActionResult> Delete(Guid id) | ||
| public async Task<IActionResult> Delete([FromRoute] Guid id) | ||
| { | ||
| await _manager.DeleteIndustryAsync(id); | ||
| return NoContent(); | ||
| BaseResponseModel result = await _industryManager.DeleteAsync(id); | ||
| return result.Status ? Ok(result) : BadRequest(result); | ||
| } | ||
| } | ||
| } | ||
18 changes: 18 additions & 0 deletions
18
src/ProjectR.Backend.Application/Interfaces/Managers/IBusinessAvailabilityManager.cs
This file contains hidden or 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,18 @@ | ||
| using ProjectR.Backend.Application.Models; | ||
|
|
||
| namespace ProjectR.Backend.Application.Interfaces.Managers | ||
| { | ||
| public interface IBusinessAvailabilityManager | ||
| { | ||
| Task<ResponseModel<BusinessAvailabilityModel>> GetByIdAsync(Guid id); | ||
| Task<ResponseModel<BusinessAvailabilityModel>> AddAsync(AddBusinessAvailabilityModel model); | ||
| Task<ResponseModel<BusinessAvailabilityModel>> UpdateAsync(Guid id, UpdateBusinessAvailabilityModel model); | ||
| Task<BusinessAvailabilityModel[]> GetByBusinessId(Guid businessId, bool includeAll = false); | ||
| /// <summary> | ||
| /// Check if the business has any availability set already within a date range | ||
| /// </summary> | ||
| /// <param name="businessId"></param> | ||
| /// <returns></returns> | ||
| Task<bool> HasActiveAvailabilityAsync(Guid businessId, DateTime startDate, DateTime endDate); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
13 changes: 13 additions & 0 deletions
13
src/ProjectR.Backend.Application/Interfaces/Repository/IBusinessAvailabilityRepository.cs
This file contains hidden or 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,13 @@ | ||
| using ProjectR.Backend.Application.Models; | ||
|
|
||
| namespace ProjectR.Backend.Application.Interfaces.Repository | ||
| { | ||
| public interface IBusinessAvailabilityRepository | ||
| { | ||
| Task<BusinessAvailabilityModel?> GetByIdAsync(Guid id); | ||
| Task<BusinessAvailabilityModel[]> GetAllByBusinessIdAsync(Guid id, bool includeAll = false); | ||
| Task<BusinessAvailabilityModel> AddAsync(BusinessAvailabilityModel model); | ||
| Task<BusinessAvailabilityModel> UpdateAsync(Guid id, UpdateBusinessAvailabilityModel model); | ||
| Task<bool> HasActiveAvailabilityAsync(Guid businessId, DateTime startDate, DateTime endDate); | ||
| } | ||
| } |
This file contains hidden or 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.
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.
can you please adjust the INDUSTRY controller to follow the convention of the other controllers?