Exemplo n.º 1
0
 public LocationPageVM(Location location)
 {
     Rate     = 0;
     Currency = location.Currency;
     if (location.PhotoAlbum != null && location.PhotoAlbum.Any())
     {
         PhotoAlbum = location.PhotoAlbum?.Select(m => new IconVM(m.Id, $"{m.Path}{m.Name}{m.Extension}")).ToList();
     }
     if (location.Feedbacks != null && location.Feedbacks.Any())
     {
         Feedbacks = location.Feedbacks?.Select(m => new FeedbackVM(m, m.UserProfile, m.Photos)).ToList();
         Rate      = location.Feedbacks.Sum(e => e.Stars) / location.Feedbacks.Count;
     }
     Name      = location.Name;
     Address   = location.Address;
     Longitude = Convert.ToDecimal(location.Longitude.Replace('.', ','));
     Latitude  = Convert.ToDecimal(location.Latitude.Replace('.', ','));
     if (location.Company != null)
     {
         Facebook      = location.Company.Facebook;
         Vk            = location.Company.Vk;
         Instagram     = location.Company.Instagram;
         Site          = location.Company.Site;
         Specification = new IconVM(location.Company.Specification.Id, location.Company.Specification.Value);
         CompanyId     = location.Company.Id;
         CompanyName   = location.Company.Name;
         CompanyPhoto  =
             $"{location.Company.File?.Path}{location.Company.File?.Name}{location.Company.File?.Extension}";
     }
 }
Exemplo n.º 2
0
        public MenuPageVM(Menu m)
        {
            Id = m.Id;
            if (m.LocationId != null)
            {
                LocationId = m.LocationId.Value;
            }
            Title = m.Title;
            Info  = m.Info;
            if (m.Icon != null)
            {
                Icon = new IconVM(m.Icon);
            }
            LocationName = m.Location?.Name;
            var currency = "";

            if (m.Location != null)
            {
                currency = m.Location.Currency;
            }

            if (m.MenuItems != null && m.MenuItems.Any())
            {
                MenuItems = m.MenuItems?.Select(e => new MenuItemPageVM(e, currency)).ToList();
            }
        }
Exemplo n.º 3
0
        public UserTabVM(UserProfile m, Sex s, FileModel f)
        {
            Id        = m.UserId;
            FirstName = m.FirstName;
            LastName  = m.LastName;
            FullName  = $"{m.FirstName} {m.LastName[0]}.";
            if (s != null)
            {
                Sex = s.Value;
            }
            Age           = DateTime.Now.Year - m.DateBirth.Year;
            UserProfileId = m.Id;
            if (DateTime.Now.DayOfYear < m.DateBirth.DayOfYear)
            {
                Age--;
            }

            if (f != null)
            {
                Photo = new IconVM(m.Id, $"{f.Path}{f.Name}{f.Extension}");
            }
        }
Exemplo n.º 4
0
        public OrderItemVM(OrderItem o, string currency)
        {
            Rate     = 0;
            Id       = o.Id;
            Title    = o.Title;
            Currency = o.Order.Location.Currency ?? currency;

            Count        = o.Count;
            PricePerItem = o.PricePerItem;
            Status       = o.Status;
            if (o.OrderId != null)
            {
                OrderId = o.OrderId.Value;
            }

            if (o.MenuItemId != null)
            {
                MenuItemId = o.MenuItemId.Value;
                if (o.UserId != null)
                {
                    UserProfileId = o.UserId.Value;
                }
                if (o.MenuItemId != null)
                {
                    if (o.MenuItem != null)
                    {
                        Photo = new IconVM(o.MenuItemId.Value,
                                           $"{o.MenuItem.FileModel?.Path}{o.MenuItem.FileModel?.Name}{o.MenuItem.FileModel?.Extension}");
                    }
                }
            }

            if (o.MenuItem != null && (o.MenuItem.Feedbacks != null && o.MenuItem.Feedbacks.Any()))
            {
                Feedbacks = o.MenuItem.Feedbacks.Select(e => new FeedbackVM(e, e.UserProfile, e.Photos)).ToList();
                Rate      = o.MenuItem.Feedbacks.Sum(e => e.Stars) / o.MenuItem.Feedbacks.Count;
            }
        }
Exemplo n.º 5
0
        //public List<FeedbackVM> Feedbacks { get; set; } = new List<FeedbackVM>();

        public MenuItemPageVM(MenuItem m, string currency)
        {
            Id    = m.Id;
            Title = m.Title;
            Info  = m.Info;
            Note  = m.Note;
            Price = m.Price;
            if (m.Menu != null)
            {
                if (m.Menu.Location != null)
                {
                    Currency = m.Menu.Location.Currency;
                }
                else
                {
                    Currency = currency;
                }

                Rate           = 0;
                PriceWithSales = m.PriceWithSales;
                IsActive       = m.IsActive;
                if (m.MenuId != null)
                {
                    MenuId = m.MenuId.Value;
                }
                MenuTitle = m.Menu?.Title;
            }

            Photo = new IconVM(m.Id, $"{m.FileModel?.Path}{m.FileModel?.Name}{m.FileModel?.Extension}");
            if (m.Feedbacks != null && m.Feedbacks.Any())
            {
                FeedbacksCount = m.Feedbacks.Count;
                //Feedbacks = m.Feedbacks.Select(e => new FeedbackVM(e)).ToList();
                Rate = m.Feedbacks.Sum(e => e.Stars) / FeedbacksCount;
            }
        }