/// <summary>
        /// Deep load all ProductProductPhoto children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.ProductProductPhotoProvider.GetPaged(tm, 0, 10, out count);

                DataRepository.ProductProductPhotoProvider.DeepLoading += new EntityProviderBaseCore <ProductProductPhoto, ProductProductPhotoKey> .DeepLoadingEventHandler(
                    delegate(object sender, DeepSessionEventArgs e)
                {
                    if (e.DeepSession.Count > 3)
                    {
                        e.Cancel = true;
                    }
                }
                    );

                if (mockCollection.Count > 0)
                {
                    DataRepository.ProductProductPhotoProvider.DeepLoad(tm, mockCollection[0]);
                    System.Console.WriteLine("ProductProductPhoto instance correctly deep loaded at 1 level.");

                    mockCollection.Add(mock);
                    // DataRepository.ProductProductPhotoProvider.DeepSave(tm, mockCollection);
                }

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        ///<summary>
        ///  Returns a Typed ProductProductPhoto Entity with mock values.
        ///</summary>
        static public ProductProductPhoto CreateMockInstance_Generated(TransactionManager tm)
        {
            ProductProductPhoto mock = new ProductProductPhoto();

            mock.Primary      = TestUtility.Instance.RandomBoolean();
            mock.ModifiedDate = TestUtility.Instance.RandomDateTime();

            //OneToOneRelationship
            Product mockProductByProductId = ProductTest.CreateMockInstance(tm);

            DataRepository.ProductProvider.Insert(tm, mockProductByProductId);
            mock.ProductId = mockProductByProductId.ProductId;
            //OneToOneRelationship
            ProductPhoto mockProductPhotoByProductPhotoId = ProductPhotoTest.CreateMockInstance(tm);

            DataRepository.ProductPhotoProvider.Insert(tm, mockProductPhotoByProductPhotoId);
            mock.ProductPhotoId = mockProductPhotoByProductPhotoId.ProductPhotoId;

            // create a temporary collection and add the item to it
            TList <ProductProductPhoto> tempMockCollection = new TList <ProductProductPhoto>();

            tempMockCollection.Add(mock);
            tempMockCollection.Remove(mock);


            return((ProductProductPhoto)mock);
        }
Exemplo n.º 3
0
        ///<summary>
        ///  Update the Typed ProductProductPhoto Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, ProductProductPhoto mock)
        {
            ProductProductPhotoTest.UpdateMockInstance_Generated(tm, mock);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);
        }
        /// <summary>
        /// Test methods exposed by the EntityHelper class.
        /// </summary>
        private void Step_20_TestEntityHelper_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);

                ProductProductPhoto entity = mock.Copy() as ProductProductPhoto;
                entity = (ProductProductPhoto)mock.Clone();
                Assert.IsTrue(ProductProductPhoto.ValueEquals(entity, mock), "Clone is not working");
            }
        }
Exemplo n.º 5
0
        public IQueryable <Product> GetFeaturedProducts()
        {
            IList <Product>     products = new List <Product>();
            Product             product;
            ProductPhoto        prodPhoto;
            ProductProductPhoto prodProdPhoto;

            product      = new Product();
            product.Name = "Road-150 Red, 48";
            prodPhoto    = new ProductPhoto();
            prodPhoto.LargePhotoFileName = "~/Content/Images/SampleCycles/cycle1.gif";
            prodProdPhoto = new ProductProductPhoto()
            {
                ProductPhoto = prodPhoto
            };
            product.ProductProductPhotoes.Add(prodProdPhoto);
            products.Add(product);

            product      = new Product();
            product.Name = "Touring-2000 Blue, 60";
            prodPhoto    = new ProductPhoto();
            prodPhoto.LargePhotoFileName = "~/Content/Images/SampleCycles/cycle2.gif";
            prodProdPhoto = new ProductProductPhoto()
            {
                ProductPhoto = prodPhoto
            };
            product.ProductProductPhotoes.Add(prodProdPhoto);
            products.Add(product);

            product      = new Product();
            product.Name = "Mountain-100 Black, 42";
            prodPhoto    = new ProductPhoto();
            prodPhoto.LargePhotoFileName = "~/Content/Images/SampleCycles/cycle3.gif";
            prodProdPhoto = new ProductProductPhoto()
            {
                ProductPhoto = prodPhoto
            };
            product.ProductProductPhotoes.Add(prodProdPhoto);
            products.Add(product);

            product      = new Product();
            product.Name = "Road-350-W Yellow, 44";
            prodPhoto    = new ProductPhoto();
            prodPhoto.LargePhotoFileName = "~/Content/Images/SampleCycles/cycle4.jpg";
            prodProdPhoto = new ProductProductPhoto()
            {
                ProductPhoto = prodPhoto
            };
            product.ProductProductPhotoes.Add(prodProdPhoto);
            products.Add(product);


            return(products.AsQueryable <Product>());
        }
Exemplo n.º 6
0
        ///<summary>
        ///  Returns a Typed ProductProductPhoto Entity with mock values.
        ///</summary>
        static public ProductProductPhoto CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            ProductProductPhoto mock = ProductProductPhotoTest.CreateMockInstance_Generated(tm);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);

            // return the modified object
            return(mock);
        }
        // PUT api/awbuildversion/5
        public void Put(ProductProductPhoto value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                    adventureWorks_BC.ProductProductPhotoDelete(value);
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                    adventureWorks_BC.ProductProductPhotoUpdate(value);
            }
        }
Exemplo n.º 8
0
        public virtual BOProductProductPhoto MapEFToBO(
            ProductProductPhoto ef)
        {
            var bo = new BOProductProductPhoto();

            bo.SetProperties(
                ef.ProductID,
                ef.ModifiedDate,
                ef.Primary,
                ef.ProductPhotoID);
            return(bo);
        }
Exemplo n.º 9
0
        public virtual ProductProductPhoto MapBOToEF(
            BOProductProductPhoto bo)
        {
            ProductProductPhoto efProductProductPhoto = new ProductProductPhoto();

            efProductProductPhoto.SetProperties(
                bo.ModifiedDate,
                bo.Primary,
                bo.ProductID,
                bo.ProductPhotoID);
            return(efProductProductPhoto);
        }
        /// <summary>
        /// Serialize the mock ProductProductPhoto entity into a temporary file.
        /// </summary>
        private void Step_06_SerializeEntity_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_ProductProductPhoto.xml");

                EntityHelper.SerializeXml(mock, fileName);
                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock not found");

                System.Console.WriteLine("mock correctly serialized to a temporary file.");
            }
        }
        public void MapEFToBOList()
        {
            var mapper = new DALProductProductPhotoMapper();
            ProductProductPhoto entity = new ProductProductPhoto();

            entity.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), true, 1, 1);

            List <BOProductProductPhoto> response = mapper.MapEFToBO(new List <ProductProductPhoto>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
        public void MapEFToBO()
        {
            var mapper = new DALProductProductPhotoMapper();
            ProductProductPhoto entity = new ProductProductPhoto();

            entity.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), true, 1, 1);

            BOProductProductPhoto response = mapper.MapEFToBO(entity);

            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Primary.Should().Be(true);
            response.ProductID.Should().Be(1);
            response.ProductPhotoID.Should().Be(1);
        }
 public bool ProductProductPhotoDelete(ProductProductPhoto productproductphoto)
 {
     return(Execute <bool>(dal =>
     {
         ProductProductPhoto productproductphotoDelete = dal.ProductProductPhoto.Where(x => x.ProductID == productproductphoto.ProductID).FirstOrDefault();
         if (productproductphotoDelete != null)
         {
             dal.ProductProductPhoto.DeleteOnSubmit(productproductphotoDelete);
             dal.SubmitChanges();
             return true;
         }
         return false;
     }));
 }
        public void MapBOToEF()
        {
            var mapper = new DALProductProductPhotoMapper();
            var bo     = new BOProductProductPhoto();

            bo.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), true, 1);

            ProductProductPhoto response = mapper.MapBOToEF(bo);

            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Primary.Should().Be(true);
            response.ProductID.Should().Be(1);
            response.ProductPhotoID.Should().Be(1);
        }
        // PUT api/awbuildversion/5
        public void Put(ProductProductPhoto value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                {
                    adventureWorks_BC.ProductProductPhotoDelete(value);
                }
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                {
                    adventureWorks_BC.ProductProductPhotoUpdate(value);
                }
            }
        }
        /// <summary>
        /// Serialize a ProductProductPhoto collection into a temporary file.
        /// </summary>
        private void Step_08_SerializeCollection_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_ProductProductPhotoCollection.xml");

                mock = CreateMockInstance(tm);
                TList <ProductProductPhoto> mockCollection = new TList <ProductProductPhoto>();
                mockCollection.Add(mock);

                EntityHelper.SerializeXml(mockCollection, fileName);

                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
                System.Console.WriteLine("TList<ProductProductPhoto> correctly serialized to a temporary file.");
            }
        }
        ///<summary>
        ///  Update the Typed ProductProductPhoto Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance_Generated(TransactionManager tm, ProductProductPhoto mock)
        {
            mock.Primary      = TestUtility.Instance.RandomBoolean();
            mock.ModifiedDate = TestUtility.Instance.RandomDateTime();

            //OneToOneRelationship
            Product mockProductByProductId = ProductTest.CreateMockInstance(tm);

            DataRepository.ProductProvider.Insert(tm, mockProductByProductId);
            mock.ProductId = mockProductByProductId.ProductId;

            //OneToOneRelationship
            ProductPhoto mockProductPhotoByProductPhotoId = ProductPhotoTest.CreateMockInstance(tm);

            DataRepository.ProductPhotoProvider.Insert(tm, mockProductPhotoByProductPhotoId);
            mock.ProductPhotoId = mockProductPhotoByProductPhotoId.ProductPhotoId;
        }
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IProductProductPhotoRepository>();
            var record = new ProductProductPhoto();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new ProductProductPhotoService(mock.LoggerMock.Object,
                                                         mock.RepositoryMock.Object,
                                                         mock.ModelValidatorMockFactory.ProductProductPhotoModelValidatorMock.Object,
                                                         mock.BOLMapperMockFactory.BOLProductProductPhotoMapperMock,
                                                         mock.DALMapperMockFactory.DALProductProductPhotoMapperMock);

            ApiProductProductPhotoResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Exemplo n.º 19
0
        public ProductDTO GetProduct(int id)
        {
            var product = unitOfWork.Products.Get(id);

            var productInventory = unitOfWork.ProductInventory.GetList().GroupBy(p => p.ProductID)
                                   .Select(g => new
            {
                ProductID = g.Key,
                Quantity  = g.Sum(p => p.Quantity)
            });


            if (product == null)
            {
                throw new ValidationException("Product doesn't find", "");
            }

            string description;

            if (product.ProductModel != null)
            {
                var descCultureEN = product.ProductModel.ProductModelProductDescriptionCultures.First(i => i.CultureID.Contains("en"));
                description = unitOfWork.ProductDescription.Get(descCultureEN.ProductDescriptionID).Description;
            }
            else
            {
                description = "No description";
            }

            ProductProductPhoto photo = product.ProductProductPhotoes.First();
            string photoFileName      = photo.ProductPhoto.LargePhotoFileName;


            return(new ProductDTO
            {
                ProductID = product.ProductID,
                Name = product.Name,
                Color = product.Color,
                Price = product.ListPrice,
                Size = product.Size,
                SizeUnitMeasureCode = product.SizeUnitMeasureCode,
                Description = description,
                Photo = photoFileName,
                Quantity = product.ProductInventories.Where(i => i.ProductID == product.ProductID).Sum(p => p.Quantity)
            });
        }
        public bool ProductProductPhotoUpdate(ProductProductPhoto productproductphoto)
        {
            return(Execute <bool>(dal =>
            {
                ProductProductPhoto productproductphotoUpdate = dal.ProductProductPhoto.Where(x => x.ProductID == productproductphoto.ProductID).FirstOrDefault();
                if (productproductphotoUpdate != null)
                {
                    productproductphotoUpdate.ProductID = productproductphoto.ProductID;
                    productproductphotoUpdate.ProductPhotoID = productproductphoto.ProductPhotoID;
                    productproductphotoUpdate.Primary = productproductphoto.Primary;
                    productproductphotoUpdate.ModifiedDate = productproductphoto.ModifiedDate;

                    dal.SubmitChanges();
                    return true;
                }
                return false;
            }));
        }
        /// <summary>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                ProductProductPhoto mock = CreateMockInstance(tm);
                bool result = DataRepository.ProductProductPhotoProvider.Insert(tm, mock);

                Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed");

                ProductProductPhotoQuery query = new ProductProductPhotoQuery();

                query.AppendEquals(ProductProductPhotoColumn.ProductId, mock.ProductId.ToString());
                query.AppendEquals(ProductProductPhotoColumn.ProductPhotoId, mock.ProductPhotoId.ToString());
                query.AppendEquals(ProductProductPhotoColumn.Primary, mock.Primary.ToString());
                query.AppendEquals(ProductProductPhotoColumn.ModifiedDate, mock.ModifiedDate.ToString());

                TList <ProductProductPhoto> results = DataRepository.ProductProductPhotoProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }
 /// <summary>
 /// Create a new ProductProductPhoto object.
 /// </summary>
 /// <param name="productID">Initial value of ProductID.</param>
 /// <param name="productPhotoID">Initial value of ProductPhotoID.</param>
 /// <param name="primary">Initial value of Primary.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static ProductProductPhoto CreateProductProductPhoto(int productID, int productPhotoID, bool primary, global::System.DateTime modifiedDate)
 {
     ProductProductPhoto productProductPhoto = new ProductProductPhoto();
     productProductPhoto.ProductID = productID;
     productProductPhoto.ProductPhotoID = productPhotoID;
     productProductPhoto.Primary = primary;
     productProductPhoto.ModifiedDate = modifiedDate;
     return productProductPhoto;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Make any alterations necessary (i.e. for DB check constraints, special test cases, etc.)
 /// </summary>
 /// <param name="mock">Object to be modified</param>
 static private void SetSpecialTestData(ProductProductPhoto mock)
 {
     //Code your changes to the data object here.
 }
 /// <summary>
 /// There are no comments for ProductProductPhoto in the schema.
 /// </summary>
 public void AddToProductProductPhoto(ProductProductPhoto productProductPhoto)
 {
     base.AddObject("ProductProductPhoto", productProductPhoto);
 }
Exemplo n.º 25
0
 public ProductRepos(int productID)
 {
     product         = (new AllProducts()).GetProduct(productID);
     productPhotoRef = awContext.ProductProductPhotoes.FirstOrDefault(t => t.ProductID == productID);
 }
	private void attach_ProductProductPhotos(ProductProductPhoto entity)
	{
		this.SendPropertyChanging();
		entity.Product = this;
	}
	private void detach_ProductProductPhotos(ProductProductPhoto entity)
	{
		this.SendPropertyChanging();
		entity.Product = null;
	}
 partial void DeleteProductProductPhoto(ProductProductPhoto instance);
 partial void UpdateProductProductPhoto(ProductProductPhoto instance);
 partial void InsertProductProductPhoto(ProductProductPhoto instance);
 // POST api/awbuildversion
 public void Post(ProductProductPhoto value)
 {
     adventureWorks_BC.ProductProductPhotoAdd(value);
 }
 // POST api/awbuildversion
 public void Post(ProductProductPhoto value)
 {
     adventureWorks_BC.ProductProductPhotoAdd(value);
 }