Beispiel #1
0
 public static PriceSubmission ToContract(this Entities.PriceSubmission domain)
 => new PriceSubmission(
     id: domain.Id,
     createdByUserId: domain.CreatedByUserId,
     modifiedAt: domain.LastModified,
     gasStationId: domain.GasStationId,
     amount: domain.Amount,
     fuelType: domain.FuelType,
     ratings: domain.Ratings?.Select(x => x.ToContract()).ToArray() ?? Array.Empty <PriceSubmissionRating>());
        public async Task <long> SubmitPrice(SubmitPriceModel model)
        {
            var submission = new Entities.PriceSubmission(
                gasStationId: model.GasStationId,
                submissionDate: DateTime.UtcNow.Date,
                amount: model.Amount,
                fuelType: model.FuelType);

            auditMetadataProvider.AddAuditMetadataToNewEntity(submission);
            dbContext.PriceSubmissions.Add(submission);
            await dbContext.SaveChangesAsync();

            return(submission.Id);
        }