Exemplo n.º 1
0
        public static LeftMenuViewModel Get(User user, string selectedMenu)
        {
            var result = new LeftMenuViewModel()
            {
                CompanyNameWithTypeOfOwnership = user.CompanyNameWithTypeOfOwnership,
                Rating           = user.Rating.ToString(),
                RatingImagesHtml = user.RatingImagesHtml,
                SelectedMenu     = selectedMenu,
                CurrentUserId    = user.Id
            };

            if (user.SmallPhotoUrl != null)
            {
                result.SmallPhotoUrl = user.SmallPhotoUrl;
            }
            else
            {
                //var photos = PhotosDAL.GetCompanyLogoGroup(user.Id).OrderBy(p => p.Width).ToList();
                //result.SmallPhotoUrl = photos.Any() ? photos.First().Url : PhotoHelper.NoLogoImageUrl;
                user.LogoGroup       = PhotosDAL.GetCompanyLogoGroup(user.Id);
                result.SmallPhotoUrl = user.GetBestFitLogoPhoto(1).Url;
            }

            result.AdsCount            = AdsDAL.GetAdsCount((int)AdStatuses.Published, user.Id);
            result.UnreadMessagesCount = MessagesDAL.GetUnreadMessagesCount(user.Id);

            return(result);
        }
Exemplo n.º 2
0
        public static string GetSmallPhotoUrl(int userId)
        {
            var logos = PhotosDAL.GetCompanyLogoGroup(userId);

            if (logos.Any())
            {
                int requiredDimension           = 200;
                var smallestDimensionDifference = logos.Min(p => Math.Abs(p.HigherDimension.Value - requiredDimension));
                var logo = logos.FirstOrDefault(p => Math.Abs(p.HigherDimension.Value - requiredDimension) == smallestDimensionDifference);
                if (logo != null)
                {
                    return(logo.Url);
                }
            }

            return(PhotoHelper.NoLogoImageUrl);
        }