示例#1
0
        public async Task <_ListViewModel <UnitListViewModel> > GetUnits(UnitSearchViewModel search)
        {
            var model = new _ListViewModel <UnitListViewModel>();

            try
            {
                var result = await _context.LoadStoredProc("dbo.apiUnitSearch")
                             .WithSqlParam("ownerType", search.OwnerType)
                             .WithSqlParam("inventoryID", null)
                             .WithSqlParam("resortID", null)
                             .WithSqlParam("startDate", search.CheckInStart)
                             .WithSqlParam("endDate", search.CheckInEnd)
                             .WithSqlParam("regionCode", search.RegionCode)
                             .WithSqlParam("countryCode", search.CountryCode)
                             .WithSqlParam("stateCode", search.StateCode)
                             .WithSqlParam("city", search.City)
                             .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 <apiUnitSearchResult>();

                model.Rows = result.Select(u => new UnitListViewModel()
                {
                    Description    = u.description.Replace("\n", " "),
                    ImageURL       = $"http://accessrsi.com/dannoJR/ProductImageHandler.ashx?imageid={u.imageID}",
                    LowestNetRate  = u.lowest,
                    OwnerId        = u.ownerID,
                    OriginalUnitId = u.origionalID,
                    UnitId         = u.unitID,
                    UnitName       = u.unitName,
                    Address        = new AddressViewModel()
                    {
                        City            = u.city,
                        CountryCode     = u.countryCode,
                        CountryFullName = u.countryFullName,
                        PostalCode      = u.postalCode,
                        RegionCode      = u.regionCode,
                        RegionFullName  = u.regionFullName,
                        StateCode       = u.stateCode,
                        StateFullName   = u.stateFullName,
                        StreetAddress   = u.address.Trim()
                    },
                    MaxRows = u.maxrows
                }).ToList();

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

            return(model);
        }
        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);
        }