Пример #1
0
        public ActionResult Create([Bind(Include = "Id,DocEntry,CardCode,CardName,DocNum,NumAtCard,DocDate,DocDueDate,DocType,Printed,DocStatus,DocCur,DocRate,SalesOrderNo,GroupNum,SalesEmployee,ContactPerson,ShipTo,BillTo,TaxRate,TotalTax,TaxAmountFC,DiscountForDocument,TotalDiscount,TotalDiscountFC,DocumentTotal,DocumentTotalFC,PaidToDate,PaidFC,Remark")] SalesOrder salesOrder)
        {
            if (ModelState.IsValid)
            {
                salesOrder.Id = Guid.NewGuid();
                db.SalesOrders.Add(salesOrder);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(salesOrder));
        }
Пример #2
0
        public void TestInitialize()
        {
            using (var entities = new IdEntities())
            {
                entities.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                entities.Ids.RemoveRange(entities.Ids);
                entities.SaveChanges();

                for (var i = 1; i <= TestSeeds; ++i)
                {
                    entities.Ids.Add(new Id {
                        Value = i
                    });
                }

                entities.SaveChanges();
            }
        }
Пример #3
0
        public void TestInitialize()
        {
            AppDomain.CurrentDomain.SetData("DataDirectory", AppDomain.CurrentDomain.BaseDirectory);

            using (var entities = new IdEntities())
            {
                entities.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                entities.Ids.RemoveRange(entities.Ids);
                entities.SaveChanges();

                for (var i = 1; i <= TestSeeds; ++i)
                {
                    entities.Ids.Add(new Id {
                        Value = i
                    });
                }

                entities.SaveChanges();
            }
        }
Пример #4
0
        //[TestInitialize]
        //public void TestInitialize()
        //{
        //    using (var entities = new IdEntities())
        //    {
        //        entities.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

        //        entities.Ids.RemoveRange(entities.Ids);
        //        entities.SaveChanges();

        //        for (var i = 1; i <= TestSeeds; ++i)
        //        {
        //            entities.Ids.Add(new Id { Value = i });
        //        }

        //        entities.SaveChanges();
        //    }
        //}

        //[TestMethod]
        public static int ClearTable()
        {
            var recordCount = -1;

            using (var entities = new IdEntities())
            {
                entities.Ids.RemoveRange(entities.Ids);
                entities.SaveChanges();
            }

            using (var entities = new IdEntities())
            {
                recordCount = entities.Ids.Count();
            }

            return(recordCount);

            //Assert.AreEqual(0, recordCount);
        }
Пример #5
0
        //[TestMethod]
        public static int RemoveRecords(int recordsToRemove)
        {
            var recordCount = -1;

            using (var entities = new IdEntities())
            {
                entities.Ids.RemoveRange(entities.Ids.Take(recordsToRemove));
                entities.SaveChanges();
            }

            using (var entities = new IdEntities())
            {
                recordCount = entities.Ids.Count();
            }

            return(recordCount);

            //Assert.AreEqual(TestSeeds - recordsToRemove, recordCount);
        }
Пример #6
0
        //[TestMethod]
        public static int UpdateRecord(int testValue)
        {
            var actualValue = -1;

            using (var entities = new IdEntities())
            {
                entities.Ids.First().Value = testValue;
                entities.SaveChanges();
            }

            using (var entities = new IdEntities())
            {
                // ReSharper disable PossibleInvalidOperationException
                actualValue = entities.Ids.First().Value.Value;
                // ReSharper restore PossibleInvalidOperationException
            }

            //Assert.AreEqual(testUpdateValue, actualValue);

            return(actualValue);
        }
Пример #7
0
        //[TestMethod]
        public static int AddRecords(int offsetRecords)
        {
            var recordCount     = -1;
            var recordsToInsert = TestSeeds + offsetRecords;

            using (var entities = new IdEntities())
            {
                for (var i = TestSeeds + 1; i <= recordsToInsert; ++i)
                {
                    entities.Ids.Add(new Id {
                        Value = i
                    });
                }

                entities.SaveChanges();

                recordCount = entities.Ids.Count();
            }

            return(recordCount);

            //Assert.AreEqual(recordsToInsert, recordCount);
        }