protected ProductSuggestion(Guid id, string title, string productImage, string description, Guid personId, ProductSuggestionGroup productSuggestionGroup) { Id = id; Title = title; ProductImage = productImage; ProductSuggestionStatus = ProductSuggestionStatus.Pending; CreationTime = DateTime.Now; Description = description; PersonId = personId; ProductSuggestionGroup = productSuggestionGroup; }
public async Task <CreateShopProductSuggestionCommandResponse> Handle(CreateShopProductSuggestionCommand command) { var person = await _personRepository.AsQuery().OfType <Shop>().SingleOrDefaultAsync(p => p.UserId == command.UserId); if (person == null) { throw new DomainException("شخص یافت نشد"); } var categoryRoot = await _categoryRootRepository.FindAsync(command.CategoryRootId); if (categoryRoot == null) { throw new DomainException("دسته بندی ریشه یافت نشد"); } Guid categoryId = Guid.Empty; string categoryName = ""; var category = await _categoryRepository.FindAsync(command.CategoryId); if (category != null) { categoryId = category.Id; categoryName = category.Name; } Guid brandId = Guid.Empty; string brandName = ""; var brand = await _brandRepository.FindAsync(command.BrandId); if (brand != null) { brandName = brand.Name; brandId = brand.Id; } var productSuggestionGroup = new ProductSuggestionGroup(categoryRoot.Id, categoryRoot.Name, categoryId, categoryName, brandId, brandName); var productSuggestion = new ShopProductSuggestion(Guid.NewGuid(), command.Title, command.ProductImage, command.Description, person.Id, productSuggestionGroup); _repository.Add(productSuggestion); return(new CreateShopProductSuggestionCommandResponse()); }
public ShopProductSuggestion(Guid id, string title, string productImage, string description, Guid personId, ProductSuggestionGroup productSuggestionGroup) : base(id, title, productImage, description, personId, productSuggestionGroup) { }