Пример #1
0
        internal bool DeleteItem(int Id)
        {
            OpCo opco = new OpCo();

            opco.Id = Id;
            return(OpCoShipmentController.DeleteShipment(Id));
        }
Пример #2
0
        internal bool DeleteItem(int Id)
        {
            OpCo opco = new OpCo();

            opco.Id = Id;
            return(OpcoController.DeleteOpCo(opco));
        }
Пример #3
0
 /// <summary>
 /// Gets a single OpCo for the specified Code.
 /// </summary>
 /// <param name="opcoCode">The opco id.</param>
 /// <param name="fullyPopulate">if set to <c>true</c> [fully populate].</param>
 /// <returns>An OpCo object</returns>
 public static OpCo GetOpCo(string opcoCode, bool fullyPopulate)
 {
     OpCo opco = new OpCo();
     try
     {
         opco = CBO<OpCo>.FillObject(DataAccessProvider.Instance().GetOpCo(opcoCode));
     }
     catch (Exception ex)
     {
         if (ExceptionPolicy.HandleException(ex, "Business Logic")) throw;
     }
     return opco;
 }
Пример #4
0
 public void SaveOpCoTestConstraint()
 {
     using (TransactionScope scope = new TransactionScope())
     {
         //get a new item
         OpCo opCo = PopulateNewItem();
         //save the item
         SaveItem(opCo);
         //save the item again, because it's id still =-1 then another insert will occur and because the item
         //has the same code a constraint will be violated
         SaveItem(opCo);
     }
 }
Пример #5
0
        public static OpCo PopulateNewItem()
        {
            OpCo opCo = new OpCo();

            opCo.Code        = Guid.NewGuid().ToString().Substring(0, 3);
            opCo.Description = "Test";
            opCo.FtpIP       = "Test";
            opCo.FtpPassword = "******";
            opCo.FtpUserName = "******";
            SalesLocationTests tests = new SalesLocationTests();

            opCo.UpdatedBy = "test";
            return(opCo);
        }
Пример #6
0
 /// <summary>
 /// Deletes a OpCo.
 /// </summary>
 /// <param name="opco">The opco to delete.</param>
 /// <returns>Success state</returns>
 public static bool DeleteOpCo(OpCo opco)
 {
     bool success = false;
     try
     {
         if (opco != null)
         {
             success = DataAccessProvider.Instance().DeleteOpCo(opco.Id);
         }
     }
     catch (Exception ex)
     {
         if (ExceptionPolicy.HandleException(ex, "Business Logic")) throw;
     }
     return success;
 }
Пример #7
0
        public void UpdateItem()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                OpCo item = PopulateNewItem();

                item.Description = "Original";
                item.Id          = SaveItem(item);
                item             = GetItem(item.Id, true);
                //change a value
                item.Description = "Updated";

                SaveItem(item);
                item = GetItem(item.Id, true);
                Assert.IsTrue(item.Description == "Updated");
            }
        }
Пример #8
0
        internal static OpCoShipment PopulateNewItem()
        {
            // Populate and Create an OpCo with default values
            OpCo opCo = OpcoTests.PopulateNewItem();

            opCo.Id = OpcoTests.SaveItem(opCo);

            OpCoShipment opCoShipment = new OpCoShipment();

            //populate item and lines
            opCoShipment.OpCoCode                 = opCo.Code;
            opCoShipment.OpCoSequenceNumber       = 1;
            opCoShipment.OpCoContact.Email        = "*****@*****.**";
            opCoShipment.OpCoContact.Name         = "TDC Test Team";
            opCoShipment.DespatchNumber           = "Despatch";
            opCoShipment.RequiredShipmentDate     = DateTime.Today;
            opCoShipment.TransactionTypeCode      = "TransType";
            opCoShipment.RouteCode                = "NHST";
            opCoShipment.CustomerNumber           = "CustNo";
            opCoShipment.CustomerReference        = "ref";
            opCoShipment.CustomerName             = "Robert Horne Group Ltd.";
            opCoShipment.CustomerAddress.Line1    = "Mansion House";
            opCoShipment.CustomerAddress.PostCode = "NN3 6JL";
            opCoShipment.ShipmentNumber           = "ShipNo";
            opCoShipment.ShipmentName             = "Shipment Name";
            opCoShipment.ShipmentAddress.Line1    = "Shipment Address Line 1";
            opCoShipment.ShipmentAddress.PostCode = "NN3 6JL";
            opCoShipment.SalesBranchCode          = "BBI";
            opCoShipment.AfterTime                = "08:30:00";
            opCoShipment.BeforeTime               = "23:59:59";
            opCoShipment.TailLiftRequired         = true;
            opCoShipment.VehicleMaxWeight         = (decimal)1.1;
            opCoShipment.CheckInTime              = 5;
            opCoShipment.DeliveryWarehouseCode    = "HNH";
            opCoShipment.StockWarehouseCode       = "XYZ";
            opCoShipment.DivisionCode             = "00";
            opCoShipment.GeneratedDateTime        = DateTime.Today;
            opCoShipment.Status       = 0;
            opCoShipment.UpdatedDate  = DateTime.Today;
            opCoShipment.UpdatedBy    = "TDC Test Team";
            opCoShipment.Instructions = "Instructions";

            return(opCoShipment);
        }
Пример #9
0
        public void ConcurrencyTest()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    OpCo item = PopulateNewItem();
                    item.Id = SaveItem(item);
                    //change a value
                    item.Description = "Updated";

                    SaveItem(item);
                }
                catch (DiscoveryException e)
                {
                    Assert.IsInstanceOfType(typeof(ConcurrencyException), e.InnerException);
                    throw e;
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Saves an OpCo object.
        /// </summary>
        /// <remarks>If the Id property =0 then an INSERT will Occur, otherwise an UPDATE will occur</remarks>
        /// <param name="opco">The opco.</param>
        /// <returns></returns>
        public static int SaveOpCo(OpCo opco)
        {
            try
            {
                if (opco.IsValid)
                {
                    opco.Id = DataAccessProvider.Instance().SaveOpCo(opco);
                }
                else
                {
                    // Entity is not valid
                    throw new InValidBusinessObjectException(opco);
                }
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "Business Logic")) throw;
            }

            // Done
            return opco.Id;
        }
Пример #11
0
 public static int SaveItem(OpCo opCo)
 {
     return(OpcoController.SaveOpCo(opCo));
 }