Exemplo n.º 1
0
        public static Area FromDataAccessToBusinessMap(DAL.Area area)
        {
            var Area    = area ?? throw new ArgumentNullException("area");
            var dTOArea = new Area()
            {
                Id             = area.Id,
                Square         = area.Square,
                HasElectricity = area.HasElectricity,
                IsPrivate      = area.IsPrivate,
                ParentAreaId   = area.ParentAreaId
            };
            var members = new List <Member>();

            foreach (var memberArea in area.MembersAreas)
            {
                members.Add(new Member()
                {
                    Id             = memberArea.Member.Id,
                    LastName       = memberArea.Member.LastName,
                    FirstName      = memberArea.Member.FirstName,
                    MiddleName     = memberArea.Member.MiddleName,
                    Address        = memberArea.Member.Address,
                    Phone          = memberArea.Member.Phone,
                    IsActiveMember = memberArea.Member.IsActiveMember,
                    AdditionalInfo = memberArea.Member.AdditionalInfo
                });
            }
            dTOArea.Members = members;
            return(dTOArea);
        }
Exemplo n.º 2
0
        public static DAL.Area FromBusinessToDataAccessMap(Area area)
        {
            var Area           = area ?? throw new ArgumentException("area");
            var dataAccessArea = new DAL.Area()
            {
                Id             = Area.Id,
                IsPrivate      = Area.IsPrivate,
                HasElectricity = Area.HasElectricity,
                ParentAreaId   = Area.ParentAreaId,
                Square         = Area.Square
            };
            var membersAreas = new List <DAL.MembersAreas>();

            foreach (var member in area.Members)
            {
                membersAreas.Add(new DAL.MembersAreas()
                {
                    AreaId = Area.Id,
                    Member = new DAL.Member()
                    {
                        Id             = member.Id,
                        LastName       = member.LastName,
                        FirstName      = member.FirstName,
                        MiddleName     = member.MiddleName,
                        AdditionalInfo = member.AdditionalInfo,
                        Address        = member.Address,
                        IsActiveMember = member.IsActiveMember,
                        Phone          = member.Phone
                    },
                    MemberId  = member.Id,
                    OwnedFrom = Area.OwnedFrom,
                    OwnedTo   = Area.OwnedTo
                });
            }
            dataAccessArea.MembersAreas = membersAreas;
            return(dataAccessArea);
        }