示例#1
0
        public ActionResult _SearchInventory(InventorySearchViewModel model)
        {
            if (model.ToDate.HasValue)
            {
                model.ToDate.Value.AddDays(1).AddMilliseconds(-1);
            }
            List <InventoryInfoViewModel> list = new List <InventoryInfoViewModel>();

            list = (from p in _context.InventoryDetailModel
                    join ivm in _context.InventoryMasterModel on p.InventoryMasterId equals ivm.InventoryMasterId
                    join ivt in _context.InventoryTypeModel on ivm.InventoryTypeId equals ivt.InventoryTypeId
                    join pd in _context.ProductModel on p.ProductId equals pd.ProductId
                    join e in _context.EmployeeModel on ivm.CreatedEmployeeId equals e.EmployeeId
                    //join ip in _context.ImportMasterModel on ivm.BusinessId equals ip.importmasterid
                    //join or in _context.OrderMasterModel on ivm.BusinessIdequals or.orderid
                    where
                    //(model.WarehouseId == null || ip.WarehouseId == model.WarehouseId || or.WarehouseId == model.WarehouseId) &&
                    (model.WarehouseId == null || ivm.WarehouseModelId == model.WarehouseId) &&
                    (model.InventoryMasterId == null || ivm.InventoryMasterId == model.InventoryMasterId) &&
                    (model.EmployeeId == null || e.EmployeeId == model.EmployeeId) &&
                    (model.ProductId == null || pd.ProductId == model.ProductId) &&
                    (model.FromDate == null || ivm.CreatedDate.Value.CompareTo(model.FromDate.Value) >= 0) &&
                    (model.ToDate == null || ivm.CreatedDate.Value.CompareTo(model.ToDate.Value) <= 0)
                    select new InventoryInfoViewModel()
            {
                InventoryDetailId = p.InventoryDetailId,
                InventoryTypeCode = ivt.InventoryTypeCode,
                EmployeeName = e.FullName,
                CreatedDate = ivm.CreatedDate,
                ProductName = pd.ProductName,
                BeginInventoryQty = p.BeginInventoryQty,
                COGS = p.COGS,
                Price = p.Price,
                ImportQty = p.ImportQty,
                ExportQty = p.ExportQty,
                UnitCOGS = p.UnitCOGS,
                UnitPrice = p.UnitPrice,
                EndInventoryQty = p.EndInventoryQty,
                ActionUrl = ivm.ActionUrl,
                BusinessId = ivm.BusinessId,
                InventoryCode = ivm.InventoryCode,
                ProductCode = pd.ProductCode,
                Specifications = pd.Specifications
            }).Distinct()
                   .OrderByDescending(p => p.InventoryDetailId)
                   .ToList();

            return(PartialView(list));
        }
        public async Task <_ListViewModel <InventoryListViewModel> > GetInventory(InventorySearchViewModel search)
        {
            var model = new _ListViewModel <InventoryListViewModel>();

            try
            {
                var result = await _legacyContext.LoadStoredProc("dbo.apiInventorySearch")
                             .WithSqlParam("resortID", search.UnitId)
                             .WithSqlParam("startDate", search.CheckInStart)
                             .WithSqlParam("endDate", search.CheckInEnd)
                             .WithSqlParam("bedroomSize", (search.BedroomSize.HasValue) ? (int?)search.BedroomSize.Value : null)
                             .WithSqlParam("inventoryType", (search.InventoryType.HasValue) ? search.InventoryType.Value.ToString() : null)
                             .WithSqlParam("maximumRSICost", search.MaximumNetRate)
                             .WithSqlParam("startRowIndex", search.StartRowIndex)
                             .WithSqlParam("numberOfRows", search.NumberOfRows)
                             .WithSqlParam("orderBy", search.SortColumn)
                             .WithSqlParam("orderDirection", search.SortDirection)
                             .ExecuteStoredProcAsync <apiInventorySearchResult>();

                model.Rows = result.Select(i => new InventoryListViewModel()
                {
                    CheckInDate   = i.checkInDate,
                    CheckOutDate  = i.checkOutDate,
                    InventoryId   = i.inventoryID,
                    InventoryType = i.inventoryType,
                    KitchenType   = i.kitchenType,
                    MaxGuests     = i.maxGuests,
                    NetRate       = (string.IsNullOrEmpty(i.netRate)) ? 0 : Decimal.Parse(i.netRate),
                    Privacy       = i.adults,
                    Quantity      = i.quantity,
                    BedroomSize   = ((BedroomSize)Enum.Parse(typeof(BedroomSize), i.unitSize)).ToString().SplitCamelCase(),
                    UnitId        = i.unitID,
                    MaxRows       = i.maxrows //,
                                              //OwnerId = i.owner
                }).ToList();

                model.TotalCount = (model.RowCount > 0) ? model.Rows[0].MaxRows : 0;
                model.Message    = "Success";
            }
            catch (Exception ex)
            {
                model.Message = $"Error: {ex.Message}";
            }

            return(model);
        }
示例#3
0
        public async Task <_ListViewModel <InventoryListViewModel> > Get(int unitId, DateTime?checkInStart, DateTime?checkInEnd,
                                                                         BedroomSize?bedroomSize, InventoryType?inventoryType, decimal?maximumNetRate,
                                                                         int?startRowIndex = 1, int?numberOfRows = 10, string orderBy = "price", string orderDirection = "asc")
        {
            var model = new _ListViewModel <InventoryListViewModel>();

            try
            {
                var search = new InventorySearchViewModel()
                {
                    UnitId         = unitId,
                    CheckInStart   = checkInStart,
                    CheckInEnd     = checkInEnd,
                    BedroomSize    = bedroomSize,
                    InventoryType  = inventoryType,
                    MaximumNetRate = maximumNetRate,
                    StartRowIndex  = startRowIndex,
                    NumberOfRows   = numberOfRows,
                    SortColumn     = orderBy,
                    SortDirection  = orderDirection,
                    ExactMatch     = true,
                };

                model = await _context.GetInventory(search);
            }
            catch (Exception ex)
            {
                if (model == null)
                {
                    model = new _ListViewModel <InventoryListViewModel>();
                }

                if (model.Message.Length > 0)
                {
                    model.Message += " | ";
                }
                else
                {
                    model.Message = "Error: ";
                }

                model.Message += ex.Message;
            }

            return(model);
        }