Пример #1
0
        async Task <Report> CreateReport(Cruise cruise, SubCruiseCode subCruise)
        {
            DateTime today  = DateTime.Today;
            Report   report = new Report {
                CruiseId = cruise.Id, SubCruise = subCruise.ToString(), Date = today.Date
            };

            using (var db = DbUtil.Open())
            {
                // Don't count bookings per subcruise since technically, one booking may have more than one subcruise
                // This is not actually possible in UI today but could be in the future so here we are
                report.BookingsCreated = SubCruiseCode.None != subCruise ? 0 : await GetCreatedBookings(db, cruise, today);

                report.BookingsTotal = SubCruiseCode.None != subCruise ? 0 : await GetTotalBookings(db, cruise);

                report.CabinsTotal = await GetTotalCabins(db, cruise, subCruise);

                report.PaxTotal = await GetTotalPax(db, cruise, subCruise);

                report.CapacityTotal = await GetTotalCapacity(db, cruise, subCruise);
            }

            return(report);
        }
Пример #2
0
        public async Task <IHttpActionResult> Excel(bool onlyFullyPaid = false, string updatedSince = null, string subCruise = null)
        {
            var activeCruise = await _cruiseRepository.GetActiveAsync();

            if (null == activeCruise)
            {
                return(NotFound());
            }

            SubCruiseCode subCruiseCode    = string.IsNullOrEmpty(subCruise) ? SubCruiseCode.First : SubCruiseCode.FromString(subCruise);
            DateTime?     updatedSinceDate = string.IsNullOrEmpty(updatedSince)
                                ? null
                                : new DateTime?(DateTime.ParseExact(updatedSince, UpdatedSinceFormat, CultureInfo.InvariantCulture));

            var      exportToExcelGenerator = new ExportToExcelGenerator(_cabinRepository, _productRepository);
            Workbook workbook = await exportToExcelGenerator.ExportToWorkbookAsync(activeCruise, onlyFullyPaid, subCruiseCode.ToString(), updatedSinceDate);

            return(CreateHttpResponseMessage(workbook, subCruise));
        }