Skip to main content
added 75 characters in body
Source Link
lbrahim
  • 363
  • 1
  • 3
  • 12

This is how I imagine my project's layering:

BLL

Should be independent and contain only pure business logic and properties Sample Domain Model:

public class Role
{
    private UnitOfWork uow { get; set; }

    public Role()
    {
        uow = new UnitOfWork();
    }

    public int RoleId { get; set; }
    public string Name { get; set; }
    public string ID { get; set; }
    public string Description { get; set; }

    public int AddRole()
    {
        //Mapping from Business 'Role' type to Data Model 'Role' type
        AutoMapper.Mapper.CreateMap<SoC.BLL.Role, SoC.DAL.Role>();
        var model = AutoMapper.Mapper.Map<SoC.DAL.Role>(this);
        return uow.Roles.Add(model);
    }
}

DAL

Contain generic repository and Unit of work and data model meaning model that will reflect the database. Sample Data Model:

public class Role
{
    [Key]
    public int RoleId { get; set; }

    [Required]
    [StringLength(50, ErrorMessage = "Name Cannot Be More Than 50 Characters")]
    public string Name { get; set; }

    [Required]
    [StringLength(6, ErrorMessage = "ID Cannot Be More Than 6 Characters")]
    public string ID { get; set; }


    [Required]
    [StringLength(250, ErrorMessage = "Description Cannot Be More Than 250 Characters")]
    public string Description { get; set; }
}

Web

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?) Sample Controller Action:

public ActionResult Index()
{
    var role = new Role { RoleId = 1, ID = "ADMIN", Name = "Administrator", Description = "Hello World"  };
    int check = role.AddRole();

    return View();
}

So, from app I am communicating with the Domain Model which has a AddRole() method that will first map using automapper to the equivalent Data Model and then call Add() of repo method to persist the record.

This way my BLL is becoming a little dependent on AutoMapper and DAL but my DAL seems independent. I am trying to create just a simple layering for a simple yet well maintained project. Please suggest on its problems and improvements.

This is how I imagine my project's layering:

BLL

Should be independent and contain only pure business logic and properties Sample Domain Model:

public class Role
{
    private UnitOfWork uow { get; set; }

    public Role()
    {
        uow = new UnitOfWork();
    }

    public int RoleId { get; set; }
    public string Name { get; set; }
    public string ID { get; set; }
    public string Description { get; set; }

    public int AddRole()
    {
        AutoMapper.Mapper.CreateMap<SoC.BLL.Role, SoC.DAL.Role>();
        var model = AutoMapper.Mapper.Map<SoC.DAL.Role>(this);
        return uow.Roles.Add(model);
    }
}

DAL

Contain generic repository and Unit of work and data model meaning model that will reflect the database. Sample Data Model:

public class Role
{
    [Key]
    public int RoleId { get; set; }

    [Required]
    [StringLength(50, ErrorMessage = "Name Cannot Be More Than 50 Characters")]
    public string Name { get; set; }

    [Required]
    [StringLength(6, ErrorMessage = "ID Cannot Be More Than 6 Characters")]
    public string ID { get; set; }


    [Required]
    [StringLength(250, ErrorMessage = "Description Cannot Be More Than 250 Characters")]
    public string Description { get; set; }
}

Web

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?) Sample Controller Action:

public ActionResult Index()
{
    var role = new Role { RoleId = 1, ID = "ADMIN", Name = "Administrator", Description = "Hello World"  };
    int check = role.AddRole();

    return View();
}

So, from app I am communicating with the Domain Model which has a AddRole() method that will first map using automapper to the equivalent Data Model and then call Add() of repo method to persist the record.

This way my BLL is becoming a little dependent on AutoMapper and DAL but my DAL seems independent. I am trying to create just a simple layering for a simple yet well maintained project. Please suggest on its problems and improvements.

This is how I imagine my project's layering:

BLL

Should be independent and contain only pure business logic and properties Sample Domain Model:

public class Role
{
    private UnitOfWork uow { get; set; }

    public Role()
    {
        uow = new UnitOfWork();
    }

    public int RoleId { get; set; }
    public string Name { get; set; }
    public string ID { get; set; }
    public string Description { get; set; }

    public int AddRole()
    {
        //Mapping from Business 'Role' type to Data Model 'Role' type
        AutoMapper.Mapper.CreateMap<SoC.BLL.Role, SoC.DAL.Role>();
        var model = AutoMapper.Mapper.Map<SoC.DAL.Role>(this);
        return uow.Roles.Add(model);
    }
}

DAL

Contain generic repository and Unit of work and data model meaning model that will reflect the database. Sample Data Model:

public class Role
{
    [Key]
    public int RoleId { get; set; }

    [Required]
    [StringLength(50, ErrorMessage = "Name Cannot Be More Than 50 Characters")]
    public string Name { get; set; }

    [Required]
    [StringLength(6, ErrorMessage = "ID Cannot Be More Than 6 Characters")]
    public string ID { get; set; }


    [Required]
    [StringLength(250, ErrorMessage = "Description Cannot Be More Than 250 Characters")]
    public string Description { get; set; }
}

Web

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?) Sample Controller Action:

public ActionResult Index()
{
    var role = new Role { RoleId = 1, ID = "ADMIN", Name = "Administrator", Description = "Hello World"  };
    int check = role.AddRole();

    return View();
}

So, from app I am communicating with the Domain Model which has a AddRole() method that will first map using automapper to the equivalent Data Model and then call Add() of repo method to persist the record.

This way my BLL is becoming a little dependent on AutoMapper and DAL but my DAL seems independent. I am trying to create just a simple layering for a simple yet well maintained project. Please suggest on its problems and improvements.

Post Reopened by Nikita B, Vogel612, mheinzerling, rolfl
added 2 characters in body
Source Link
lbrahim
  • 363
  • 1
  • 3
  • 12

This is how I imagine my project's layering:

BLL

Should be independent and contain only pure business logic and properties Sample Domain Model:

public class Role
{
    private UnitOfWork uow { get; set; }

    public Role()
    {
        uow = new UnitOfWork();
    }

    public int RoleId { get; set; }
    public string Name { get; set; }
    public string ID { get; set; }
    public string Description { get; set; }

    public int AddRole()
    {
        AutoMapper.Mapper.CreateMap<SoC.BLL.Role, SoC.DAL.Role>();
        var model = AutoMapper.Mapper.Map<SoC.DAL.Role>(this);
        return uow.Roles.Add(model);
    }
}

DAL

Contain generic repository and Unit of work and data model meaning model that will reflect the database. Sample Data Model:

public class Role
{
    [Key]
    public int RoleId { get; set; }

    [Required]
    [StringLength(50, ErrorMessage = "Name Cannot Be More Than 50 Characters")]
    public string Name { get; set; }

    [Required]
    [StringLength(6, ErrorMessage = "ID Cannot Be More Than 6 Characters")]
    public string ID { get; set; }


    [Required]
    [StringLength(250, ErrorMessage = "Description Cannot Be More Than 250 Characters")]
    public string Description { get; set; }
}

Web

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?) Sample Controller Action:

public ActionResult Index()
{
    var role = new Role { RoleId = 1, ID = "ADMIN", Name = "Administrator", Description = "Hello World"  };
    int check = role.AddRole();

    return View();
}

So, from app I am communicating with the Domain Model which has a AddRole() method that will first map using automapper to the equivalent Data Model and then call Add() of repo method to persist the record.

This way my BLL is becoming a little dependent on AutoMapper and DAL but my DAL seems dependentindependent. I am trying to create just a simple layering for a simple yet well maintained project. Please suggest on its problems and improvements.

This is how I imagine my project's layering:

BLL

Should be independent and contain only pure business logic and properties Sample Domain Model:

public class Role
{
    private UnitOfWork uow { get; set; }

    public Role()
    {
        uow = new UnitOfWork();
    }

    public int RoleId { get; set; }
    public string Name { get; set; }
    public string ID { get; set; }
    public string Description { get; set; }

    public int AddRole()
    {
        AutoMapper.Mapper.CreateMap<SoC.BLL.Role, SoC.DAL.Role>();
        var model = AutoMapper.Mapper.Map<SoC.DAL.Role>(this);
        return uow.Roles.Add(model);
    }
}

DAL

Contain generic repository and Unit of work and data model meaning model that will reflect the database. Sample Data Model:

public class Role
{
    [Key]
    public int RoleId { get; set; }

    [Required]
    [StringLength(50, ErrorMessage = "Name Cannot Be More Than 50 Characters")]
    public string Name { get; set; }

    [Required]
    [StringLength(6, ErrorMessage = "ID Cannot Be More Than 6 Characters")]
    public string ID { get; set; }


    [Required]
    [StringLength(250, ErrorMessage = "Description Cannot Be More Than 250 Characters")]
    public string Description { get; set; }
}

Web

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?) Sample Controller Action:

public ActionResult Index()
{
    var role = new Role { RoleId = 1, ID = "ADMIN", Name = "Administrator", Description = "Hello World"  };
    int check = role.AddRole();

    return View();
}

So, from app I am communicating with the Domain Model which has a AddRole() method that will first map using automapper to the equivalent Data Model and then call Add() of repo method to persist the record.

This way my BLL is becoming a little dependent on AutoMapper and DAL but my DAL seems dependent. I am trying to create just a simple layering for a simple yet well maintained project. Please suggest on its problems and improvements.

This is how I imagine my project's layering:

BLL

Should be independent and contain only pure business logic and properties Sample Domain Model:

public class Role
{
    private UnitOfWork uow { get; set; }

    public Role()
    {
        uow = new UnitOfWork();
    }

    public int RoleId { get; set; }
    public string Name { get; set; }
    public string ID { get; set; }
    public string Description { get; set; }

    public int AddRole()
    {
        AutoMapper.Mapper.CreateMap<SoC.BLL.Role, SoC.DAL.Role>();
        var model = AutoMapper.Mapper.Map<SoC.DAL.Role>(this);
        return uow.Roles.Add(model);
    }
}

DAL

Contain generic repository and Unit of work and data model meaning model that will reflect the database. Sample Data Model:

public class Role
{
    [Key]
    public int RoleId { get; set; }

    [Required]
    [StringLength(50, ErrorMessage = "Name Cannot Be More Than 50 Characters")]
    public string Name { get; set; }

    [Required]
    [StringLength(6, ErrorMessage = "ID Cannot Be More Than 6 Characters")]
    public string ID { get; set; }


    [Required]
    [StringLength(250, ErrorMessage = "Description Cannot Be More Than 250 Characters")]
    public string Description { get; set; }
}

Web

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?) Sample Controller Action:

public ActionResult Index()
{
    var role = new Role { RoleId = 1, ID = "ADMIN", Name = "Administrator", Description = "Hello World"  };
    int check = role.AddRole();

    return View();
}

So, from app I am communicating with the Domain Model which has a AddRole() method that will first map using automapper to the equivalent Data Model and then call Add() of repo method to persist the record.

This way my BLL is becoming a little dependent on AutoMapper and DAL but my DAL seems independent. I am trying to create just a simple layering for a simple yet well maintained project. Please suggest on its problems and improvements.

edited to contain code
Source Link
lbrahim
  • 363
  • 1
  • 3
  • 12

Should be independent and contain only pure business logic and properties Sample Domain Model:

public class Role
{
    private UnitOfWork uow { get; set; }

    public Role()
    {
        uow = new UnitOfWork();
    }

    public int RoleId { get; set; }
    public string Name { get; set; }
    public string ID { get; set; }
    public string Description { get; set; }

    public int AddRole()
    {
        AutoMapper.Mapper.CreateMap<SoC.BLL.Role, SoC.DAL.Role>();
        var model = AutoMapper.Mapper.Map<SoC.DAL.Role>(this);
        return uow.Roles.Add(model);
    }
}

Contain generic repository and Unit of work and data model meaning model that will reflect the database. Sample Data Model:

public class Role
{
    [Key]
    public int RoleId { get; set; }

    [Required]
    [StringLength(50, ErrorMessage = "Name Cannot Be More Than 50 Characters")]
    public string Name { get; set; }

    [Required]
    [StringLength(6, ErrorMessage = "ID Cannot Be More Than 6 Characters")]
    public string ID { get; set; }


    [Required]
    [StringLength(250, ErrorMessage = "Description Cannot Be More Than 250 Characters")]
    public string Description { get; set; }
}

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?) Sample Controller Action:

public ActionResult Index()
{
    var role = new Role { RoleId = 1, ID = "ADMIN", Name = "Administrator", Description = "Hello World"  };
    int check = role.AddRole();

    return View();
}

Now ifSo, from app I want to saveam communicating with the Domain Model which has a record then I can do it from web app's ControllerAddRole() bymethod that will first map using automapper to the DALequivalent Data Model and Repo's Save or I can abstract it in BLL inside athen call SaveAdd() of repo method but that way BLL becomes dependent on DALto persist the record.

This way my BLL is becoming a little dependent on AutoMapper and DAL but my DAL seems dependent. I am trying to create just a simple layering for a simple yet well maintained project. Please suggest how I should solve this or anything else you see wrong hereon its problems and improvements.

Should be independent and contain only pure business logic and properties

Contain generic repository and Unit of work and data model meaning model that will reflect the database.

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?)

Now if I want to save a record then I can do it from web app's Controller by using the DAL and Repo's Save or I can abstract it in BLL inside a Save() method but that way BLL becomes dependent on DAL.

Please suggest how I should solve this or anything else you see wrong here.

Should be independent and contain only pure business logic and properties Sample Domain Model:

public class Role
{
    private UnitOfWork uow { get; set; }

    public Role()
    {
        uow = new UnitOfWork();
    }

    public int RoleId { get; set; }
    public string Name { get; set; }
    public string ID { get; set; }
    public string Description { get; set; }

    public int AddRole()
    {
        AutoMapper.Mapper.CreateMap<SoC.BLL.Role, SoC.DAL.Role>();
        var model = AutoMapper.Mapper.Map<SoC.DAL.Role>(this);
        return uow.Roles.Add(model);
    }
}

Contain generic repository and Unit of work and data model meaning model that will reflect the database. Sample Data Model:

public class Role
{
    [Key]
    public int RoleId { get; set; }

    [Required]
    [StringLength(50, ErrorMessage = "Name Cannot Be More Than 50 Characters")]
    public string Name { get; set; }

    [Required]
    [StringLength(6, ErrorMessage = "ID Cannot Be More Than 6 Characters")]
    public string ID { get; set; }


    [Required]
    [StringLength(250, ErrorMessage = "Description Cannot Be More Than 250 Characters")]
    public string Description { get; set; }
}

This will be ASP.NET MVC app that will use BLL. (Should or should not be aware of DAL?) Sample Controller Action:

public ActionResult Index()
{
    var role = new Role { RoleId = 1, ID = "ADMIN", Name = "Administrator", Description = "Hello World"  };
    int check = role.AddRole();

    return View();
}

So, from app I am communicating with the Domain Model which has a AddRole() method that will first map using automapper to the equivalent Data Model and then call Add() of repo method to persist the record.

This way my BLL is becoming a little dependent on AutoMapper and DAL but my DAL seems dependent. I am trying to create just a simple layering for a simple yet well maintained project. Please suggest on its problems and improvements.

Post Closed as "Not suitable for this site" by Jamal
Source Link
lbrahim
  • 363
  • 1
  • 3
  • 12
Loading