public async Task <IActionResult> CreateSupplier(SupplierDto supplierDto) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (supplierDto.Id != 0) { return(BadRequest("The Id should be empty")); } var createdSupplier = await _supplierService.CreateAsync(supplierDto); var integrationEventData = JsonConvert.SerializeObject(new { id = createdSupplier.Id, companyName = createdSupplier.CompanyName }); PublishToMessageQueue("suppliers.add", integrationEventData); _logger.LogInformation($"Supplier added, id {createdSupplier.Id}"); //Fetch the supplier from data source return(CreatedAtRoute("GetSupplierById", new { id = createdSupplier.Id }, createdSupplier)); } catch (DbQueryResultNullException e) { return(NotFound(e.Message)); } }
public async Task <IActionResult> Create([Bind("SupplierId,CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax,HomePage")] Suppliers suppliers) { if (ModelState.IsValid) { await _supplierService.CreateAsync(suppliers); return(RedirectToAction(nameof(Index))); } return(View(suppliers)); }
public async Task <IHttpActionResult> CreateCategories([FromBody] Supplier supplier) { if (ModelState.IsValid) { var result = await _supplierService.CreateAsync(supplier); return(Ok(result)); } return(BadRequest()); }
public async Task <IActionResult> Create([FromBody] SupplierDTO supplierDto) { var createdDto = await _supplierService.CreateAsync(supplierDto); if (createdDto != null) { return(CreatedAtAction(nameof(Create), createdDto)); } return(BadRequest()); }
public async Task <ActionResult> Create(SupplierDTO supplier) { try { await _supplierService.CreateAsync(supplier); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ActionResult> Create(SupplierViewModel supplierViewModel) { try { if (ModelState.IsValid) { var supplier = Mapper.Map <Supplier>(supplierViewModel); supplier.Status = CommonStatus.Active; await _supplierService.CreateAsync(supplier, true); return(RedirectToAction("Index")); } } catch { } return(View()); }
public async Task <IActionResult> CreateSupplier(SupplierDto supplierDto) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (supplierDto.Id != 0) { return(BadRequest("The Id should be empty")); } var createdSupplier = await _supplierService.CreateAsync(supplierDto); //Fetch the supplier from data source return(CreatedAtRoute("GetSupplierById", new { id = createdSupplier.Id }, createdSupplier)); } catch (DbQueryResultNullException e) { return(NotFound(e.Message)); } }
public async Task <IActionResult> PostAsync([FromBody] SupplierForCreationDto value) { await _supplierService.CreateAsync(value); return(Ok()); }
public async Task <object> CreateSupplier([Bind("Name,ContactNo,Email,City,PostalCode,Country,Image")] Supplier supplier) { return(await _supplierService.CreateAsync(supplier)); }
public async Task <IActionResult> Create([FromBody] SupplierDTO supplierDto) { return(CreatedAtAction(nameof(Create), await _supplierService.CreateAsync(supplierDto))); }