Ejemplo n.º 1
0
 public Account(DO.Account account, ICollection <DO.ApplicationStore> applicationStores)
     : this(account)
 {
     if (!applicationStores.IsNull())
     {
         Applications      = null;
         ApplicationsStore = applicationStores.Select(app => new DTO.AccountApplicationStore(app)).OrderBy(a => a.Name).ToList();
     }
 }
Ejemplo n.º 2
0
 public Account(DO.Account account, ICollection <DO.ApplicationStore> applicationStores, bool blacklist = false)
     : this(account, applicationStores)
 {
     if (blacklist)
     {
         if (!account.BlacklistCollection.IsNull())
         {
             Blacklist = account.BlacklistCollection.Where(x => x.Blocked).Select(x => new DTO.Blacklist(x)).ToList();
         }
     }
 }
Ejemplo n.º 3
0
        public virtual DO.Account Transfer()
        {
            var account = new DO.Account();

            account.FacebookId      = this.FacebookId.IsNullOrWhiteSpace() ? this.FacebookId : this.FacebookId.Trim();
            account.Password        = this.Password;
            account.Login           = this.Login.IsNullOrWhiteSpace() ? this.Login : this.Login.Trim();
            account.Email           = this.Email.IsNullOrWhiteSpace() ? this.Email : this.Email.Trim();
            account.Document        = this.Document.IsNullOrWhiteSpace() ? this.Document : this.Document.Trim();
            account.DataFingerprint = this.DataFingerprint.IsNullOrWhiteSpace() ? this.DataFingerprint : this.DataFingerprint.Trim();

            if (!this.Customer.IsNull())
            {
                account.Customer = this.Customer.Transfer(this);
            }

            return(account);
        }
Ejemplo n.º 4
0
        public DO.Account Transfer(List <DO.ApplicationStore> applicationStores)
        {
            var account = new DO.Account()
            {
                FacebookId = this.FacebookId,
                Password   = this.Password,
                Login      = this.Login,
                Email      = this.Email,
                AccountApplicationStoreCollection = applicationStores.Select(a => new DO.AccountApplicationStore(this.Code, a.Code)).ToList(),
                Document          = this.Document.ClearStrings(),
                DataFingerprint   = this.DataFingerprint,
                CodeEmailTemplate = this.CodeEmailTemplate
            };

            if (!this.Customer.IsNull())
            {
                account.Customer = this.Customer.Transfer(this);
            }
            else if (this.Document.IsValidCNPJ())
            {
                account.Customer = new DO.Company()
                {
                    Cnpj      = this.Document.ClearStrings(),
                    Email     = this.Email,
                    Name      = !this.Name.IsNullOrWhiteSpace() ? this.Name : this.Email,
                    Addresses = new List <AddressCustomer>()
                };
            }
            else
            {
                account.Customer = new DO.Person()
                {
                    FirstName = !this.Name.IsNullOrWhiteSpace() ? this.Name : this.Email,
                    Email     = this.Email,
                    Gender    = string.Empty,
                    Cpf       = this.Document.IsValidCPF() ? this.Document.ClearStrings() : string.Empty,
                    Addresses = new List <AddressCustomer>()
                };
            }

            return(account);
        }
Ejemplo n.º 5
0
        public Account(DO.Account account)
        {
            Code            = account.Code;
            FacebookId      = account.FacebookId;
            Login           = account?.Login?.Trim();
            Email           = account?.Email?.Trim();
            Password        = account.Password;
            Document        = account?.Document?.ClearStrings();
            Status          = account.Status;
            SaveDate        = account.SaveDate;
            UpdateDate      = account.UpdateDate;
            DataFingerprint = account.DataFingerprint;

            QtyWrongsPassword = account.QtyWrongsPassword;
            LockedUp          = account.LockedUp;
            ApplicationsStore = null;

            if (!account.AccountRoles.IsNull() && account.AccountRoles.Count > 0 && !account.AccountRoles.Any(r => r.Role.Permissions.IsNull()))
            {
                Roles = account.AccountRoles.Where(r => r.Status && r.Role.Status && r.Role.Permissions.Any(p => p.Status)).Select(r => new Role()
                {
                    Code            = r.Role.Code,
                    Name            = r.Role.Name,
                    Status          = r.Role.Status,
                    Type            = r.Role.Type,
                    TypeCode        = r.Role.Type.AsInt(),
                    TypeDescription = r.Role.Type.GetDescription(),
                    Store           = new Store()
                    {
                        Code = r.Role.Store.Code,
                        Name = r.Role.Store.Name
                    }
                }).ToList();
            }

            if (!account.Metadata.IsNull())
            {
                var metadata = new Dictionary <string, object>();

                account.Metadata.ForEach(m => metadata.Add(m.Field.JsonId, m.Value));

                this.Metadata = metadata;

                this.MetadataFields = account.Metadata.OrderBy(m => m.Field.SaveDate).Select(m => new DTO.MetadataField(m.Field, m)).ToList();
            }

            if (!account.Customer.IsNull() && account.Customer is DO.Customer)
            {
                switch (account.Customer.GetType().Name)
                {
                case "Person":
                    Customer = new Person((DO.Person)account.Customer);
                    break;

                case "Company":
                    Customer = new Company((DO.Company)account.Customer);
                    break;

                default:
                    Customer = new Customer(account.Customer);
                    break;
                }
            }
        }