public async Task <IActionResult> Create([Bind("Id,Name,Descripton")] Item item) { if (ModelState.IsValid) { _context.Add(item); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(item)); }
public async Task <IActionResult> Create([Bind("Id,Salesname,Buyer,Quantity")] Sales sales) { if (ModelState.IsValid) { _context.Add(sales); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sales)); }
protected async Task <ItemApiModel> SaveItemAsync(Item itemToSave) { using IServiceScope scope = Server.CreateScope(); ItemsDbContext itemsDbContext = scope.ServiceProvider.GetRequiredService <ItemsDbContext>(); itemsDbContext.Add(itemToSave); await itemsDbContext.SaveChangesAsync(); return(new ItemApiModel { Id = itemToSave.Id, IsDone = itemToSave.IsDone, Text = itemToSave.Text, Priority = itemToSave.Priority }); }
public void Create(T aggregateRoot) => dbContext.Add(aggregateRoot);