public string Execute(RegisterProductDto dto) { List <ProductImage> images = new List <ProductImage>(); dto.Images.ForEach(p => { images.Add(new ProductImage { ImageId = p, RegisterDate = DateTime.Now.ToUnix() }); }); Product pr = new Product { Description = dto.Description, RegisterDate = DateTime.Now.ToUnix(), Title = dto.Title, UserId = dto.UserId, IsImmediate = dto.IsImmediate, IsSpecial = dto.IsSpecial, Price = dto.Price, ProductCategoryId = dto.ProductCategoryId, IsAdvertisement = dto.IsAdvertisement, Link = dto.Link, CityId = dto.CityId, IsForSale = dto.IsForSale, IsForExchange = dto.IsForExchange, ProductImage = images }; unit.Product.Add(pr); unit.Complete(); string result = Api.ToJson(new { pr.Id }); return(result); }
public async Task <IActionResult> Register([FromBody] RegisterProductDto dto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var command = new RegisterProductCommand(dto.ProductName); await _registerHandler.HandleAsync(command); return(Ok()); //Http200 }