public ProductsController(IGetProductsCommand get, ICreateProductCommand create, IEditProductCommand edit, IGetProductCommand getOne) { _get = get; _create = create; _edit = edit; _getOne = getOne; }
public ProductsController(ICreateProductCommand createProduct, IGetProductsCommand getProducts, IDeleteProductsCommand deleteProducts, IEditProductCommand editProduct) { _createProduct = createProduct; _getProducts = getProducts; _deleteProducts = deleteProducts; _editProduct = editProduct; }
public ProductsController( IGetProductListQuery getProductListQuery, IGetProductDetailQuery getProductDetailQuery, ICreateProductCommand createProductCommand) { _getProductListQuery = getProductListQuery; _getProductDetailQuery = getProductDetailQuery; _createProductCommand = createProductCommand; }
public ProductController(IGetProductsCommand getProducts, IGetProductInsertData getProductInsertData, ICreateProductCommand createProduct, IGetProductCommand getProduct, IEditProductCommand editProduct) { _getProducts = getProducts; _getProductInsertData = getProductInsertData; _createProduct = createProduct; _getProduct = getProduct; _editProduct = editProduct; }
public ProductController(IGetProductListQuery getProductListQuery, ICreateProductViewModelFactory viewModelFactory, ICreateProductCommand createProductCommand, IDeleteProductCommand deleteProductCommand, IEditProductViewModelFactory editProductViewModelFactory, IUpdateProductCommand updateProductCommand) { this.getProductListQuery = getProductListQuery; this.viewModelFactory = viewModelFactory; this.createProductCommand = createProductCommand; this.deleteProductCommand = deleteProductCommand; this.editProductViewModelFactory = editProductViewModelFactory; this.updateProductCommand = updateProductCommand; }
public ProductsController(IGetProductsQuery IGetProductsQuery, IGetProductByIDQuery IGetProductByIDQuery, ICreateProductCommand ICreateProductCommand, IUpdateProductCommand IUpdateProductCommand, IDeleteProductCommand IDeleteProductCommand) { _IGetProductsQuery = IGetProductsQuery; _IGetProductByIDQuery = IGetProductByIDQuery; _ICreateProductCommand = ICreateProductCommand; _IUpdateProductCommand = IUpdateProductCommand; _IDeleteProductCommand = IDeleteProductCommand; }
} //Optimistic concurrency public static Product CreateProduct(ICreateProductCommand command) { var product = new Product { Code = command.Code, Name = command.Name, Description = command.Description, PhotoName = command.PhotoName, BlobName = command.BlobName, Price = command.Price, LastUpdated = DateTime.Now }; product.ValidateModel(); return(product); }
/// <summary> /// Create product /// </summary> /// <param name="productCommand"></param> /// <returns></returns> public async Task <CreateProductDto> CreateProduct(ICreateProductCommand productCommand) { CreateProductDto response = null; try { var product = Product.CreateProduct(productCommand); if (product == null) { return(await Task.Run(() => response = new CreateProductDto(null))); } if (product.Errors.Count > 0) { return(await Task.Run(() => response = new CreateProductDto(product))); } var result = _repository.Product.GetByCondition(x => x.Code.Equals(product.Code) || x.Name.Equals(product.Name)); if (result?.Count() == 0) { _repository.Product.CreateProduct(product); _repository.Save(); response = new CreateProductDto(product); } else { response = new CreateProductDto(product) { Errors = new List <Error> { new Error("Id", "Product already exists") } }; } return(await Task.Run(() => response)); } catch (Exception e) { Console.WriteLine(e); response = CreateProductDto.PrepareExceptionResponse(null, "ERROR_SYSTEM"); return(await Task.Run(() => response)); } }
public IActionResult Post([FromBody] ProductDto dto, [FromServices] ICreateProductCommand command) { executor.ExecuteCommand(command, dto); return(NoContent()); }
public void Post([FromForm] ProductDto dto, [FromServices] ICreateProductCommand command) { executor.ExecuteCommand(command, dto); }