Inheritance: System.Web.UI.Page
        /// <summary>
        /// Deep load all ProductCostHistory children.
        /// </summary>
        private void Step_03_DeepLoad_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                int count = -1;
                mock           = CreateMockInstance(tm);
                mockCollection = DataRepository.ProductCostHistoryProvider.GetPaged(tm, 0, 10, out count);

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

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

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

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        /// <summary>
        /// Test Find using the Query class
        /// </summary>
        private void Step_30_TestFindByQuery_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                //Insert Mock Instance
                ProductCostHistory mock = CreateMockInstance(tm);
                bool result             = DataRepository.ProductCostHistoryProvider.Insert(tm, mock);

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

                ProductCostHistoryQuery query = new ProductCostHistoryQuery();

                query.AppendEquals(ProductCostHistoryColumn.ProductId, mock.ProductId.ToString());
                query.AppendEquals(ProductCostHistoryColumn.StartDate, mock.StartDate.ToString());
                if (mock.EndDate != null)
                {
                    query.AppendEquals(ProductCostHistoryColumn.EndDate, mock.EndDate.ToString());
                }
                query.AppendEquals(ProductCostHistoryColumn.StandardCost, mock.StandardCost.ToString());
                query.AppendEquals(ProductCostHistoryColumn.ModifiedDate, mock.ModifiedDate.ToString());

                TList <ProductCostHistory> results = DataRepository.ProductCostHistoryProvider.Find(tm, query);

                Assert.IsTrue(results.Count == 1, "Find is not working correctly.  Failed to find the mock instance");
            }
        }
        public ProductCostHistoryCollection GetAllProductCostHistorysDynamicCollection(string whereExpression, string orderBy)
        {
            IDBManager dbm = new DBManager();
            ProductCostHistoryCollection cols = new ProductCostHistoryCollection();

            try
            {
                dbm.CreateParameters(2);
                dbm.AddParameters(0, "@WhereCondition", whereExpression);
                dbm.AddParameters(1, "@OrderByExpression", orderBy);
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectProductInventoriesDynamic");
                while (reader.Read())
                {
                    ProductCostHistory productCostHistory = new ProductCostHistory();
                    productCostHistory.ProductID    = Int32.Parse(reader["ProductID"].ToString());
                    productCostHistory.StartDate    = DateTime.Parse(reader["StartDate"].ToString());
                    productCostHistory.EndDate      = DateTime.Parse(reader["EndDate"].ToString());
                    productCostHistory.StandardCost = Decimal.Parse(reader["StandardCost"].ToString());
                    productCostHistory.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString());
                    cols.Add(productCostHistory);
                }
            }

            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllProductCostHistorysDynamicCollection");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(cols);
        }
        public int AddProductCostHistory(ProductCostHistory productCostHistory)
        {
            IDBManager dbm = new DBManager();

            try
            {
                dbm.CreateParameters(6);
                dbm.AddParameters(0, "@ProductID", productCostHistory.ProductID);
                dbm.AddParameters(1, "@StartDate", productCostHistory.StartDate);
                dbm.AddParameters(2, "@EndDate", productCostHistory.EndDate);
                dbm.AddParameters(3, "@StandardCost", productCostHistory.StandardCost);
                dbm.AddParameters(4, "@ModifiedDate", DateTime.Now);
                dbm.AddParameters(5, "@ID", productCostHistory.ID);
                dbm.Parameters[5].Direction = ParameterDirection.Output;
                dbm.ExecuteNonQuery(CommandType.StoredProcedure, "InsertProductCostHistory");

                productCostHistory.ID = Int32.Parse(dbm.Parameters[5].Value.ToString());
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "AddProductCostHistory");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(productCostHistory.ID);
        }
        public ProductCostHistory GetProductCostHistory(int productID)
        {
            IDBManager         dbm = new DBManager();
            ProductCostHistory productCostHistory = new ProductCostHistory();

            try
            {
                dbm.CreateParameters(1);
                dbm.AddParameters(0, "@ProductID", productID);
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectProductCostHistory");
                while (reader.Read())
                {
                    productCostHistory.ID           = Int32.Parse(reader["ID"].ToString());
                    productCostHistory.ProductID    = Int32.Parse(reader["ProductID"].ToString());
                    productCostHistory.StartDate    = DateTime.Parse(reader["StartDate"].ToString());
                    productCostHistory.EndDate      = DateTime.Parse(reader["EndDate"].ToString());
                    productCostHistory.StandardCost = Decimal.Parse(reader["StandardCost"].ToString());
                    productCostHistory.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString());
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetProductCostHistory");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(productCostHistory);
        }
        public bool UpdateProductCostHistory(ProductCostHistory productCostHistory)
        {
            IDBManager dbm = new DBManager();

            try
            {
                dbm.CreateParameters(5);
                dbm.AddParameters(0, "@ProductID", productCostHistory.ProductID);
                dbm.AddParameters(1, "@StartDate", productCostHistory.StartDate);
                dbm.AddParameters(2, "@EndDate", productCostHistory.EndDate);
                dbm.AddParameters(3, "@StandardCost", productCostHistory.StandardCost);
                dbm.AddParameters(4, "@ModifiedDate", DateTime.Now);

                dbm.ExecuteNonQuery(CommandType.StoredProcedure, "UpdateProductCostHistory");
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "UpdateProductCostHistory");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(true);
        }
        public ProductCostHistoryCollection GetAllProductCostHistorysCollection()
        {
            IDBManager dbm = new DBManager();
            ProductCostHistoryCollection cols = new ProductCostHistoryCollection();

            try
            {
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectProductCostHistoriesAll");
                while (reader.Read())
                {
                    ProductCostHistory productCostHistory = new ProductCostHistory();
                    productCostHistory.ID           = Int32.Parse(reader["ID"].ToString());
                    productCostHistory.ProductID    = Int32.Parse(reader["ProductID"].ToString());
                    productCostHistory.StartDate    = DateTime.Parse(reader["StartDate"].ToString());
                    productCostHistory.EndDate      = DateTime.Parse(reader["EndDate"].ToString());
                    productCostHistory.StandardCost = Decimal.Parse(reader["StandardCost"].ToString());
                    productCostHistory.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString());
                    cols.Add(productCostHistory);
                }
            }

            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllProductCostHistorysCollection");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(cols);
        }
        ///<summary>
        ///  Update the Typed ProductCostHistory Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, ProductCostHistory mock)
        {
            ProductCostHistoryTest.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);

                ProductCostHistory entity = mock.Copy() as ProductCostHistory;
                entity = (ProductCostHistory)mock.Clone();
                Assert.IsTrue(ProductCostHistory.ValueEquals(entity, mock), "Clone is not working");
            }
        }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "ProductID,StartDate,EndDate,StandardCost,ModifiedDate,isDeleted")] ProductCostHistory productCostHistory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productCostHistory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductID = new SelectList(db.Products, "ProductID", "Name", productCostHistory.ProductID);
     return(View(productCostHistory));
 }
        /// <summary>
        /// Check the foreign key dal methods.
        /// </summary>
        private void Step_10_FK_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                ProductCostHistory entity = CreateMockInstance(tm);
                bool result = DataRepository.ProductCostHistoryProvider.Insert(tm, entity);

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

                TList <ProductCostHistory> t0 = DataRepository.ProductCostHistoryProvider.GetByProductId(tm, entity.ProductId, 0, 10);
            }
        }
        ///<summary>
        ///  Update the Typed ProductCostHistory Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance_Generated(TransactionManager tm, ProductCostHistory mock)
        {
            mock.EndDate      = TestUtility.Instance.RandomDateTime();
            mock.StandardCost = TestUtility.Instance.RandomShort();
            mock.ModifiedDate = TestUtility.Instance.RandomDateTime();

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

            DataRepository.ProductProvider.Insert(tm, mockProductByProductId);
            mock.ProductId = mockProductByProductId.ProductId;
        }
        ///<summary>
        ///  Returns a Typed ProductCostHistory Entity with mock values.
        ///</summary>
        static public ProductCostHistory CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            ProductCostHistory mock = ProductCostHistoryTest.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(ProductCostHistory 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.ProductCostHistoryDelete(value);
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                    adventureWorks_BC.ProductCostHistoryUpdate(value);
            }
        }
Esempio n. 15
0
        public virtual ProductCostHistory MapBOToEF(
            BOProductCostHistory bo)
        {
            ProductCostHistory efProductCostHistory = new ProductCostHistory();

            efProductCostHistory.SetProperties(
                bo.EndDate,
                bo.ModifiedDate,
                bo.ProductID,
                bo.StandardCost,
                bo.StartDate);
            return(efProductCostHistory);
        }
Esempio n. 16
0
        public virtual BOProductCostHistory MapEFToBO(
            ProductCostHistory ef)
        {
            var bo = new BOProductCostHistory();

            bo.SetProperties(
                ef.ProductID,
                ef.EndDate,
                ef.ModifiedDate,
                ef.StandardCost,
                ef.StartDate);
            return(bo);
        }
        /// <summary>
        /// Serialize the mock ProductCostHistory 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_ProductCostHistory.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.");
            }
        }
        /// <summary>
        /// Check the indexes dal methods.
        /// </summary>
        private void Step_11_IX_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                ProductCostHistory entity = CreateMockInstance(tm);
                bool result = DataRepository.ProductCostHistoryProvider.Insert(tm, entity);

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


                ProductCostHistory t0 = DataRepository.ProductCostHistoryProvider.GetByProductIdStartDate(tm, entity.ProductId, entity.StartDate);
            }
        }
        public void MapEFToBOList()
        {
            var mapper = new DALProductCostHistoryMapper();
            ProductCostHistory entity = new ProductCostHistory();

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

            List <BOProductCostHistory> response = mapper.MapEFToBO(new List <ProductCostHistory>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
Esempio n. 20
0
        // GET: ProductCostHistories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductCostHistory productCostHistory = db.ProductCostHistories.Find(id);

            if (productCostHistory == null)
            {
                return(HttpNotFound());
            }
            return(View(productCostHistory));
        }
Esempio n. 21
0
 public bool ProductCostHistoryDelete(ProductCostHistory productcosthistory)
 {
     return(Execute <bool>(dal =>
     {
         ProductCostHistory productcosthistoryDelete = dal.ProductCostHistory.Where(x => x.ProductID == productcosthistory.ProductID).FirstOrDefault();
         if (productcosthistoryDelete != null)
         {
             dal.ProductCostHistory.DeleteOnSubmit(productcosthistoryDelete);
             dal.SubmitChanges();
             return true;
         }
         return false;
     }));
 }
        /// <summary>
        /// Inserts a mock ProductCostHistory entity into the database.
        /// </summary>
        private void Step_01_Insert_Generated()
        {
            using (TransactionManager tm = CreateTransaction())
            {
                mock = CreateMockInstance(tm);
                Assert.IsTrue(DataRepository.ProductCostHistoryProvider.Insert(tm, mock), "Insert failed");

                System.Console.WriteLine("DataRepository.ProductCostHistoryProvider.Insert(mock):");
                System.Console.WriteLine(mock);

                //normally one would commit here
                //tm.Commit();
                //IDisposable will Rollback Transaction since it's left uncommitted
            }
        }
        public void MapBOToEF()
        {
            var mapper = new DALProductCostHistoryMapper();
            var bo     = new BOProductCostHistory();

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

            ProductCostHistory response = mapper.MapBOToEF(bo);

            response.EndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ProductID.Should().Be(1);
            response.StandardCost.Should().Be(1m);
            response.StartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
        public void MapEFToBO()
        {
            var mapper = new DALProductCostHistoryMapper();
            ProductCostHistory entity = new ProductCostHistory();

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

            BOProductCostHistory response = mapper.MapEFToBO(entity);

            response.EndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ProductID.Should().Be(1);
            response.StandardCost.Should().Be(1m);
            response.StartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
Esempio n. 25
0
        // GET: ProductCostHistories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductCostHistory productCostHistory = db.ProductCostHistories.Find(id);

            if (productCostHistory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "Name", productCostHistory.ProductID);
            return(View(productCostHistory));
        }
Esempio n. 26
0
        // PUT api/awbuildversion/5
        public void Put(ProductCostHistory 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.ProductCostHistoryDelete(value);
                }
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                {
                    adventureWorks_BC.ProductCostHistoryUpdate(value);
                }
            }
        }
        /// <summary>
        /// Serialize a ProductCostHistory 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_ProductCostHistoryCollection.xml");

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

                EntityHelper.SerializeXml(mockCollection, fileName);

                Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found");
                System.Console.WriteLine("TList<ProductCostHistory> correctly serialized to a temporary file.");
            }
        }
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IProductCostHistoryRepository>();
            var record = new ProductCostHistory();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new ProductCostHistoryService(mock.LoggerMock.Object,
                                                        mock.RepositoryMock.Object,
                                                        mock.ModelValidatorMockFactory.ProductCostHistoryModelValidatorMock.Object,
                                                        mock.BOLMapperMockFactory.BOLProductCostHistoryMapperMock,
                                                        mock.DALMapperMockFactory.DALProductCostHistoryMapperMock);

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

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Esempio n. 29
0
        public bool ProductCostHistoryUpdate(ProductCostHistory productcosthistory)
        {
            return(Execute <bool>(dal =>
            {
                ProductCostHistory productcosthistoryUpdate = dal.ProductCostHistory.Where(x => x.ProductID == productcosthistory.ProductID).FirstOrDefault();
                if (productcosthistoryUpdate != null)
                {
                    productcosthistoryUpdate.ProductID = productcosthistory.ProductID;
                    productcosthistoryUpdate.StartDate = productcosthistory.StartDate;
                    productcosthistoryUpdate.EndDate = productcosthistory.EndDate;
                    productcosthistoryUpdate.StandardCost = productcosthistory.StandardCost;
                    productcosthistoryUpdate.ModifiedDate = productcosthistory.ModifiedDate;

                    dal.SubmitChanges();
                    return true;
                }
                return false;
            }));
        }
Esempio n. 30
0
        public ActionResult DeleteConfirmed(int id)
        {
            var res = (from c in db.ProductCostHistories
                       where c.ProductID == id
                       select c).FirstOrDefault();

            if (res != null)
            {
                res.isDeleted = true;
                db.SaveChanges();
                ViewBag.Message = string.Format("Congrats! Delete success");
            }

            ProductCostHistory productCategory = db.ProductCostHistories.Find(id);



            return(View(productCategory));
        }
        ///<summary>
        ///  Returns a Typed ProductCostHistory Entity with mock values.
        ///</summary>
        static public ProductCostHistory CreateMockInstance_Generated(TransactionManager tm)
        {
            ProductCostHistory mock = new ProductCostHistory();

            mock.StartDate    = TestUtility.Instance.RandomDateTime();
            mock.EndDate      = TestUtility.Instance.RandomDateTime();
            mock.StandardCost = TestUtility.Instance.RandomShort();
            mock.ModifiedDate = TestUtility.Instance.RandomDateTime();

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

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

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

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


            return((ProductCostHistory)mock);
        }
 /// <summary>
 /// There are no comments for ProductCostHistory in the schema.
 /// </summary>
 public void AddToProductCostHistory(ProductCostHistory productCostHistory)
 {
     base.AddObject("ProductCostHistory", productCostHistory);
 }
 /// <summary>
 /// Create a new ProductCostHistory object.
 /// </summary>
 /// <param name="productID">Initial value of ProductID.</param>
 /// <param name="startDate">Initial value of StartDate.</param>
 /// <param name="standardCost">Initial value of StandardCost.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static ProductCostHistory CreateProductCostHistory(int productID, global::System.DateTime startDate, decimal standardCost, global::System.DateTime modifiedDate)
 {
     ProductCostHistory productCostHistory = new ProductCostHistory();
     productCostHistory.ProductID = productID;
     productCostHistory.StartDate = startDate;
     productCostHistory.StandardCost = standardCost;
     productCostHistory.ModifiedDate = modifiedDate;
     return productCostHistory;
 }
 // POST api/awbuildversion
 public void Post(ProductCostHistory value)
 {
     adventureWorks_BC.ProductCostHistoryAdd(value);
 }