public BarViewModel(IBar bar)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (bar.Description.Length < 256)
            {
                stringBuilder.Append(bar.Description.Substring(0));
            }
            else
            {
                stringBuilder.Append(bar.Description.Substring(0, 255));
            }
            stringBuilder.Append("...");
            Id               = bar.Id;
            Name             = bar.Name;
            Address          = bar.Address;
            AverageRating    = bar.AverageRating;
            ShortDescription = stringBuilder.ToString();
            Description      = bar.Description;
            RatingsCount     = bar.Ratings.Count();
            City             = bar.City.Name;
            Country          = bar.Country.Name;
            Ratings          = new BarRatingListViewModel(bar.Ratings);
            Comments         = new BarCommentListViewModel(bar.Comments);
            Cocktails        = new BarCocktailListViewModel(bar.Cocktails);
            FavoritedBy      = new UserBarListViewModel(bar.FavoritedBy);
            Hidden           = bar.Hidden == 1 ? true : false;
        }
Ejemplo n.º 2
0
 public UserViewModel(IUser user)
 {
     Id                = user.Id;
     UserName          = user.UserName;
     FirstName         = user.FirstName;
     LastName          = user.LastName;
     Password          = user.Password;
     AccountStatus     = user.AccountStatus;
     AccountType       = user.AccountType;
     Country           = user.Country;
     City              = user.City;
     BarRatings        = new BarRatingListViewModel(user.BarRatings);
     BarComments       = new BarCommentListViewModel(user.BarComments);
     CocktailRatings   = new CocktailRatingListViewModel(user.CocktailRatings);
     CocktailComments  = new CocktailCommentListViewModel(user.CocktailComments);
     FavoriteBars      = new UserBarListViewModel(user.FavoriteBars);
     FavoriteCocktails = new UserCocktailListViewModel(user.FavoriteCocktails);
     Notifications     = new NotificationListViewModel(user.Notifications);
     LastLogIn         = user.LastLogIn;
     LastPage          = true;
 }