Exemplo n.º 1
0
        public async Task AddRating(long id, RatePriceSubmissionModel model)
        {
            var priceSubmission = await dbContext.PriceSubmissions.GetAsync(id);

            var rating = new Entities.PriceSubmissionRating(
                priceSubmissionId: priceSubmission.Id,
                userId: userContext.Id.Value,
                value: model.Value,
                submitedAt: DateTime.Now);

            await dbContext.UpsertAsync(new[] { rating }, options => options
                                        .SelectValues(x => new object[]
            {
                (int)x.Value,
                x.PriceSubmissionId,
                $"'{x.SubmitedAt.ToString(CultureInfo.InvariantCulture)}'",
                x.UserId
            })
                                        .WithColumns(
                                            x => x.Value,
                                            x => x.PriceSubmissionId,
                                            x => x.SubmitedAt,
                                            x => x.UserId
                                            )
                                        .ConflictOn(
                                            x => x.UserId,
                                            x => x.PriceSubmissionId
                                            ));
        }
Exemplo n.º 2
0
 public static PriceSubmissionRating ToContract(this Entities.PriceSubmissionRating domain)
 => new PriceSubmissionRating
 {
     Value  = domain.Value,
     UserId = domain.UserId
 };