Esempio n. 1
0
        public static Member FromDataAccessToBusinessMap(DAL.Member member)
        {
            var Member    = member ?? throw new ArgumentNullException("member");
            var dTOMember = new Member()
            {
                Id             = member.Id,
                LastName       = member.LastName,
                FirstName      = member.FirstName,
                MiddleName     = member.MiddleName,
                Address        = member.Address,
                Phone          = member.Phone,
                IsActiveMember = member.IsActiveMember,
                AdditionalInfo = member.AdditionalInfo
            };
            var areas = new List <Area>();

            foreach (var memberArea in member.MembersAreas)
            {
                areas.Add(new Area()
                {
                    Id             = memberArea.Area.Id,
                    Square         = memberArea.Area.Square,
                    HasElectricity = memberArea.Area.HasElectricity,
                    IsPrivate      = memberArea.Area.IsPrivate,
                    OwnedFrom      = memberArea.OwnedFrom,
                    OwnedTo        = memberArea.OwnedTo,
                    ParentAreaId   = memberArea.Area.ParentAreaId
                });
            }
            dTOMember.Areas = areas;
            return(dTOMember);
        }
Esempio n. 2
0
        public static DAL.Member FromBusinessToDataAccessMap(Member member)
        {
            var Member           = member ?? throw new ArgumentNullException("member");
            var dataAccessMember = new DAL.Member()
            {
                Id             = Member.Id,
                LastName       = Member.LastName,
                FirstName      = Member.FirstName,
                MiddleName     = Member.MiddleName,
                Address        = Member.Address,
                Phone          = Member.Phone,
                AdditionalInfo = Member.AdditionalInfo,
                IsActiveMember = Member.IsActiveMember
            };
            var membersAreas = new List <DAL.MembersAreas>();

            if (member.Areas != null)
            {
                foreach (var area in member.Areas)
                {
                    membersAreas.Add(new DAL.MembersAreas()
                    {
                        Area = new DAL.Area()
                        {
                            Id             = area.Id,
                            Square         = area.Square,
                            HasElectricity = area.HasElectricity,
                            IsPrivate      = area.IsPrivate,
                            ParentAreaId   = area.ParentAreaId
                        },
                        OwnedFrom = area.OwnedFrom,
                        OwnedTo   = area.OwnedTo,
                        AreaId    = area.Id
                    });
                }
                dataAccessMember.MembersAreas = membersAreas;
            }
            return(dataAccessMember);
        }