public async Task <ActionResult <Guid> > Create(Product product, CancellationToken ct = default) { product.AccountId = _userContext.AccountId; var id = await _productsService.CreateAsync(_userContext.UserId, product, ct); return(Created(nameof(Get), id)); }
public async Task <IActionResult> CreateProduct([FromBody] ProductCreateForm form) { var createResult = await _products.CreateAsync(form); return(CreatedAtRoute( nameof(GetProduct), new { id = createResult.Id }, createResult)); }
public async Task <ActionResult <Product> > Create(Product product) { var result = await productsService.CreateAsync(product); if (result.IsSuccess) { return(Ok()); } return(BadRequest(result.ErrorMessage)); }
public async Task <IActionResult> Create(ProductViewModel viewModel) { if (ModelState.IsValid) { var dto = _productMapper.MapToDto(viewModel); await _productsService.CreateAsync(dto); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(await _categoriesService.GetAllAsync(), "CategoryId", "CategoryName", viewModel.CategoryId); ViewData["SupplierId"] = new SelectList(await _suppliersService.GetAllAsync(), "SupplierId", "CompanyName", viewModel.SupplierId); return(View(viewModel)); }
public async Task <IActionResult> OnPost() { if (!ModelState.IsValid) { return(Page()); } var result = await productsService.CreateAsync(Product); if (!result.IsSuccess) { return(Page()); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> Post([FromForm] AddAccesoarModel input) { var accessory = new Accessory() { Brand = input.Brand, Model = input.Model, Price = input.Price, Description = input.Description }; var result = await productsService.CreateAsync(accessory, input.File); if (result == null) { return(Json(new { })); } return(Json(result)); }
public async Task <IActionResult> Post([FromForm] AddParagliderModel input) { var paraglider = new Paraglider() { Brand = input.Brand, Model = input.Model, Description = input.Description, Price = input.Price, Sizes = input.Sizes, }; var result = await productsService.CreateAsync(paraglider, input.File); if (result == null) { return(Json(new { })); } return(Json(result)); }
public async Task <IActionResult> Post([FromForm] AddHarnessModel input) { var harness = new Harness() { Brand = input.Brand, Description = input.Description, Model = input.Model, Sizes = input.Sizes, Price = input.Price }; var result = await productService.CreateAsync(harness, input.File); if (result == null) { return(Json(new { })); } return(Json(result)); }
public async Task Post([FromBody] ProductCreateModel value) { await _service.CreateAsync(value); }
public async Task <ActionResult <ProductDto> > Post([FromBody] ProductDto product) { var productCreated = await _productsService.CreateAsync(product); return(CreatedAtAction(nameof(Get), new { id = product.ProductId }, product)); }
public async Task HandleAsync(CreateProduct command) => await _productsService.CreateAsync(command.Id, command.Name, command.Description, command.Vendor, command.Price);