コード例 #1
0
        public async Task <IsComposed> InsertAsync(IsComposed entity)
        {
            var stmt = @"insert into isComposed (idDish, idService) values (@idDish, @idService)";
            int i    = await _session.Connection.ExecuteAsync(stmt, entity, _session.Transaction);

            return(await GetAsync(i));
        }
コード例 #2
0
        public async Task <IsComposed> CreateIsComposed(IsComposed isComposed)
        {
            _db.BeginTransaction();
            IIsComposedRepository _isComposed   = _db.GetRepository <IIsComposedRepository>();
            IsComposed            newIsComposed = await _isComposed.InsertAsync(isComposed);

            _db.Commit();
            return(newIsComposed);
        }
コード例 #3
0
        public async Task <IActionResult> CreateIsComposed([FromBody] IsComposed isComposed)
        {
            //Ajout de IsComposed avec la BLL server
            IsComposed newIsComposed = await _restaurantService.CreateIsComposed(isComposed);

            if (newIsComposed != null)
            {
                return(CreatedAtAction(nameof(CreateIsComposed), newIsComposed));
            }
            else
            {
                //Retourner code 400 Bad Request
                return(BadRequest());
            }
        }
コード例 #4
0
        /// <summary>
        /// Créer la table d'association "IsComposed" associant les services et les plats :
        /// </summary>
        /// <param name="isComposed"></param>
        /// <returns>Task</returns>
        public async Task <IsComposed> CreateIsComposed(IsComposed isComposed)
        {
            var response = await _httpClient.PostAsync("isComposed",
                                                       new StringContent(
                                                           JsonSerializer.Serialize(isComposed), Encoding.UTF8, "application/json"));

            if (response.IsSuccessStatusCode)
            {
                var stream = await response.Content.ReadAsStreamAsync();

                IsComposed newIsComposed = await JsonSerializer.DeserializeAsync <IsComposed>(stream, new JsonSerializerOptions()
                {
                    PropertyNameCaseInsensitive = true
                });

                Trace.WriteLine("Création d'un IsComposed");
                return(newIsComposed);
            }
            else
            {
                Trace.WriteLine("Problème dans la création d'un IsComposed");
                return(null);
            }
        }
コード例 #5
0
 public Task UpdateAsync(IsComposed entity)
 {
     throw new NotImplementedException();
 }