示例#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 Backend_FilterList(BackendPartnerListArgs args)
        {
            BackendPartnerListViewModel viewmodel           = new BackendPartnerListViewModel();
            PartnerDataController       dataCtrl            = new PartnerDataController();
            PartnerPackDataController   partnerPackdataCtrl = new PartnerPackDataController();

            try
            {
                viewmodel.Filter.Name                = args.Filter.Name;
                viewmodel.Filter.StatusSelected      = args.Filter.StatusSelected;
                viewmodel.Filter.PartnerTypeSelected = args.Filter.PartnerTypeSelected;
                viewmodel.Pagination = args.Pagination;
                viewmodel.Filter.PartnerTypeOptions = partnerPackdataCtrl.GetItems().Select(x => x.Name).OrderBy(x => x).ToList();

                Int32 TotalItemsCount;
                viewmodel.Data.FromModel(dataCtrl.FilterList(args, out TotalItemsCount));

                viewmodel.Pagination.TotalItemsCount = TotalItemsCount;
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel));
        }
示例#3
0
        public IHttpActionResult Backend_Detail_New()
        {
            BackendPartnerViewModel      viewmodel              = new BackendPartnerViewModel();
            PartnerDataController        dataCtrl               = new PartnerDataController();
            PartnerPackDataController    partnerPackdataCtrl    = new PartnerPackDataController();
            PartnerDisplayDataController partnerDisplayDataCtrl = new PartnerDisplayDataController();

            try
            {
                viewmodel.PartnerTypeOptions = partnerPackdataCtrl.GetItems().ToList().ConvertAll(x =>
                {
                    return(new BackendPartnerType()
                    {
                        ID = x.ID, Name = x.Name
                    });
                }).OrderBy(x => x.Name).ToList();
                foreach (var display in partnerDisplayDataCtrl.GetItems())
                {
                    viewmodel.Data.Display.Add(new data.ViewModel.Partner.PartnerDisplay()
                    {
                        ID    = display.ID,
                        Name  = display.Name,
                        Value = false
                    });
                }
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel));
        }
示例#4
0
        public IHttpActionResult Backend_Detail(Int32 id)
        {
            BackendPartnerViewModel   viewmodel           = new BackendPartnerViewModel();
            PartnerDataController     dataCtrl            = new PartnerDataController();
            PartnerPackDataController partnerPackdataCtrl = new PartnerPackDataController();

            try
            {
                viewmodel.Data.FromModel(dataCtrl.GetItem(id));
                viewmodel.PartnerTypeOptions = partnerPackdataCtrl.GetItems().ToList().ConvertAll(x =>
                {
                    return(new BackendPartnerType()
                    {
                        ID = x.ID, Name = x.Name
                    });
                }).OrderBy(x => x.Name).ToList();
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel));
        }