Exemplo n.º 1
0
        public void GoodsDtoTransformerTest()
        {
            var domain   = new Goods(1, "1", 2, 3, 4, 5m);
            var provider = new ProviderDto(12, "name", "adress", "phone");
            var category = new GoodsCategoryDto(54, "category");
            var gclass   = new GoodsClassDto(76543, "class");
            var result   = GoodsTransformer.FromGoodsToGoodsDto(domain, provider, category, gclass);

            Assert.AreEqual(category.Title, result.GoodsCategory.Title);
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> PostGoodsCategory(GoodsCategoryDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _goodsService.CreateCategory(dto);

            return(Ok(result));
        }
Exemplo n.º 3
0
 /// <summary>
 /// The from goods to goods dto.
 /// </summary>
 /// <param name="goods">
 /// The goods.
 /// </param>
 /// <param name="provider">
 /// The provider.
 /// </param>
 /// <param name="goodsCategory">
 /// The goods category.
 /// </param>
 /// <param name="goodsClass">
 /// The goods class.
 /// </param>
 /// <returns>
 /// The <see cref="GoodsDto"/>.
 /// </returns>
 public static GoodsDto FromGoodsToGoodsDto(
     Goods goods,
     ProviderDto provider,
     GoodsCategoryDto goodsCategory,
     GoodsClassDto goodsClass)
 {
     Mapper.Reset();
     Mapper.Initialize(cfg => cfg.CreateMap <Goods, GoodsDto>()
                       .ForMember("Provider", map => map.UseValue(provider))
                       .ForMember("GoodsCategory", map => map.UseValue(goodsCategory))
                       .ForMember("GoodsClass", map => map.UseValue(goodsClass)));
     return(Mapper.Map <Goods, GoodsDto>(goods));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GoodsDto"/> class.
 /// </summary>
 /// <param name="goodsId">
 /// The goods id.
 /// </param>
 /// <param name="title">
 /// The title.
 /// </param>
 /// <param name="provider">
 /// The provider.
 /// </param>
 /// <param name="goodsCategory">
 /// The goods category.
 /// </param>
 /// <param name="goodsClass">
 /// The goods class.
 /// </param>
 /// <param name="price">
 /// The price.
 /// </param>
 public GoodsDto(
     int goodsId,
     string title,
     ProviderDto provider,
     GoodsCategoryDto goodsCategory,
     GoodsClassDto goodsClass,
     decimal price)
 {
     this.GoodsId       = goodsId;
     this.Title         = title;
     this.Provider      = provider;
     this.GoodsCategory = goodsCategory;
     this.GoodsClass    = goodsClass;
     this.Price         = price;
 }