//[HttpGet("{id}")] public IActionResult Create(int id) { // Yeni bir CreateBazaarListItem sınıfını ayağa kaldır CreateBazaarListItem model = new CreateBazaarListItem(); // model.BazaarListId'yi parametreden gelen id'ye eşitle model.BazaarListId = id; return(View(model)); }
public async Task <BazaarListItem> CreateAsync(CreateBazaarListItem input) { var item = BazaarListItem.Create(input.Name, input.BazaarListId, input.CreatorUserId); await _context.BazaarListItems.AddAsync(item); await _context.SaveChangesAsync(); return(item); }
public async Task <IActionResult> CreateAsync(int id, CreateBazaarListItem model) { if (ModelState.IsValid) { // CreateBazaarListItem model // model.CreatorUserId atamasını yap model.CreatorUserId = User.FindFirst(ClaimTypes.NameIdentifier).Value; // oluşan model servis katmanina gonder var createdItem = await _bazaarListItemService.CreateAsync(model); return(RedirectToAction("Index", new { id = model.BazaarListId })); } return(View(model)); }
private async Task CreateFirst() { var count = await inMemoryDbContext.BazaarListItems.CountAsync(); if (count > 1) { await CleanAll(); await CreateFirst(); } if (count == 0) { // parametresiyle fake data olustur CreateBazaarListItem fakeInput = new CreateBazaarListItem { BazaarListId = bazaarListId, CreatorUserId = Guid.NewGuid().ToString(), Name = "Domates_Test" }; // servisi calistir await service.CreateAsync(fakeInput); } }
public async Task <BazaarListItem> CreateAsync(CreateBazaarListItem input) { return(await _bazaarListItemService.CreateAsync(input)); }