| @@ -1,11 +1,8 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Business.HelperModels | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class DeleteCustomerRequest | |||
| { | |||
| public string? Id { get; set; } | |||
| @@ -5,12 +5,14 @@ using Microsoft.Extensions.Options; | |||
| using MongoDB.Driver; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace Diligent.WebAPI.Business.Services | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class AuthorizationService : BaseMongo<Customer> | |||
| { | |||
| public AuthorizationService(IOptions<WebApiDatabaseSettings> webApiDatabaseSettings) : | |||
| @@ -1,9 +1,11 @@ | |||
| using Diligent.WebAPI.Data; | |||
| using Microsoft.Extensions.Options; | |||
| using MongoDB.Driver; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Business.MongoServices | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class BaseMongo<T> where T : class | |||
| { | |||
| protected readonly IMongoCollection<T> _mongoCollection; | |||
| @@ -1,7 +1,9 @@ | |||
| using MongoDB.Driver; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Data | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class MongoDBContext : IMongoDBContext | |||
| { | |||
| private readonly IConfiguration _configuration; | |||
| @@ -1,8 +1,10 @@ | |||
| using MongoDB.Bson; | |||
| using MongoDB.Bson.Serialization.Attributes; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Data.Entities | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class BaseMongo | |||
| { | |||
| [BsonId] | |||
| @@ -1,11 +1,13 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace Diligent.WebAPI.Data | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class WebApiDatabaseSettings | |||
| { | |||
| public string ConnectionString { get; set; } = null!; | |||
| @@ -3,12 +3,14 @@ using Diligent.WebAPI.Host.Mediator.Authentication.Commands; | |||
| using Diligent.WebAPI.Host.Mediator.Authentication.Queries; | |||
| using MediatR; | |||
| using Microsoft.AspNetCore.Mvc; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Controllers | |||
| { | |||
| [ApiVersion("1.0")] | |||
| [ApiController] | |||
| [Route("v{version:apiVersion}/[controller]")] | |||
| [ExcludeFromCodeCoverage] | |||
| public class AuthenticationController : ControllerBase | |||
| { | |||
| // password for every user in database is "Nekasifra123!" | |||
| @@ -3,12 +3,14 @@ using Diligent.WebAPI.Host.Mediator.Notifications.Commands; | |||
| using Diligent.WebAPI.Host.Mediator.Notifications.Queries; | |||
| using MediatR; | |||
| using Microsoft.AspNetCore.Mvc; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Controllers | |||
| { | |||
| [ApiVersion("1.0")] | |||
| [ApiController] | |||
| [Route("v{version:apiVersion}/[controller]")] | |||
| [ExcludeFromCodeCoverage] | |||
| public class NotificationController : ControllerBase | |||
| { | |||
| private readonly IMediator _mediator; | |||
| @@ -8,12 +8,14 @@ using Diligent.WebAPI.Host.Mediator.Request.Commands; | |||
| using Diligent.WebAPI.Host.Mediator.Request.Queries; | |||
| using MediatR; | |||
| using Microsoft.AspNetCore.Mvc; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Controllers | |||
| { | |||
| [ApiVersion("1.0")] | |||
| [ApiController] | |||
| [Route("v{version:apiVersion}/[controller]")] | |||
| [ExcludeFromCodeCoverage] | |||
| public class RequestController:ControllerBase | |||
| { | |||
| private readonly IMediator _mediator; | |||
| @@ -4,12 +4,14 @@ using Diligent.WebAPI.Host.Mediator.Rooms.Queries; | |||
| using MediatR; | |||
| using Microsoft.AspNetCore.Authorization; | |||
| using Microsoft.AspNetCore.Mvc; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Controllers | |||
| { | |||
| [ApiVersion("1.0")] | |||
| [ApiController] | |||
| [Route("v{version:apiVersion}/[controller]")] | |||
| [ExcludeFromCodeCoverage] | |||
| public class RoomController : ControllerBase | |||
| { | |||
| private readonly IMediator _mediator; | |||
| @@ -1,5 +1,8 @@ | |||
| namespace Diligent.WebAPI.Host.DTOs.Chat | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.DTOs.Chat | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class LeaveChatRoomDTO | |||
| { | |||
| public string ConnId { get; set; } | |||
| @@ -1,5 +1,8 @@ | |||
| namespace Diligent.WebAPI.Host.DTOs.Notification | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.DTOs.Notification | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class NotificationReadDTO | |||
| { | |||
| public string RoomId { get; set; } | |||
| @@ -1,5 +1,8 @@ | |||
| namespace Diligent.WebAPI.Host.DTOs.Request | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.DTOs.Request | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class AcceptCustomerDTO | |||
| { | |||
| public string customerId { get; set; } | |||
| @@ -1,13 +1,8 @@ | |||
| using System.Runtime.Serialization; | |||
| namespace Diligent.WebAPI.Host.Exceptions | |||
| namespace Diligent.WebAPI.Host.Exceptions | |||
| { | |||
| public class BaseException : Exception | |||
| { | |||
| public BaseException() { } | |||
| public BaseException(string? message) : base(message) { } | |||
| public BaseException(string message, Exception innerException) : base(message, innerException) { } | |||
| public BaseException(SerializationInfo info, StreamingContext context) : base(info, context) { } | |||
| } | |||
| } | |||
| @@ -4,11 +4,7 @@ namespace Diligent.WebAPI.Host.Exceptions | |||
| { | |||
| public class NotFoundException : BaseException | |||
| { | |||
| public NotFoundException() { } | |||
| public NotFoundException(string? message) : base(message) { } | |||
| public NotFoundException(string message, Exception innerException) : base(message, innerException) { } | |||
| public NotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } | |||
| } | |||
| } | |||
| @@ -1,7 +1,9 @@ | |||
| using Microsoft.AspNetCore.Mvc; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Extensions | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public static class ApiConfiguration | |||
| { | |||
| public static void ConfigureServices(IServiceCollection services) | |||
| @@ -1,7 +1,9 @@ | |||
| using Diligent.WebAPI.Host.Middlewares; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Extensions | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public static class ExceptionHandlingMiddlewareExtensions | |||
| { | |||
| public static void ConfigureCustomExceptionMiddleware(this IApplicationBuilder app) | |||
| @@ -1,8 +1,13 @@ | |||
| | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Extensions; | |||
| [ExcludeFromCodeCoverage] | |||
| public static class WebApp | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public static void SetupData(this WebApplication app) | |||
| { | |||
| app.ConfigureCustomExceptionMiddleware(); | |||
| @@ -12,11 +12,14 @@ using System.Text; | |||
| using Diligent.WebAPI.Business.Services; | |||
| using Diligent.WebAPI.Host.Middlewares; | |||
| using Diligent.WebAPI.Business.Interfaces; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Extensions; | |||
| [ExcludeFromCodeCoverage] | |||
| public static class WebAppBuilder | |||
| { | |||
| public static void ConfigureData(this WebApplicationBuilder builder, IConfiguration configuration) | |||
| { | |||
| // database configuration | |||
| @@ -1,9 +1,11 @@ | |||
| using AutoMapper; | |||
| using Diligent.WebAPI.Data.Entities; | |||
| using Diligent.WebAPI.Host.DTOs.Notification; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Mapper | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class NotificationMappingProfile : Profile | |||
| { | |||
| public NotificationMappingProfile() | |||
| @@ -2,9 +2,11 @@ | |||
| using Diligent.WebAPI.Host.Mediator.Authentication.Commands; | |||
| using MediatR; | |||
| using Microsoft.AspNetCore.Identity; | |||
| using System.Diagnostics.CodeAnalysis; | |||
| namespace Diligent.WebAPI.Host.Mediator.Authentication.Handlers | |||
| { | |||
| [ExcludeFromCodeCoverage] | |||
| public class AddRoleHandler : IRequestHandler<AddRoleCommand, Unit> | |||
| { | |||
| private readonly RoleManager<Roles> _roleManager; | |||
| @@ -31,7 +31,7 @@ namespace Diligent.WebAPI.Host.Mediator.Authentication.Handlers | |||
| Customer customer = await _customerService.GetCustomer(customerLoginDTO.Username); | |||
| var customerReadDTO = _mapper.Map<CustomerReadDTO>(customer); | |||
| customerReadDTO.Token = await _authenticationService.GenerateToken(); | |||
| customerReadDTO.Token = await _authenticationService.GenerateToken() ?? ""; | |||
| customerReadDTO.Roles = (List<string>)await _customerManager.GetRolesAsync(customer); | |||
| return customerReadDTO; | |||
| } | |||