Ejemplo n.º 1
0
        public async Task <AuctionDetailsResponseModel> DetailsAsync(AuctionDetailsRequestModel request)
        {
            if (request.IsNotSpecified())
            {
                throw new WebApiException(HttpStatusCode.BadRequest, AuctionErrorMessages.MissingAuctionsInformation);
            }
            if (request.AuctionId.IsNotSpecified())
            {
                throw new WebApiException(HttpStatusCode.BadRequest, AuctionErrorMessages.IncorrectAuction);
            }

            return(await m_auctionsRepository.DetailsAsync(request).ConfigureAwait(true));
        }
Ejemplo n.º 2
0
        public async Task <AuctionDetailsResponseModel> DetailsAsync(AuctionDetailsRequestModel request)
        {
            // check if auction exists and only then do the full join
            bool auctionExists = await m_context.Auctions.AnyAsync(auct => auct.AuctionId == request.AuctionId).ConfigureAwait(true);

            if (auctionExists)
            {
                AuctionDetailsModel details = await(
                    from auct in m_context.Auctions
                    join aitem in m_context.AuctionItems on auct.AuctionId equals aitem.AuctionId
                    join adet in m_context.AuctionDetails on aitem.AuctionItemId equals adet.AuctionItemId
                    join acrea in m_context.AuctionCreators on auct.AuctionCreatorId equals acrea.AuctionCreatorId
                    where auct.AuctionId == request.AuctionId
                    select new AuctionDetailsModel
                {
                    Auction        = auct,
                    AuctionItem    = aitem,
                    AuctionDetails = adet,
                    AuctionCreator = acrea
                }
                    ).FirstOrDefaultAsync().ConfigureAwait(true);

                if (details.Auction.AuctionCategoryId == AuctionCategories.Item)
                {
                    return(await SetupItemAuctionDetailsAsync(details, request).ConfigureAwait(true));
                }

                if (details.Auction.AuctionCategoryId == AuctionCategories.Vehicle)
                {
                    return(await SetupVehicleAuctionDetailsAsync(details, request).ConfigureAwait(true));
                }

                if (details.Auction.AuctionCategoryId == AuctionCategories.Property)
                {
                    return(await SetupPropertyAuctionDetailsAsync(details, request).ConfigureAwait(true));
                }

                throw new WebApiException(HttpStatusCode.BadRequest, AuctionErrorMessages.MissingAuctionsInformation);
            }
            else
            {
                throw new WebApiException(HttpStatusCode.BadRequest, AuctionErrorMessages.IncorrectAuction);
            }
        }
Ejemplo n.º 3
0
        private async Task <AuctionDetailsResponseModel> SetupPropertyAuctionDetailsAsync(AuctionDetailsModel details, AuctionDetailsRequestModel request)
        {
            string auctionFormatName   = LoadAuctionFormatName(details.Auction.AuctionFormatId);
            string measurementTypeName = details.AuctionDetails.MeasurementTypeId.IsNotSpecified() ? null : LoadPropertyMeasurementTypeName(details.AuctionDetails.MeasurementTypeId.Value);
            string regionName          = details.AuctionDetails.RegionId.IsNotSpecified() ? null : LoadPropertyRegionName(details.AuctionDetails.RegionId.Value);

            Tuple <List <string>, List <AuctionDocumentModel> > auctionFiles = await LoadAuctionFilesAsync(request.AuctionId).ConfigureAwait(true);

            return(new AuctionDetailsResponseModel
            {
                AboutAuctionDetails = SetAboutAuctionDetails(details, auctionFormatName, auctionFiles),
                PropertyAuction = new PropertyAuctionDetailsModel
                {
                    PropertyCoordinates = details.AuctionDetails.Coordinates,
                    PropertyRegionName = regionName,
                    PropertyCadastreNumber = details.AuctionDetails.CadastreNumber.Value,
                    PropertyMeasurementValue = details.AuctionDetails.MeasurementValue.Value,
                    PropertyMeasurementTypeName = measurementTypeName,
                    PropertyAddress = details.AuctionDetails.Address,
                    PropertyFloorCount = details.AuctionDetails.FloorCount ?? null,
                    PropertyRoomCount = details.AuctionDetails.RoomCount ?? null
                },
                AboutAuctionCreator = SetAuctionCreatorDetails(details)
            });
        }
Ejemplo n.º 4
0
        private async Task <AuctionDetailsResponseModel> SetupItemAuctionDetailsAsync(AuctionDetailsModel details, AuctionDetailsRequestModel request)
        {
            string auctionFormatName = LoadAuctionFormatName(details.Auction.AuctionFormatId);
            string conditionName     = details.AuctionDetails.ConditionId.IsNotSpecified() ? null : LoadItemConditionName(details.AuctionDetails.ConditionId.Value);
            string companyTypeName   = details.AuctionDetails.CompanyTypeId.IsNotSpecified() ? null : LoadCompanyTypeName(details.AuctionDetails.CompanyTypeId.Value);

            Tuple <List <string>, List <AuctionDocumentModel> > auctionFiles = await LoadAuctionFilesAsync(request.AuctionId).ConfigureAwait(true);

            return(new AuctionDetailsResponseModel
            {
                AboutAuctionDetails = SetAboutAuctionDetails(details, auctionFormatName, auctionFiles),
                ItemAuction = new ItemAuctionDetailsModel
                {
                    ItemModel = details.AuctionDetails.Model,
                    ItemManufacturingYear = details.AuctionDetails.ManufacturingYear ?? null,
                    ItemConditionName = conditionName,
                    ItemStartingPrice = details.Auction.StartingPrice,
                    ItemVolume = details.AuctionDetails.Volume,
                    ItemCompanyType = companyTypeName
                },
                AboutAuctionCreator = SetAuctionCreatorDetails(details)
            });
        }
Ejemplo n.º 5
0
        private async Task <AuctionDetailsResponseModel> SetupVehicleAuctionDetailsAsync(AuctionDetailsModel details, AuctionDetailsRequestModel request)
        {
            string auctionFormatName = LoadAuctionFormatName(details.Auction.AuctionFormatId);
            string transmissionName  = details.AuctionDetails.TransmissionId.IsNotSpecified() ? null : LoadVehicleTransmissionName(details.AuctionDetails.TransmissionId.Value);
            string fuelTypeName      = details.AuctionDetails.FuelTypeId.IsNotSpecified() ? null : LoadVehicleFuelTypeName(details.AuctionDetails.FuelTypeId.Value);
            string dimensionName     = details.AuctionDetails.DimensionTypeId.IsNotSpecified() ? null : LoadVehicleDimensionTypeName(details.AuctionDetails.DimensionTypeId.Value);
            string inspectionActive  = details.AuctionDetails.InspectionActive.HasValue && details.AuctionDetails.InspectionActive.Value ? "Ir" : "Nav";


            Tuple <List <string>, List <AuctionDocumentModel> > auctionFiles = await LoadAuctionFilesAsync(request.AuctionId).ConfigureAwait(true);

            return(new AuctionDetailsResponseModel
            {
                AboutAuctionDetails = SetAboutAuctionDetails(details, auctionFormatName, auctionFiles),
                VehicleAuction = new VehicleAuctionDetailsModel
                {
                    VehicleMake = details.AuctionDetails.Make,
                    VehicleModel = details.AuctionDetails.Model,
                    VehicleManufacturingYear = details.AuctionDetails.ManufacturingYear.Value,
                    VehicleRegistrationNumber = details.AuctionDetails.RegistrationNumber,
                    VehicleIdentificationNumber = details.AuctionDetails.IdentificationNumber,
                    VehicleInspectionActive = inspectionActive,
                    VehicleTransmissionName = transmissionName,
                    VehicleFuelType = fuelTypeName,
                    VehicleDimensionValue = details.AuctionDetails.DimensionValue,
                    VehicleDimensionType = dimensionName,
                    VehicleEngineSize = details.AuctionDetails.EngineSize,
                    VehicleAxis = details.AuctionDetails.Axis
                },
                AboutAuctionCreator = SetAuctionCreatorDetails(details)
            });
        }
Ejemplo n.º 6
0
 public async Task <IActionResult> Details([FromQuery] AuctionDetailsRequestModel request)
 {
     return(Ok(await m_auctionsService.DetailsAsync(request).ConfigureAwait(true)));
 }