Skip to content

Latest commit

 

History

History
76 lines (64 loc) · 2.1 KB

README.md

File metadata and controls

76 lines (64 loc) · 2.1 KB
                                              Portfolio Project

I used these technologies dotnet6 , MVC -> ViewComponents ,
AJAX ,
N-Tier Architecture ,
EntityFramework (MSSQL) ,
Identity ,
AutoMapper ,
I tried SOLİD,DRY and Yagni principles ,
Error Handling Manually

FluentAPI :

    public class ImageConfigurations : IEntityTypeConfiguration<Image>
    {
        public void Configure(EntityTypeBuilder<Image> builder)
        {
            builder.HasKey(x => x.id);
            builder.Property(x => x.imgPath).IsRequired();
            builder.HasOne(x => x.contentDetail).WithMany(x => x.images).HasForeignKey(x => x.contentDetailId);
        }
    }

Clean code examples:

  public bool ContentIsValid(ContentCreateDto dto) => _createContentValidator.Validate(dto).IsValid;

  public bool ContentUpdateIsValid(ContentUpdateDto dto) => _updateContentValidator.Validate(dto).IsValid;

Unit Of Work :

    public class Uow : IUow 
    {
        private readonly PortfolioContext _context;

        public Uow(PortfolioContext context)
        {
            _context = context;
        }

        public IRepository<T> GetRepository<T>() where T : BaseEntity
        {
            return new Repository<T>(_context);
        }

        public async Task SaveChangesAsync()
        {
            await _context.SaveChangesAsync();
        }
    }

Fluent Validation :

    public class ServiceUpdateDtoValidator : AbstractValidator<ServiceUpdateDto>
    {
        public ServiceUpdateDtoValidator()
        {
            RuleFor(x => x.id).NotEmpty().WithMessage("data id not found");
            RuleFor(x => x.serviceName).NotEmpty().WithMessage("Service name can't be empty");
            RuleFor(x => x.rank).LessThan((short)101).WithMessage("Rank max value is 100");
            RuleFor(x => x.rank).GreaterThan((short)0).WithMessage("Rank min value is 1");
        }
    }

You can star and look when you forget these :)