Exemple #1
0
        public static IList <DataModel.UserPhone> ToDataModel(this IList <DomainModel.Phone> phones, DomainModel.User user)
        {
            var list   = new List <DataModel.UserPhone>();
            var dmUser = new DataModel.User
            {
                FirstName  = user.Name.FirstName,
                MiddleName = user.Name.MiddleName,
                LastName   = user.Name.LastName,
                Email      = user.Email,
                Cpf        = user.Cpf
            };

            if (user.Id > 0)
            {
                dmUser.Id = user.Id;
            }

            foreach (var p in phones)
            {
                var up = new DataModel.UserPhone();

                if (p.Id > 0)
                {
                    up.IdPhone = p.Id;
                }
                else
                {
                    up.Phone = new DataModel.Phone
                    {
                        LocalCode = p.LocalCode,
                        Number    = p.Number
                    }
                };

                if (user.Id > 0)
                {
                    up.IdUser = user.Id;
                }
                else
                {
                    up.User = dmUser;
                }

                list.Add(up);
            }

            return(list);
        }
    }
Exemple #2
0
 public static DomainModel.Phone ToDomainModel(this DataModel.UserPhone phone)
 => new DomainModel.Phone(phone.IdPhone, phone.Phone?.LocalCode, phone.Phone?.Number);