Exemplo n.º 1
0
        public ProductBl AddProduct(ProductBl model)
        {
            Product mapRes = MapTools.MapToProductModel <ProductBl, Product>(model);

            if (mapRes.JewerlyType != null)
            {
                if (mapRes.JewerlyType.Name != string.Empty)
                {
                    var jType = _Repository.GetEntity <JewerlyType>().FirstOrDefault(j => j.Name == mapRes.JewerlyType.Name);
                    if (jType != null)
                    {
                        mapRes.JewerlyType = jType;
                    }
                }
                else if (mapRes.JewerlyType_Id > 0)
                {
                    var jType = _Repository.GetEntity <JewerlyType>().FirstOrDefault(j => j.Id == mapRes.JewerlyType_Id);
                    if (jType != null)
                    {
                        mapRes.JewerlyType = jType;
                    }
                }
            }
            mapRes = _Repository.Add(mapRes);

            return(MapTools.MapToProductModel <Product, ProductBl>(mapRes));
        }
Exemplo n.º 2
0
        public ProductBl GetById(int id)
        {
            var result = _Repository.GetEntity <Product>().Include(j => j.JewerlyType).Include(s => s.Stones).FirstOrDefault(p => p.Id == id);

            return(MapTools.MapToProductModel <Product, ProductBl>(result));
        }