Наследование: System.Data.Objects.DataClasses.EntityObject
        public void It_Should_Be_Possible_To_Update_A_CheckpointOrder_To_The_Database()
        {
            CheckpointOrder origCheckpointOrder = new CheckpointOrder();
            origCheckpointOrder.CheckpointID = 1;
            origCheckpointOrder.StartingNumber = 1;

            CheckpointOrder updatedCheckpointOrder = origCheckpointOrder;

            Given("we have a checkpointOrder", () =>
            {
                checkpointOrderModel.AddCheckpointOrderDB((int)origCheckpointOrder.CheckpointID, (int)origCheckpointOrder.StartingNumber);
            });

            When("we update the checkpointOrder", () =>
            {
                updatedCheckpointOrder.CheckpointID = 1;
                updatedCheckpointOrder.StartingNumber = 2;
                checkpointOrderModel.UpdateCheckpointOrderDB((int)updatedCheckpointOrder.CheckpointID, (int)updatedCheckpointOrder.StartingNumber);
            });

            Then("the values should be different", () =>
            {
                updatedCheckpointOrder.StartingNumber.ShouldNotBe(origCheckpointOrder.StartingNumber);
            });
        }
        private static CheckpointOrder CreateCheckpointOrder(int checkpointId, int startingNumber, Entities entities)
        {
            var checkpointOrder = new CheckpointOrder();
            checkpointOrder.CheckpointID = checkpointId;
            checkpointOrder.StartingNumber = startingNumber;

            if ((ExistsAnyCheckpointOrdersInDb(entities)) && (CheckpointExistsInDb(checkpointId, entities)))
                checkpointOrder.OrderNumber = GetHighestExistingOrderNumberForCheckpoint(checkpointId, entities) + 1;
            else
                checkpointOrder.OrderNumber = 1;

            checkpointOrder.IsDeleted = false;
            return checkpointOrder;
        }
Пример #3
0
        public static CheckpointOrderModel Create(int checkpointId, int startingNumber, int orderNumber)
        {
            CheckpointOrderModel checkpointOrderModel = new CheckpointOrderModel();

            using (var ctx = new Entities())
            {
                CheckpointOrder checkpointOrder = new CheckpointOrder();
                checkpointOrder.CheckpointID = checkpointId;
                checkpointOrder.StartingNumber = startingNumber;
                checkpointOrder.StartingNumber = (ctx.CheckpointOrders.OrderByDescending(chkpnt => chkpnt.CheckpointID).First().CheckpointID) + 1;
                ctx.CheckpointOrders.AddObject(checkpointOrder);
                ctx.SaveChanges();
                checkpointOrder.ID = (int)ctx.CheckpointOrders.OrderByDescending(chkpnt => chkpnt.CheckpointID).First().CheckpointID;
            }

            return checkpointOrderModel;
        }
Пример #4
0
 /// <summary>
 /// Create a new CheckpointOrder object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static CheckpointOrder CreateCheckpointOrder(global::System.Int32 id)
 {
     CheckpointOrder checkpointOrder = new CheckpointOrder();
     checkpointOrder.ID = id;
     return checkpointOrder;
 }
Пример #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the CheckpointOrders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCheckpointOrders(CheckpointOrder checkpointOrder)
 {
     base.AddObject("CheckpointOrders", checkpointOrder);
 }
Пример #6
0
 public ActionResult Create(CheckpointOrder CheckpointOrderToInsert)
 {
     return View("Index");
 }
Пример #7
0
        public void It_Should_Be_Possible_To_Update_A_CheckpointOrder_To_The_Database()
        {
            CheckpointOrder origCheckpointOrder = new CheckpointOrder();
            origCheckpointOrder.CheckpointID = 1;
            origCheckpointOrder.StartingNumber = 1;
            var id = 0;
            var startnumber = 0;

            using (var ctxTest = new Entities())
            {
                if (ctxTest.CheckpointOrders.Any(chkpnt => (chkpnt.StartingNumber == origCheckpointOrder.StartingNumber && chkpnt.CheckpointID == origCheckpointOrder.CheckpointID)))
                {
                    var checkpointOrderToDelete = ctxTest.CheckpointOrders.Where(checkpointOrder => (checkpointOrder.StartingNumber == origCheckpointOrder.StartingNumber && checkpointOrder.CheckpointID == origCheckpointOrder.CheckpointID)).Single();
                    ctxTest.CheckpointOrders.DeleteObject(checkpointOrderToDelete);
                    ctxTest.SaveChanges();
                }
            }

            CheckpointOrder updatedCheckpointOrder = origCheckpointOrder;

            Given("we have a checkpointOrder", () =>
            {
                checkpointOrderModel.AddCheckpointOrderDB((int)origCheckpointOrder.CheckpointID, (int)origCheckpointOrder.StartingNumber);
                var ctxTest = new Entities();
                id = ctxTest.CheckpointOrders.Where(checkpointOrder => (checkpointOrder.StartingNumber == origCheckpointOrder.StartingNumber && checkpointOrder.CheckpointID == origCheckpointOrder.CheckpointID)).Single().ID;
            });

            When("we update the checkpointOrder", () =>
            {
                updatedCheckpointOrder.CheckpointID = 1;
                updatedCheckpointOrder.StartingNumber = 2;
                checkpointOrderModel.UpdateCheckpointOrderDB((int)id, (int)updatedCheckpointOrder.StartingNumber);
                var ctxTest = new Entities();
                 startnumber = (int)(ctxTest.CheckpointOrders.Where(checkpointOrder => (checkpointOrder.StartingNumber == origCheckpointOrder.StartingNumber && checkpointOrder.ID == id)).Single().StartingNumber);
            });

            Then("the values should be different", () =>
            {
                updatedCheckpointOrder.StartingNumber.ShouldBe(startnumber);
            });
        }
Пример #8
0
 /// <summary>
 /// Create a new CheckpointOrder object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 /// <param name="isMerged">Initial value of the IsMerged property.</param>
 public static CheckpointOrder CreateCheckpointOrder(global::System.Int32 id, global::System.Boolean isDeleted, global::System.Boolean isMerged)
 {
     CheckpointOrder checkpointOrder = new CheckpointOrder();
     checkpointOrder.ID = id;
     checkpointOrder.IsDeleted = isDeleted;
     checkpointOrder.IsMerged = isMerged;
     return checkpointOrder;
 }
 private static void SaveCheckpointOrder(CheckpointOrder checkpointOrder, Entities entities)
 {
     entities.CheckpointOrders.AddObject(checkpointOrder);
     entities.SaveChanges();
 }