예제 #1
0
        public IHttpActionResult Backend_Position(PositionPartnerTypeRequest args)
        {
            BackendPartnerPositionViewModel viewmodel           = new BackendPartnerPositionViewModel();
            PartnerDataController           dataCtrl            = new PartnerDataController();
            PartnerPackDataController       partnerPackDataCtrl = new PartnerPackDataController();

            if (args.PartnerType == null)
            {
                args.PartnerType = partnerPackDataCtrl.GetItems().First().Name;
            }

            viewmodel.PartnerTypeOptions = partnerPackDataCtrl.GetItems().ToList().ConvertAll(x =>
            {
                return(x.Name);
            });

            int position = 1;
            var partner  = dataCtrl.GetItems().Where(x => x.PartnerPack.Name == args.PartnerType && x.IsActive).OrderBy(x => x.Position).ToList();

            viewmodel.Data = partner.ConvertAll(x => {
                return(new BackendPartnerPositionViewModelItem().FromModel(x, position++));
            }).ToList();

            return(Ok(viewmodel));
        }
예제 #2
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));
        }