Exemple #1
0
        internal static Entities.User GetUserToUpdate(TestCase testCase)
        {
            var request = GetRequestToUpdate(testCase);

            Entities.Address address = null;

            if (request.Address != null)
            {
                address = new Entities.Address
                          (
                    90,
                    request.Address.Street,
                    request.Address.Number,
                    request.Address.Complement,
                    request.Address.District,
                    request.Address.City,
                    request.Address.State,
                    request.Address.PostalCode
                          );
            }

            var idPhone = 88;

            return(new Entities.User
                   (
                       request.Id ?? 0,
                       new Name(request.FirstName, request.MiddleName, request.LastName),
                       request.Email,
                       request.Cpf,
                       address,
                       request.Phones.Select(r => new Entities.Phone(++idPhone, r.LocalCode, r.Number)).ToList()
                   ));
        }
Exemple #2
0
 public static DataModel.Address ToDataModel(this DomainModel.Address address)
 => new DataModel.Address
 {
     Id         = address.Id,
     Street     = address.Street,
     Number     = address.Number,
     Complement = address.Complement,
     District   = address.District,
     City       = address.City,
     State      = address.State,
     PostalCode = address.PostalCode
 };
Exemple #3
0
        internal static Entities.User GetUserByRequest(UserRequest request, IList <Entities.Phone> phones = null, Entities.Address address = null)
        {
            if (address == null)
            {
                address = new Entities.Address(request.Address.Street, request.Address.Number, request.Address.Complement, request.Address.District, request.Address.City, request.Address.State, request.Address.PostalCode);
            }

            if (phones == null)
            {
                phones = new List <Entities.Phone>();
            }

            var list =
                (
                    phones.Any() ?
                    request.Phones.Where(p => !phones.Any(db => db.LocalCode == p.LocalCode & db.Number == p.Number)) :
                    request.Phones
                )
                .Select(p => new Entities.Phone(p.LocalCode, p.Number)).ToList();

            list.ForEach(p => phones.Add(p));

            return(new Entities.User(new Name(request.FirstName, request.MiddleName, request.LastName), request.Email, request.Cpf, address, phones));
        }