Exemplo n.º 1
0
        public static User Update(User user)
        {
            bool isNew = user.IsNew;

            UserMapper.Instance.Update(user);

            if (user.BrandsLoaded)
            {
                if (!isNew)
                {
                    UserBrandMapper.Instance.DeleteUserBrands(user.UserId);
                }

                if (user.UserRole != Shared.UserRole.SuperAdministrator)
                {
                    foreach (Brand brand in user.Brands)
                    {
                        UserBrand ub = UserBrand.New();
                        ub.UserId  = user.UserId.GetValueOrDefault();
                        ub.BrandId = brand.BrandId.GetValueOrDefault();
                        UserBrand.Update(ub);
                    }
                }
            }

            return(user);
        }
Exemplo n.º 2
0
        protected override object ReadRow(IRowReader reader)
        {
            UserBrand userBrand = UserBrand.New();

            // Table Fields
            userBrand.UserBrandId = reader.GetInt32("UserBrandId");
            userBrand.UserId      = reader.GetInt32("UserId");
            userBrand.BrandId     = reader.GetInt32("BrandId");


            userBrand.IsDirty = false;
            userBrand.ChangedProperties.Clear();

            return(userBrand);
        }