Beispiel #1
0
        public IHttpActionResult Get()
        {
            PartnerListViewModel  viewmodel = new PartnerListViewModel();
            PartnerDataController dataCtrl  = new PartnerDataController();

            foreach (var model in dataCtrl.GetItems().Where(x => x.IsActive).OrderBy(x => x.PartnerPackID).ThenBy(x => x.Position))
            {
                PartnerViewModelItem item = new PartnerViewModelItem();

                item.FromModel(model);
                viewmodel.Data.Add(item);
            }

            return(Ok(viewmodel));
        }
        public static PartnerViewModelItem FromModel(this PartnerViewModelItem viewmodel, Partner model)
        {
            viewmodel.Name        = model.Name;
            viewmodel.Description = model.Content;
            viewmodel.Image       = Properties.Settings.Default.imageAbsolutePath + model.ImageOriginal;
            viewmodel.Link        = model.Link;
            viewmodel.RefLink     = model.Link;

            viewmodel.PartnerType.FromModel(model.PartnerPack);

            // TODO Nachfolgendes
            string[] displays = { "Header", "Footer" };
            foreach (var display in displays)
            {
                viewmodel.Display.Add(new data.ViewModel.Partner.PartnerDisplay()
                {
                    ID = 1, Name = display, Value = true
                });
            }

            return(viewmodel);
        }