public CreateProductOut CreateProduct(CreateProductIn input) { CreateProductOut response = new CreateProductOut() { ResponseCode = Entities.Client.General.ResponseCode.Error }; using (IDbConnection connection = new SqlConnection(connectionString)) { connection.Open(); DynamicParameters param = new DynamicParameters(); param.Add("@ProductId", input.product.ProductId); param.Add("@Name", input.product.Name); param.Add("@Quantity", input.product.Quantity); param.Add("@Price", input.product.Price); param.Add("@Operation", 1); param.Add("@RESULT", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue); var data = connection.Execute("SP_Crud_Product", param, commandType: CommandType.StoredProcedure); if (param.Get <int>("@RESULT") == 1) { response.ResponseCode = Entities.Client.General.ResponseCode.Success; } } return(response); }
public async Task <CreatProductOut> CreateAsync(CreateProductIn @in) { @in.NotNull(nameof(@in)); var product = _mapper.Map <Product>(@in); var result = await _productRepository.InsertAsync(product); _logger.LogInformation($"Create product {result.Name} success"); return(_mapper.Map <CreatProductOut>(result)); }
public IHttpActionResult CreateProduct(CreateProductIn input) { var response = Product.CreateProduct(input); return(Ok(response)); }
public CreateProductOut CreateProduct(CreateProductIn input) { return(productDA.CreateProduct(input)); }