Use file scoped namepace

This commit is contained in:
2022-12-22 15:29:53 +01:00
parent 27bf5f0b24
commit 6d7e447ccc
51 changed files with 886 additions and 937 deletions

View File

@@ -1,13 +1,12 @@
namespace GerstITS.Examples.Logic.Example
{
public class Example
{
#region Properties
namespace GerstITS.Examples.Logic.Example;
public string FirstName { get; set; }
public string LastName { get; set; }
public string Description { get; set; }
public class Example
{
#region Properties
public string FirstName { get; set; }
public string LastName { get; set; }
public string Description { get; set; }
#endregion
}
#endregion
}

View File

@@ -1,8 +1,7 @@
namespace GerstITS.Examples.Logic.Example
namespace GerstITS.Examples.Logic.Example;
public interface IExampleProvider
{
public interface IExampleProvider
{
Example GetById(int id);
Example GetById_v1_1(int id);
}
}
Example GetById(int id);
Example GetById_v1_1(int id);
}

View File

@@ -1,51 +1,50 @@
using AutoMapper;
using GerstITS.Data;
namespace GerstITS.Examples.Logic.Example
namespace GerstITS.Examples.Logic.Example;
internal sealed class ExampleProvider : IExampleProvider
{
internal sealed class ExampleProvider : IExampleProvider
#region Fields
private readonly IMapper _mapper;
#endregion
#region Constructors
public ExampleProvider(IMapper mapper)
{
#region Fields
private readonly IMapper _mapper;
#endregion
#region Constructors
public ExampleProvider(IMapper mapper)
{
_mapper = mapper;
}
#endregion
#region IExampleProvider
public Example GetById(int id)
{
ThrowsAnExceptionIfEntityIsNotFound(id);
return _mapper.Map<Example>(id);
}
public Example GetById_v1_1(int id)
{
ThrowsAnExceptionIfEntityIsNotFound(id);
return _mapper.Map<Example>(id);
}
#endregion
#region Methods
private static void ThrowsAnExceptionIfEntityIsNotFound(int id)
{
if (id % 2 == 0)
throw new EntityNotFoundException($"Example mit der Id '{id}' nicht gefunden.");
}
#endregion
_mapper = mapper;
}
#endregion
#region IExampleProvider
public Example GetById(int id)
{
ThrowsAnExceptionIfEntityIsNotFound(id);
return _mapper.Map<Example>(id);
}
public Example GetById_v1_1(int id)
{
ThrowsAnExceptionIfEntityIsNotFound(id);
return _mapper.Map<Example>(id);
}
#endregion
#region Methods
private static void ThrowsAnExceptionIfEntityIsNotFound(int id)
{
if (id % 2 == 0)
throw new EntityNotFoundException($"Example mit der Id '{id}' nicht gefunden.");
}
#endregion
}

View File

@@ -1,19 +1,18 @@
using AutoMapper;
namespace GerstITS.Examples.Logic.Example
namespace GerstITS.Examples.Logic.Example;
internal sealed class IntegerMapping : Profile
{
internal sealed class IntegerMapping : Profile
#region Construtcors
public IntegerMapping()
{
#region Construtcors
public IntegerMapping()
{
CreateMap<int, Example>()
.ForMember(x => x.FirstName, m => m.MapFrom((s, _) => $"First Name {s}"))
.ForMember(x => x.LastName, m => m.MapFrom((s, _) => $"Last Name {s}"))
.ForMember(x => x.Description, m => m.MapFrom((s, _) => $"Useful description for id '{s}'"));
}
#endregion
CreateMap<int, Example>()
.ForMember(x => x.FirstName, m => m.MapFrom((s, _) => $"First Name {s}"))
.ForMember(x => x.LastName, m => m.MapFrom((s, _) => $"Last Name {s}"))
.ForMember(x => x.Description, m => m.MapFrom((s, _) => $"Useful description for id '{s}'"));
}
}
#endregion
}