Exemple #1
0
        private async Task <int> PostReviewAsync(Review reviewToSave, Guid?userId = null)
        {
            if (reviewToSave.Guid == new Guid())
            {
                reviewToSave.Guid = Guid.NewGuid();
            }
            if (userId != null)
            {
                reviewToSave.User = context.Users.SingleOrDefault(u => u.Guid == userId);
            }

            reviewToSave.Records?.ForEach(e => e.Guid = e.Guid == new Guid() ? Guid.NewGuid() : e.Guid);
            await context.Reviews.AddAsync(reviewToSave);

            return(await context.SaveChangesAsync());
        }
        private async Task <int> PostUserAsync(User userToSave)
        {
            await context.Users.AddAsync(userToSave);

            return(await context.SaveChangesAsync());
        }