Example #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);
        }