Пример #1
0
        public List <InventoryViewModel> Search(InventorySearchModel searchModel)
        {
            var products = _shopContext.Products.Select(x => new { x.Id, x.Name }).ToList();
            var query    = _inventoryContext.Inventory.Select(x => new InventoryViewModel
            {
                Id           = x.Id,
                UnitPrice    = x.UnitPrice,
                InStock      = x.InStock,
                ProductId    = x.ProductId,
                CurrentCount = x.CalculateCurrentCount(),
                CreationDate = x.CreationDate.ToFarsi()
            });

            if (searchModel.ProductId > 0)
            {
                query = query.Where(x => x.ProductId == searchModel.ProductId);
            }

            if (searchModel.InStock)
            {
                query = query.Where(x => !x.InStock);
            }

            var inventory = query.OrderByDescending(x => x.Id).ToList();

            inventory.ForEach(item =>
                              item.Product = products.FirstOrDefault(x => x.Id == item.ProductId)?.Name);

            return(inventory);
        }
Пример #2
0
        public List <InventoryViewModel> Search(InventorySearchModel searchModel)
        {
            var products = _shopContext.Products.Select(p => new { Id = p.Id, Name = p.Name }).AsNoTracking().ToList();
            var query    = _db.Inventory.Select(i => new InventoryViewModel()
            {
                Id           = i.Id,
                ProductId    = i.ProductId,
                CurrentCount = i.CalculateCurrentCount(),
                IsInStock    = i.IsInStock,
                UnitPrice    = i.UnitPrice
            });

            if (searchModel.ProductId != 0)
            {
                query = query.Where(i => i.ProductId == searchModel.ProductId);
            }

            if (searchModel.IsNotInStock)
            {
                query = query.Where(i => i.IsInStock == false);
            }

            var result = query.AsNoTracking().ToList();

            result.ForEach(i => i.Product = products.FirstOrDefault(p => p.Id == i.ProductId)?.Name);
            return(result);
        }
        public void OnGet(InventorySearchModel searchModel)
        {
            var products = _productApplication.GetProducts();

            Products  = new SelectList(products, "Id", "Name");
            Inventory = _inventoryApplication.Search(searchModel);
        }
        public List <InventoryViewModel> Search(InventorySearchModel searchModel)
        {
            var query = _context.Inventory.Select(c => new InventoryViewModel()
            {
                Id           = c.Id,
                CreationDate = c.CreationDate.ToFarsi(),
                InStock      = c.InStock,
                CurrentCount = c.CalculateCurrentCount(),
                ProductId    = c.ProductId,
                UnitPrice    = c.UnitPrice
            });

            if (searchModel.ProductId > 0)
            {
                query = query.Where(c => c.ProductId == searchModel.ProductId);
            }

            if (searchModel.InStock)
            {
                query = query.Where(c => !c.InStock);
            }

            var Products = _shopcontext.Products.Select(c => new { c.Id, c.Name }).ToList();

            var inventory = query.OrderByDescending(c => c.Id).ToList();

            inventory.ForEach(
                item => item.ProductName = Products.FirstOrDefault(c => c.Id == item.ProductId)?.Name);

            return(inventory);
        }
Пример #5
0
        public List <InventoryViewModel> GetNameWiseSearchedInventories(InventorySearchModel model)
        {
            var sqlQuery            = GetNameWiseSearchedInventoriesQuery(model.SearchKeyWord);
            var searchedInventories = _db.Query <InventoryViewModel>(sqlQuery).ToList();

            return(searchedInventories);
        }
        private IQueryable <ProductDto> GetDetail(InventorySearchModel searchModel)
        {
            IQueryable <ProductDto> list = null;

            if (!searchModel.HasAnyValue())
            {
                list = _inventoryService.GetAll().OrderByDescending(i => i.ProductId);
            }
            else
            {
                var predicate = PredicateBuilder.True <ProductDto>();

                if (!searchModel.CategoryId.IsNull())
                {
                    predicate = predicate.And(c => c.CategoryId == searchModel.CategoryId);
                }

                if (!searchModel.ProductCode.IsNull())
                {
                    predicate = predicate.And(c => c.ProductCode.Contains(searchModel.ProductCode));
                }

                if (!searchModel.ProductName.IsNull())
                {
                    predicate = predicate.And(c => c.ProductName.Contains(searchModel.ProductName));
                }

                if (!searchModel.ProductDescription.IsNull())
                {
                    predicate = predicate.And(c => c.ProductDescription.Contains(searchModel.ProductDescription));
                }

                if (!searchModel.ProductSize.IsNull())
                {
                    predicate = predicate.And(c => c.ProductSize.Contains(searchModel.ProductSize));
                }

                if (!searchModel.CurrentNum.IsNull())
                {
                    predicate = predicate.And(c => c.CurrentNum.Contains(searchModel.CurrentNum));
                }

                if (!searchModel.DRNum.IsNull())
                {
                    predicate = predicate.And(c => c.DRNum.Contains(searchModel.DRNum));
                }

                if (!searchModel.CartonNum.IsNull())
                {
                    predicate = predicate.And(c => c.CartonNum.Contains(searchModel.CartonNum));
                }



                list = _inventoryService.GetAll().AsExpandable().Where(predicate).OrderByDescending(i => i.ProductId);
            }

            return(list);
        }
Пример #7
0
        public IActionResult SearchInventory([FromBody] InventorySearchModel searchRequest)
        {
            try
            {
                var searchResults = _service.SearchInventory(searchRequest);

                return(Ok(searchResults));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, "A problem happened while handling your request."));
            }
        }
Пример #8
0
 public IHttpActionResult GetInventories(InventorySearchModel model)
 {
     try
     {
         var inventories = _inventoryService.GetInventories(model.CurrentDate);
         return(Ok(new { data = inventories }));
     }
     catch (Exception ex)
     {
         _log.ErrorFormat("Error in get all inventories. Error : {0}", ex.Message);
         _log.Error(ex);
         throw;
     }
 }
Пример #9
0
 public IHttpActionResult GetInventoryDetailByCode(long userId, long storeId, InventorySearchModel model)
 {
     try
     {
         var inventoryDetailByCode = _inventoryService.GetInventoryDetailByCode(storeId, model);
         return(Ok(new { data = inventoryDetailByCode }));
     }
     catch (Exception ex)
     {
         _log.ErrorFormat("Error in getting inventory detail by code. Error : {0}", ex.Message);
         _log.Error(ex);
         throw;
     }
 }
Пример #10
0
        public object GetInventoryDetailByCode(long storeId, InventorySearchModel model)
        {
            var inventoryModel     = new InventoryViewModel();
            var errorResponseModel = new ErrorResponseModel();
            var webUrl             = ConfigurationManager.AppSettings["WebUrl"] + "/";

            if (string.IsNullOrEmpty(model.InventoryCode))
            {
                throw _exception.ThrowException(System.Net.HttpStatusCode.BadRequest, "", "QR kod kan inte vara tomt.");
            }

            var inventoryExist = _inventoryRepository.GetInventoryDetailByCode(model.InventoryCode);

            if (inventoryExist == null)
            {
                errorResponseModel.Message = "Inventarielista saknas.";
                return(errorResponseModel);
            }
            //throw _exception.ThrowException(System.Net.HttpStatusCode.OK, "", "Inventory does not exist.");

            var isInventoryExistInStore = _inventoryRepository.IsInventoryExistInStore(inventoryExist.Id, storeId);

            if (!isInventoryExistInStore)
            {
                throw _exception.ThrowException(System.Net.HttpStatusCode.BadRequest, "", "Det finns ingen inventarielista för denna butik.");
            }

            inventoryModel.Id             = inventoryExist.Id;
            inventoryModel.BrandName      = inventoryExist.BrandName;
            inventoryModel.Name           = inventoryExist.Name;
            inventoryModel.OutPriceIncVat = inventoryExist.OutPriceIncVat;
            inventoryModel.REA            = inventoryExist.REA;
            inventoryModel.Specification  = inventoryExist.Specification;
            inventoryModel.CreatedBy      = inventoryExist.CreatedBy;
            inventoryModel.ImagePath      = !string.IsNullOrEmpty(inventoryExist.ImagePath) ? inventoryExist.ImagePath.Replace("~/", webUrl) : null;
            inventoryModel.InventoryCode  = inventoryExist.InventoryCode;
            inventoryModel.VolumeType     = inventoryExist.VolumeType;
            inventoryModel.Volume         = inventoryExist.Volume;
            inventoryModel.Supplier       = inventoryExist.Supplier;
            //TerminalId = x.TerminalId,
            inventoryModel.ModifiedDate = inventoryExist.ModifiedDate;
            return(inventoryModel);
        }
Пример #11
0
        public List <InventoryResponseModel> GetNameWiseSearchedInventories(InventorySearchModel model)
        {
            var inventoryViewModelList = new List <InventoryResponseModel>();
            var searchedInventories    = _inventoryRepository.GetNameWiseSearchedInventories(model);
            var webUrl = ConfigurationManager.AppSettings["WebUrl"] + "/";

            inventoryViewModelList = searchedInventories.ConvertAll(x => new InventoryResponseModel()
            {
                Id            = x.Id,
                BrandName     = x.BrandName,
                Name          = x.Name,
                Price         = x.OutPriceIncVat,
                REA           = x.REA,
                Description   = x.Specification,
                CreatedBy     = x.CreatedBy,
                ImagePath     = !string.IsNullOrEmpty(x.ImagePath) ? x.ImagePath.Replace("~/", webUrl) : null,
                InventoryCode = x.InventoryCode,
                //TerminalId = x.TerminalId
            });

            return(inventoryViewModelList);
        }
Пример #12
0
        public IHttpActionResult GetNameWiseSearchedInventories(InventorySearchModel model)
        {
            try
            {
                if (model == null)
                {
                    throw _exception.ThrowException(HttpStatusCode.BadRequest, "", "Ogiltig förfrågan.");
                }
                if (string.IsNullOrEmpty(model.SearchKeyWord))
                {
                    throw _exception.ThrowException(HttpStatusCode.BadRequest, "", "Invalid keyword.");
                }

                var searchedInventories = _inventoryService.GetNameWiseSearchedInventories(model);
                return(Ok(new { data = searchedInventories }));
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error in getting searched wise inventories by name. Error : {0}", ex.Message);
                _log.Error(ex);
                throw;
            }
        }
 public List <InventoryViewModel> Search(InventorySearchModel searchModel)
 {
     return(_inventoryRepository.Search(searchModel));
 }
Пример #14
0
 public List <InventorySearchResultsModel> SearchInventory(InventorySearchModel searchRequest) => _inventoryRepository.SearchInventory(searchRequest);
        public virtual ActionResult GetDetails([DataSourceRequest] DataSourceRequest request, InventorySearchModel searchModel)
        {
            var list = GetDetail(searchModel);

            return(Json(list.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }
 private void ResetSearch()
 {
     _searchModel = new InventorySearchModel();
 }