SRP

Single Responsibility Principle: A class should have only one responsibility and should be mutable for only one reason.

Photo 1

Explanation


• Create class library "Business"
• Create folder Abstract and Concrete
• Create Interface "ICustomerService" and "IEmailService"
• Create class "Customermanger" and "EmailManager"
• Create class library "Entities"
• Create folder Entities and CUSTOMER.cs

Services Code
                        public interface ICustomerService
 {
     void AddCustomer(CUSTOMER customer);
 }  
public interface IEmailService
 {
     void SendEmail();
 }              
                    
                    
                    

Managers Code
                        namespace Business.Concrete
{
    //SRP: Bir sınıfın yalnızca bir sorumluluğu olmalı ve yalnızca bir nedenle değiştirilebilir olmalıdır.
    //Customer process
    public class CustomerManager : ICustomerService
    {
        private readonly IEmailService _emailService;

        public CustomerManager(IEmailService emailService)
        {
            _emailService = emailService;
        }

        public void AddCustomer(CUSTOMER customer)
        {
            _emailService.SendEmail();//Done
            throw new NotImplementedException();
        }
    }
}
namespace Business.Concrete
{
//Email process
public class EmailManager : IEmailService
    {
        public void SendEmail()
        {
            throw new NotImplementedException();
        }
    }
}                
                    
                    
                    

Class Code
                        public class CUSTOMER
{
    [Key]
    public int ID { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
}