Exemplo n.º 1
0
        public static Product Map(this ProductDataDTO dto) =>
        (dto != null) ? new Product
        {
            Name         = dto.Name,
            Description  = dto.Description,
            IsActive     = dto.IsActive ?? true,
            OfferEndDate = dto.OfferEndDate,
            OfferPrice   = dto.OfferPrice,
            PictureUrl   = dto.PictureUrl,
            Price        = dto.Price ?? dto.Price.Value,
            Special      = dto.Special ?? false,
            DateCreated  = DateTime.Now
        }

             : null;
Exemplo n.º 2
0
        /// <summary>
        /// method to map the product service model to DTO model manual
        /// </summary>
        /// <param name="rootobject"></param>
        /// <returns></returns>
        public ObservableCollection <ProductDataDTO> MapProductserviceModelToDTOModel(ProductModel productrootobject)
        {
            ObservableCollection <ProductDataDTO> ProductCollection = new ObservableCollection <ProductDataDTO>();
            ProductDataDTO _product;

            for (int i = 0; i < productrootobject.products.Count; i++)
            {
                _product               = new ProductDataDTO();
                _product.uid           = productrootobject.products[i].uid;
                _product.name          = productrootobject.products[i].name;
                _product.selling_price = productrootobject.products[i].selling_price;
                _product.stock_price   = productrootobject.products[i].stock_price;
                ProductCollection.Add(_product);
            }
            return(ProductCollection);
        }
Exemplo n.º 3
0
        public async Task <ActionResult <Product> > Create(ProductDataDTO data)
        {
            if (!string.IsNullOrEmpty(data.ImageData))
            {
                var imageResult = await MediaHelper.UploadMediaAsync("product", data.ImageData);

                if (imageResult != null)
                {
                    data.PictureUrl = imageResult.Data.Path;
                }
            }

            var result = await this.Mediator.Send(new CreateProductCommand
            {
                Data = data
            });

            return(ResponseHelper.ResponseOutcome <Product>(result, this));
        }