Exemplo n.º 1
0
        public bool UpdateCarrier(int id, string name, string contactFirstName, string contactLastName, string address, string city, string state, string postal, string phone, string email, string fax, string note)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ApplicationException("You must provide a Carrier Name.");
            }

            SPG.CarriersDataTable carriers = Adapter.GetCarrierByID(id);

            if (carriers.Count() == 0)
            {
                //It is a new carriers
                return(InsertCarrier(id, name, contactFirstName, contactLastName, address, city, state, postal, phone, email, fax, note));
            }

            SPG.CarriersRow carrier = carriers[0];

            object[] originalRecord = carrier.ItemArray;

            SetCarrierFields(name, contactFirstName, contactLastName, address, city, state, postal, phone, email, fax, note, carrier);

            if (!(originalRecord == null))
            {
                UpdateAuditTrail(carrier, originalRecord);
            }

            int rowsAffected = Adapter.Update(carrier);

            return(rowsAffected == 1);
        }
Exemplo n.º 2
0
        public bool DeleteCarrier(int id)
        {
            SPG.CarriersDataTable carriers = Adapter.GetCarrierByID(id);
            int rowsAffected = 0;

            if (carriers.Count() == 1)
            {
                SPG.CarriersRow carrier = (SPG.CarriersRow)carriers.Rows[0];
                rowsAffected = Adapter.Delete(id, carrier.ts);
            }

            //Return true if precisely one row was deleted, otherwise return false.
            return(rowsAffected == 1);
        }