예제 #1
0
        public HttpResponseMessage ProductSearchExport(string catalogType, string searchTerms, [FromUri] SearchInputModel searchModel, ExportRequestModel exportRequest)
        {
            HttpResponseMessage ret;

            try
            {
                searchModel.Size        = 500;
                searchModel.CatalogType = catalogType;

                ProductsReturn prods = _catalogService.GetProductsBySearch(this.SelectedUserContext, searchTerms, searchModel, this.AuthenticatedUser);

                prods.Products = FavoritesAndNotesHelper.GetFavoritesAndNotesFromLists(this.AuthenticatedUser, this.SelectedUserContext, prods.Products, _listService);

                ContractInformationHelper.GetContractCategoriesFromLists(SelectedUserContext, prods.Products, _listService);

                ItemOrderHistoryHelper.GetItemOrderHistories(_catalogLogic, SelectedUserContext, prods.Products);

                if (exportRequest.Fields != null)
                {
                    _exportSettingRepository.SaveUserExportSettings(this.AuthenticatedUser.UserId, ExportType.Products, ListType.Custom, exportRequest.Fields, exportRequest.SelectedType);
                }

                ret = ExportModel <Product>(prods.Products, exportRequest, SelectedUserContext);
            }
            catch (Exception ex)
            {
                _elRepo.WriteErrorLog("ProductSearchExport", ex);
                ret = Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
            return(ret);
        }
예제 #2
0
        public HttpResponseMessage ExportCartDetail(Guid cartId, ExportRequestModel exportRequest)
        {
            HttpResponseMessage ret;

            try
            {
                var cart = _shoppingCartLogic.ReadCart(this.AuthenticatedUser, this.SelectedUserContext, cartId);
                ContractInformationHelper.GetContractCategoriesFromLists(this.SelectedUserContext, cart.Items, _listService);
                ItemOrderHistoryHelper.GetItemOrderHistories(_catalogLogic, SelectedUserContext, cart.Items);
                FavoritesAndNotesHelper.GetFavoritesAndNotesFromLists(AuthenticatedUser, SelectedUserContext, cart.Items, _listService);

                if (exportRequest.Fields != null)
                {
                    _exportLogic.SaveUserExportSettings(AuthenticatedUser.UserId, Core.Models.Configuration.EF.ExportType.CartDetail, Core.Enumerations.List.ListType.Custom,
                                                        exportRequest.Fields, exportRequest.SelectedType);
                }

                ret = ExportModel <ShoppingCartItem>(cart.Items, exportRequest, SelectedUserContext);
            }
            catch (Exception ex)
            {
                ret = Request.CreateResponse(HttpStatusCode.InternalServerError);
                ret.ReasonPhrase = ex.Message;
                _log.WriteErrorLog("ExportCartDetail", ex);
            }
            return(ret);
        }
예제 #3
0
        public HttpResponseMessage ExportOrders(InvoiceExportRequestModel request)
        {
            HttpResponseMessage ret;

            try
            {
                request.paging.Size = int.MaxValue;
                request.paging.From = 0;

                var transactions = _invLogic.PendingTransactionsAllCustomers(this.AuthenticatedUser, request.paging);

                if (request.export.Fields != null)
                {
                    _exportLogic.SaveUserExportSettings(this.AuthenticatedUser.UserId, Core.Models.Configuration.EF.ExportType.PendingTransactions, KeithLink.Svc.Core.Enumerations.List.ListType.Custom, request.export.Fields, request.export.SelectedType);
                }

                ret = ExportModel <PaymentTransactionModel>(transactions.Results, request.export, SelectedUserContext);
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("ExportOrders", ex);
                ret = Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
            return(ret);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <param name="context"></param>
        /// <param name="exportRequest"></param>
        /// <param name="invoiceNumber"></param>
        /// <param name="contractdictionary"></param>
        /// <returns></returns>
        public List <InvoiceItemModel> GetExportableInvoiceItems(UserProfile user,
                                                                 UserSelectedContext context,
                                                                 ExportRequestModel exportRequest,
                                                                 string invoiceNumber,
                                                                 Dictionary <string, string> contractdictionary)
        {
            if (exportRequest.Fields != null)
            {
                _exportLogic.SaveUserExportSettings(user.UserId,
                                                    Core.Models.Configuration.EF.ExportType.InvoiceDetail,
                                                    KeithLink.Svc.Core.Enumerations.List.ListType.Custom,
                                                    exportRequest.Fields,
                                                    exportRequest.SelectedType);
            }

            Order order = _orderLogic.GetOrder(context.BranchId, invoiceNumber);

            List <InvoiceItemModel> items = order.Items.Select(i => i.ToInvoiceItem()).ToList();

            items = items.Select(i => _invLogic.AssignContractCategory(contractdictionary, i)).ToList();

            return(items);
        }
예제 #5
0
        public HttpResponseMessage ExportList(ListType type, long listId, [FromBody] ExportRequestModel exportRequest)
        {
            HttpResponseMessage ret;

            try
            {
                var list = _listService.ReadList(this.AuthenticatedUser, this.SelectedUserContext, type, listId, true);

                ListModel exportListModel = list.Clone();
                exportListModel.ListId = 0;

                ItemOrderHistoryHelper.GetItemOrderHistories(_catalogLogic, SelectedUserContext, exportListModel.Items);

                if (exportRequest.Filter != null)
                {
                    exportListModel.Items = exportListModel.Items.AsQueryable()
                                            .Filter(exportRequest.Filter, null)
                                            .ToList();
                }



                if (exportRequest.Sort != null)
                {
                    List <SortInfo> slist = new List <SortInfo>();
                    if (exportRequest != null &&
                        exportRequest.Sort != null)
                    {
                        slist = exportRequest.Sort;
                    }
                    exportListModel.Items = exportListModel.Items.AsQueryable()
                                            .Sort(slist, typeof(ListItemModel).GetProperties().First().Name)
                                            .ToList();
                }

                if (exportRequest.Fields != null)
                {
                    _exportLogic.SaveUserExportSettings(this.AuthenticatedUser.UserId, Core.Models.Configuration.EF.ExportType.List, exportListModel.Type,
                                                        exportRequest.Fields, exportRequest.SelectedType);
                }
                ret = ExportModel <ListItemModel>(exportListModel.Items, exportRequest, SelectedUserContext);
            }
            catch (Exception ex)
            {
                _elRepo.WriteErrorLog("List Export", ex);
                ret = Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
            return(ret);
        }
예제 #6
0
        public HttpResponseMessage ExportOrders(ExportRequestModel exportRequest)
        {
            HttpResponseMessage ret;

            try
            {
                var orders = _orderLogic.GetOrders(AuthenticatedUser.UserId, SelectedUserContext)
                             .OrderByDescending(o => o.CreatedDate)
                             .ToList();
                if (exportRequest.Fields != null)
                {
                    _exportLogic.SaveUserExportSettings(AuthenticatedUser.UserId, Core.Models.Configuration.EF.ExportType.Order, Core.Enumerations.List.ListType.Custom,
                                                        exportRequest.Fields, exportRequest.SelectedType);
                }

                ret = ExportModel <Order>(orders, exportRequest, SelectedUserContext);
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("ExportInvoices", ex);
                ret = Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
            return(ret);
        }
예제 #7
0
        public HttpResponseMessage ExportItemUsage([FromUri] ItemUsageReportQueryModel usageQuery, ExportRequestModel exportRequest)
        {
            HttpResponseMessage retVal;

            try
            {
                if (usageQuery != null && usageQuery.fromDate.HasValue && usageQuery.toDate.HasValue)
                {
                    usageQuery.UserSelectedContext = this.SelectedUserContext;
                    var ret = _reportLogic.GetItemUsage(usageQuery);
                    ContractInformationHelper.GetContractCategoriesFromLists(SelectedUserContext, ret, _listService);
                    ItemOrderHistoryHelper.GetItemOrderHistories(_catalogLogic, SelectedUserContext, ret);

                    if (exportRequest.Fields != null)
                    {
                        _exportLogic.SaveUserExportSettings(this.AuthenticatedUser.UserId, Core.Models.Configuration.EF.ExportType.ItemUsage, Core.Enumerations.List.ListType.Custom, exportRequest.Fields, exportRequest.SelectedType);
                    }

                    retVal = ExportModel <ItemUsageReportItemModel>(ret.ToList(), exportRequest, SelectedUserContext);
                }
                else
                {
                    retVal = new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.NoContent
                    }
                };
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("ExportItemUsage", ex);
                retVal = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.InternalServerError
                };
            }
            return(retVal);
        }