public IHttpActionResult Backend_FilterList(BackendCateringListArgs args)
        {
            BackendCateringListViewModel  viewmodel        = new BackendCateringListViewModel();
            EventDataController           eventDataCtrl    = new EventDataController();
            CateringOrderDataController   orderDataCtrl    = new CateringOrderDataController();
            CateringProductDataController cateringDataCtrl = new CateringProductDataController();
            UserDataController            userDataCtrl     = new UserDataController();

            try
            {
                var events = eventDataCtrl.GetItems().OrderByDescending(x => x.ID).ToList();
                viewmodel.Filter.EventOptions = events.ConvertAll(x =>
                {
                    return(new BackendCateringFilter.CateringFilterEvent()
                    {
                        ID = x.ID,
                        Name = $"{x.EventType.Name} Vol.{x.Volume}"
                    });
                });

                var products = cateringDataCtrl.GetItems().ToList();
                viewmodel.ProductOptions = products.ConvertAll(x =>
                {
                    return(new BackendCateringProductItem().FromModel(x));
                });

                viewmodel.Filter.Name           = args.Filter.Name;
                viewmodel.Filter.SeatNumber     = args.Filter.SeatNumber;
                viewmodel.Filter.EventSelected  = args.Filter.EventSelected;
                viewmodel.Filter.StatusSelected = args.Filter.StatusSelected;
                viewmodel.Pagination            = args.Pagination;

                Int32 TotalItemsCount = 0;
                viewmodel.FromModel(orderDataCtrl.FilterList(args, out TotalItemsCount));
                viewmodel.Pagination.TotalItemsCount = TotalItemsCount;
            }
            catch (Exception ex)
            {
                return(Error(viewmodel, ex));
            }

            return(Ok(viewmodel));
        }
Exemple #2
0
        public static BackendCateringListViewModel FromModel(this BackendCateringListViewModel viewmodel, IEnumerable <CateringOrder> modelList)
        {
            viewmodel.Data = new List <BackendCateringViewModelItem>().FromModel(modelList);

            return(viewmodel);
        }