Skip to content

Commit

Permalink
feat: Add timeslot api
Browse files Browse the repository at this point in the history
Add api for adding and listing time slots
  • Loading branch information
LuukvH committed Jul 20, 2024
1 parent a813fe0 commit 5ac64c7
Show file tree
Hide file tree
Showing 58 changed files with 421 additions and 126 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Net;
using System.Threading.Tasks;
using System.Net;
using KDVManager.Services.CRM.Application.Exceptions;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http;

namespace KDVManager.Services.CRM.Api.Middleware;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Microsoft.AspNetCore.Builder;

namespace KDVManager.Services.CRM.Api.Middleware
namespace KDVManager.Services.CRM.Api.Middleware
{
public static class ExceptionHandlerMiddlewareExtension
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using KDVManager.Services.CRM.Application.Exceptions;
using ValidationException = KDVManager.Services.CRM.Application.Exceptions.ValidationException;

public class ValidationError
Expand Down
3 changes: 0 additions & 3 deletions src/Services/CRM/Api/Services/TenantService/TenantService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using KDVManager.Services.CRM.Application.Contracts.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using KDVManager.Services.CRM.Application.Exceptions;

namespace KDVManager.Services.CRM.Api.Services;
Expand Down
4 changes: 1 addition & 3 deletions src/Services/CRM/Application/ConfigureServices.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Reflection;
using System.Reflection;
using MediatR;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.Extensions.DependencyInjection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using KDVManager.Services.CRM.Domain.Interfaces;
using MediatR;

namespace KDVManager.Services.CRM.Application.Contracts.Pagination
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using KDVManager.Services.CRM.Domain.Entities;
using KDVManager.Services.CRM.Domain.Interfaces;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using KDVManager.Services.CRM.Domain.Entities;
using KDVManager.Services.CRM.Domain.Interfaces;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
namespace KDVManager.Services.CRM.Application.Contracts.Validation
namespace KDVManager.Services.CRM.Application.Contracts.Validation
{
public class ValidationError
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using FluentValidation;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
using FluentValidation;

namespace KDVManager.Services.CRM.Application.Features.Children.Commands.CreateChild;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
using KDVManager.Services.CRM.Application.Features.Children.Commands.CreateChild;
using KDVManager.Services.CRM.Domain.Entities;
using MediatR;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using FluentValidation;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
using FluentValidation;

namespace KDVManager.Services.CRM.Application.Features.Children.Commands.UpdateChild;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using KDVManager.Services.CRM.Domain;
using KDVManager.Services.CRM.Application.Contracts.Pagination;
using KDVManager.Services.CRM.Application.Contracts.Pagination;
using MediatR;

namespace KDVManager.Services.CRM.Application.Features.Children.Queries.GetChildList
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
using KDVManager.Services.CRM.Application.Contracts.Pagination;
using KDVManager.Services.CRM.Domain.Entities;
using MediatR;

namespace KDVManager.Services.CRM.Application.Features.Children.Queries.GetChildList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using FluentValidation;
using FluentValidation;

namespace KDVManager.Services.CRM.Application.Features.People.Commands.AddPerson;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using KDVManager.Services.CRM.Domain;
using KDVManager.Services.CRM.Application.Contracts.Pagination;
using KDVManager.Services.CRM.Application.Contracts.Pagination;
using MediatR;

namespace KDVManager.Services.CRM.Application.Features.People.Queries.GetPersonList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
using KDVManager.Services.CRM.Application.Contracts.Pagination;
using KDVManager.Services.CRM.Domain.Entities;
using MediatR;

namespace KDVManager.Services.CRM.Application.Features.People.Queries.GetPersonList;
Expand Down
3 changes: 1 addition & 2 deletions src/Services/CRM/Application/Profiles/MappingProfile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using AutoMapper;
using AutoMapper;
using KDVManager.Services.CRM.Application.Contracts.Pagination;
using KDVManager.Services.CRM.Application.Features.Children.Commands.CreateChild;
using KDVManager.Services.CRM.Application.Features.Children.Commands.UpdateChild;
Expand Down
3 changes: 1 addition & 2 deletions src/Services/CRM/Infrastructure/ChildManagementDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using KDVManager.Services.CRM.Domain.Entities;
using KDVManager.Services.CRM.Domain.Entities;
using KDVManager.Services.CRM.Application.Contracts.Services;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using KDVManager.Services.CRM.Domain.Entities;
using KDVManager.Services.CRM.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

Expand Down
4 changes: 1 addition & 3 deletions src/Services/CRM/Infrastructure/ConfigureServices.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
using KDVManager.Services.CRM.Infrastructure;
using KDVManager.Services.CRM.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.Extensions.DependencyInjection;

Expand Down
3 changes: 1 addition & 2 deletions src/Services/CRM/Infrastructure/MigrationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using KDVManager.Services.CRM.Domain.Entities;
using KDVManager.Services.CRM.Domain.Entities;
using Microsoft.EntityFrameworkCore;

namespace KDVManager.Services.CRM.Infrastructure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using KDVManager.Services.CRM.Application.Contracts.Persistence;
Expand Down
10 changes: 1 addition & 9 deletions src/Services/Scheduling/Api/Controllers/GroupsController.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using KDVManager.Services.Scheduling.Application.Features.Groups.Commands.AddGroup;
using KDVManager.Services.Scheduling.Application.Features.Groups.Commands.AddGroup;
using KDVManager.Services.Scheduling.Application.Features.Groups.Queries.ListGroups;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
using KDVManager.Services.Scheduling.Application.Contracts.Pagination;
using System.Net;
using KDVManager.Services.Scheduling.Application.Contracts.Persistence;
using System.Net.Mime;
using KDVManager.Services.Scheduling.Application.Features.Groups.Commands.DeleteGroup;

namespace KDVManager.Services.Scheduling.Api.Controllers;
Expand Down
39 changes: 39 additions & 0 deletions src/Services/Scheduling/Api/Controllers/TimeSlotsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using KDVManager.Services.Scheduling.Application.Features.TimeSlots.Commands.AddTimeSlot;
using KDVManager.Services.Scheduling.Application.Features.TimeSlots.Queries.ListTimeSlots;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using KDVManager.Services.Scheduling.Application.Contracts.Pagination;
using System.Net;

namespace KDVManager.Services.Scheduling.Api.Controllers;

[ApiController]
[Route("v1/[controller]")]
public class TimeSlotsController : ControllerBase
{
private readonly IMediator _mediator;
private readonly ILogger<TimeSlotsController> _logger;

public TimeSlotsController(IMediator mediator, ILogger<TimeSlotsController> logger)
{
_logger = logger;
_mediator = mediator;
}

[HttpGet("", Name = "ListTimeSlots")]
public async Task<ActionResult<PagedList<TimeSlotListVM>>> ListTimeSlots([FromQuery] ListTimeSlotsQuery listTimeSlotsQuery)
{
var dtos = await _mediator.Send(listTimeSlotsQuery);
Response.Headers.Add("x-Total", dtos.TotalCount.ToString());
return Ok(dtos);
}

[HttpPost(Name = "AddTimeSlot")]
[ProducesResponseType(typeof(Guid), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(UnprocessableEntityResponse), (int)HttpStatusCode.UnprocessableEntity)]
public async Task<ActionResult<Guid>> AddTimeSlot([FromBody] AddTimeSlotCommand addTimeSlotCommand)
{
var id = await _mediator.Send(addTimeSlotCommand);
return Ok(id);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Net;
using System.Threading.Tasks;
using System.Net;
using KDVManager.Services.Scheduling.Application.Exceptions;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http;

namespace KDVManager.Services.Scheduling.Api.Middleware;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Microsoft.AspNetCore.Builder;

namespace KDVManager.Services.Scheduling.Api.Middleware;
namespace KDVManager.Services.Scheduling.Api.Middleware;

public static class ExceptionHandlerMiddlewareExtension
{
Expand Down
2 changes: 0 additions & 2 deletions src/Services/Scheduling/Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using KDVManager.Services.Scheduling.Api.Middleware;
using KDVManager.Services.Scheduling.Application;
using KDVManager.Services.Scheduling.Infrastructure;

var builder = WebApplication.CreateBuilder(args);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using KDVManager.Services.Scheduling.Application.Exceptions;
using ValidationException = KDVManager.Services.Scheduling.Application.Exceptions.ValidationException;

public class ValidationError
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using KDVManager.Services.Scheduling.Application.Contracts.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using KDVManager.Services.Scheduling.Application.Exceptions;

namespace KDVManager.Services.Scheduling.Api.Services;
Expand Down
4 changes: 1 addition & 3 deletions src/Services/Scheduling/Application/ConfigureServices.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Reflection;
using System.Reflection;
using MediatR;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.Extensions.DependencyInjection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using KDVManager.Services.Scheduling.Domain.Interfaces;
using MediatR;

namespace KDVManager.Services.Scheduling.Application.Contracts.Pagination;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using KDVManager.Services.Scheduling.Application.Contracts.Persistence;
using KDVManager.Services.Scheduling.Domain.Entities;
using KDVManager.Services.Scheduling.Domain.Interfaces;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using KDVManager.Services.Scheduling.Domain.Entities;
using KDVManager.Services.Scheduling.Domain.Interfaces;

namespace KDVManager.Services.Scheduling.Application.Contracts.Persistence;

public interface ITimeSlotRepository : IAsyncRepository<TimeSlot>
{
Task<IReadOnlyList<TimeSlot>> PagedAsync(IPaginationFilter paginationFilter);

Task<int> CountAsync();

Task<bool> IsTimeSlotNameUnique(string name);
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
namespace KDVManager.Services.Scheduling.Application.Contracts.Validation;
namespace KDVManager.Services.Scheduling.Application.Contracts.Validation;

public class ValidationError
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using FluentValidation;
using KDVManager.Services.Scheduling.Application.Contracts.Persistence;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using KDVManager.Services.Scheduling.Application.Contracts.Persistence;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using KDVManager.Services.Scheduling.Domain;
using KDVManager.Services.Scheduling.Application.Contracts.Pagination;
using KDVManager.Services.Scheduling.Application.Contracts.Pagination;
using MediatR;

namespace KDVManager.Services.Scheduling.Application.Features.Groups.Queries.ListGroups;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using KDVManager.Services.Scheduling.Application.Contracts.Persistence;
using KDVManager.Services.Scheduling.Application.Contracts.Pagination;
using KDVManager.Services.Scheduling.Domain.Entities;
using MediatR;

namespace KDVManager.Services.Scheduling.Application.Features.Groups.Queries.ListGroups;
Expand Down
Loading

0 comments on commit 5ac64c7

Please sign in to comment.