public async Task <ActionResult <Products> > PostProducts(Products products) { //var product1 = JsonConvert.DeserializeObject<Products>(products); _db.Products.Add(products); await _db.SaveChangesAsync(); return(CreatedAtAction("GetProduct", new { id = products.ProductId }, products)); }
public async Task DeleteImageInfo(int id) { var entity = await _context.imageInfo.FindAsync(id); if (entity == null) { } else { _context.imageInfo.Remove(entity); await _context.SaveChangesAsync(); } }
public async Task <IActionResult> PutAd(int id, AdEntity adEntity) { if (id != adEntity.Id) { } _context.Entry(adEntity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdEntityExists(id)) { } else { throw; } } return(null); }
public async Task <IActionResult> CreateFeed() { string content = string.Empty; using (Stream receiveStream = HttpContext.Request.Body) { using (StreamReader reader = new StreamReader(receiveStream)) { content = reader.ReadToEnd(); } } var entry = JsonConvert.DeserializeObject <Customer>(content, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto // A6 - Insecure Deserialization - You should instead use TypeNameHandling.None }); _context.Add(entry); await _context.SaveChangesAsync(); return(Ok()); }