public ProductController(ICreateProduct createProduct, IGetProduct getProduct, IUpdateProduct updateProduct, IRemoveProduct removeProduct) { this.createProduct = createProduct; this.getProduct = getProduct; this.updateProduct = updateProduct; this.removeProduct = removeProduct; }
public CreateProductUseCase( IProductsRepository repository, ICreateProduct createProduct) { _repository = repository; _createProduct = createProduct; }
public ProductController(IGetProduct getProduct, ICreateProduct createProduct, IUpdateProduct updateProduct, IRemoveProduct removeProduct, IValidateProductPrice validateProductPrice, IConfirmProductPrice confirmProductPrice) { this.getProduct = getProduct; this.createProduct = createProduct; this.updateProduct = updateProduct; this.removeProduct = removeProduct; this.validateProductPrice = validateProductPrice; this.confirmProductPrice = confirmProductPrice; }
public void Setup() { _persistenceFacade = MockRepository.GenerateStub<IPersistenceFacade>(); _createProductMessage = MockRepository.GenerateStub<ICreateProductMessage>(); _createProduct = MockRepository.GenerateStub<ICreateProduct>(); _productId = Guid.NewGuid(); _persistenceFacade.Stub(scope => scope.CreateNew<ICreateProduct>()).Return(_createProduct); _createProductMessage.ProductId = _productId; _createProductMessage.Name = TestName; _createProductMessage.Category = TestCategory; _createProductMessageHandler = new CreateProductMessageHandler(_persistenceFacade); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <returns></returns> public async Task <Product> Create(ICreateProduct data) { var existCode = _context.Product.Find(f => f.CompanyId == data.CompanyId && f.IsDelete == false && f.ProductCode == data.ProductCode).FirstOrDefault(); if (existCode == null) { var product = data.Cast <Product>(); product.CreatedAt = DateTime.UtcNow; product.IsDelete = false; await _context.Product.InsertOneAsync(product); return(product); } return(new Product() { Id = "-1" }); }
public async Task <Product> Create(ICreateProduct command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } var product = new Product() { Name = command.Name, Description = command.Description, Price = command.Price.GetValueOrDefault(), DepartamentId = command.DepartamentId.GetValueOrDefault(), CreatedAt = DateTimeOffset.Now }; await productRepository.Insert(product); return(product); }
protected virtual IProductStateCreated Map(ICreateProduct c) { var stateEventId = new ProductEventId(c.ProductId, c.Version); IProductStateCreated e = NewProductStateCreated(stateEventId); e.ProductTypeId = c.ProductTypeId; e.PrimaryProductCategoryId = c.PrimaryProductCategoryId; e.ManufacturerPartyId = c.ManufacturerPartyId; e.FacilityId = c.FacilityId; e.IntroductionDate = c.IntroductionDate; e.ReleaseDate = c.ReleaseDate; e.SupportDiscontinuationDate = c.SupportDiscontinuationDate; e.SalesDiscontinuationDate = c.SalesDiscontinuationDate; e.SalesDiscWhenNotAvail = c.SalesDiscWhenNotAvail; e.InternalName = c.InternalName; e.BrandName = c.BrandName; e.Comments = c.Comments; e.ProductName = c.ProductName; e.Description = c.Description; e.PriceDetailText = c.PriceDetailText; e.SmallImageUrl = c.SmallImageUrl; e.MediumImageUrl = c.MediumImageUrl; e.LargeImageUrl = c.LargeImageUrl; e.DetailImageUrl = c.DetailImageUrl; e.OriginalImageUrl = c.OriginalImageUrl; e.DetailScreen = c.DetailScreen; e.InventoryMessage = c.InventoryMessage; e.InventoryItemTypeId = c.InventoryItemTypeId; e.RequireInventory = c.RequireInventory; e.QuantityUomId = c.QuantityUomId; e.QuantityIncluded = c.QuantityIncluded; e.PiecesIncluded = c.PiecesIncluded; e.RequireAmount = c.RequireAmount; e.FixedAmount = c.FixedAmount; e.AmountUomTypeId = c.AmountUomTypeId; e.WeightUomId = c.WeightUomId; e.ShippingWeight = c.ShippingWeight; e.ProductWeight = c.ProductWeight; e.HeightUomId = c.HeightUomId; e.ProductHeight = c.ProductHeight; e.ShippingHeight = c.ShippingHeight; e.WidthUomId = c.WidthUomId; e.ProductWidth = c.ProductWidth; e.ShippingWidth = c.ShippingWidth; e.DepthUomId = c.DepthUomId; e.ProductDepth = c.ProductDepth; e.ShippingDepth = c.ShippingDepth; e.DiameterUomId = c.DiameterUomId; e.ProductDiameter = c.ProductDiameter; e.ProductRating = c.ProductRating; e.RatingTypeEnum = c.RatingTypeEnum; e.Returnable = c.Returnable; e.Taxable = c.Taxable; e.ChargeShipping = c.ChargeShipping; e.AutoCreateKeywords = c.AutoCreateKeywords; e.IncludeInPromotions = c.IncludeInPromotions; e.IsVirtual = c.IsVirtual; e.IsVariant = c.IsVariant; e.VirtualVariantMethodEnum = c.VirtualVariantMethodEnum; e.InShippingBox = c.InShippingBox; e.DefaultShipmentBoxTypeId = c.DefaultShipmentBoxTypeId; e.IsSerialNumbered = c.IsSerialNumbered; e.IsManagedByLot = c.IsManagedByLot; e.AttributeSetId = c.AttributeSetId; e.AttributeSetInstanceId = c.AttributeSetInstanceId; e.Active = c.Active; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; foreach (ICreateGoodIdentification innerCommand in c.GoodIdentifications) { ThrowOnInconsistentCommands(c, innerCommand); IGoodIdentificationStateCreated innerEvent = MapCreate(innerCommand, c, version, _state); e.AddGoodIdentificationEvent(innerEvent); } return(e); }
public virtual void Create(ICreateProduct c) { IProductStateCreated e = Map(c); Apply(e); }
public virtual void When(ICreateProduct c) { Update(c, ar => ar.Create(c)); }
void IProductApplicationService.When(ICreateProduct c) { this.When((CreateProductDto)c); }
public async Task <ActionResult> Post([FromBody] CreateProductRequest createProductRequest, [FromServices] ICreateProduct createProduct) { try { ResponseResult <ProductEntityDomain> resultDomain = await createProduct.InvokeAsync(new ProductEntityDomain() { Description = createProductRequest.Description, BarCode = createProductRequest.BarCode, UnitMeasurementId = createProductRequest.UnitMeasurementId }); if (!resultDomain.Success) { return(BadRequest(resultDomain)); // Retorna 400 BadRequest } return(Created("Product", resultDomain)); // Retorna 201 Success Created } catch (System.Exception ex) { Debug.WriteLine(ex); return(StatusCode(500)); // Retorna 500 Internal Server Error. } }