protected void Page_Load(object sender, EventArgs e)
    {
        // Get requested person
        try
        {
            string inputKey = HttpContext.Current.Request["Person"].ToString();
            string persId   = inputKey.Substring(1, inputKey.IndexOf("A") - 2);
            _displayedPerson = (Person)Person.FromIdentity(Convert.ToInt32(persId));
            string key = "1" + CheckDigit.AppendCheckDigit(_displayedPerson.Identity).ToString() + "A" + _displayedPerson.HexIdentifier();
            if (inputKey.ToUpper() != key.ToUpper())
            {
                throw new Exception("Wrong Call");
            }

            Subscriptions1.CurrentUserId   = _displayedPerson.Identity;
            Subscriptions1.DisplayedPerson = _displayedPerson;
            Panel2.Visible = true;
            Panel1.Visible = false;
        }
        catch
        {
            Panel1.Visible = true;
            Panel2.Visible = false;
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (Code != null)
         {
             hashCode = hashCode * 59 + Code.GetHashCode();
         }
         if (CheckDigit != null)
         {
             hashCode = hashCode * 59 + CheckDigit.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (RelatedBranch != null)
         {
             hashCode = hashCode * 59 + RelatedBranch.GetHashCode();
         }
         if (OpeningDate != null)
         {
             hashCode = hashCode * 59 + OpeningDate.GetHashCode();
         }
         return(hashCode);
     }
 }
        public void CheckIsbnTest_Condition4()
        {
            var    checkDigit = new CheckDigit();
            string returned   = CheckDigit.CheckIsbn("978037428158");

            Assert.AreEqual("0374281580", returned);
        }
Esempio n. 4
0
 public override void FillIndividualPlaceholders(IEmailPerson personObject)
 {
     try
     {
         if (!(personObject is Person))
         {
             throw new ArgumentException(BaseName +
                                         ".MakeIndividualReplacements called with wrong type of person object");
         }
         Person person = (Person)personObject;
         MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
         HexIdentifier         = person.HexIdentifier();
         MemberNumber          = person.PersonId.ToString();
         if (People.FromPhoneNumber(person.Country.Code, person.Phone).Count == 1)
         {
             MemberPhoneNumber = person.Phone;
         }
     }
     catch (Exception e)
     {
         throw new Exception(
                   "Failed in FillIndividualPlaceholders person is " + personObject == null
                 ? "null"
                 : personObject.Identity.ToString(), e);
     }
 }
        public void CheckIsbnTest_Condition3()
        {
            var    checkDigit = new CheckDigit();
            string returned   = CheckDigit.CheckIsbn("978037541457");

            Assert.AreEqual("0375414576", returned);
        }
        public void CheckIsbnTest_Condition2()
        {
            var    checkDigit = new CheckDigit();
            string returned   = CheckDigit.CheckIsbn("978140007917");

            Assert.AreEqual("1400079179", returned);
        }
        public void CheckIsbnTest_Condition1()
        {
            var    checkDigit = new CheckDigit();
            string returned   = CheckDigit.CheckIsbn("978155192370");

            Assert.AreEqual("155192370x", returned);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (AccountNumber != null)
         {
             hashCode = hashCode * 59 + AccountNumber.GetHashCode();
         }
         if (BankCode != null)
         {
             hashCode = hashCode * 59 + BankCode.GetHashCode();
         }
         if (BankName != null)
         {
             hashCode = hashCode * 59 + BankName.GetHashCode();
         }
         if (BranchCode != null)
         {
             hashCode = hashCode * 59 + BranchCode.GetHashCode();
         }
         if (CheckDigit != null)
         {
             hashCode = hashCode * 59 + CheckDigit.GetHashCode();
         }
         if (CountryCode != null)
         {
             hashCode = hashCode * 59 + CountryCode.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 9
0
    static void Main(string[] args)
    {
        isbn myFavoriteBook = new isbn();
        bool isValid        = CheckDigit.CheckIsbn(myFavoriteBook.GetIsbn());

        Console.WriteLine(string.Format("Your book {0} a valid ISBN",
                                        isValid ? "has" : "doesn't have"));
        Console.ReadLine();
    }
Esempio n. 10
0
        public override void FillIndividualPlaceholders(IEmailPerson personObject)
        {
            if (!(personObject is Person))
            {
                throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
            }
            Person person = (Person)personObject;

            this.MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
            this.HexIdentifier         = person.HexIdentifier();
            this.MemberNumber          = person.PersonId.ToString();
        }
    static void Main(string[] args)
    {
        //create a new instance of the ISBN/book class. you're prompted as part
        //of the constructor.
        isbn myFavoriteBook = new isbn();
        //new class contains the method for checking validity
        bool isValid = CheckDigit.CheckIsbn(myFavoriteBook.GetIsbn());

        //write out the results of the validity.
        Console.WriteLine(string.Format("Your book {0} a valid ISBN",
                                        isValid ? "has" : "doesn't have"));
        Console.ReadLine();
    }
Esempio n. 12
0
        public override void FillIndividualPlaceholders(IEmailPerson personObject)
        {
            if (!(personObject is Person))
            {
                throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
            }
            Person person = (Person)personObject;

            this.MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
            this.HexIdentifier         = person.HexIdentifier();
            this.MemberNumber          = person.PersonId.ToString();
            this.Name           = person.Name;
            this.NameUrl        = HttpUtility.UrlEncode(person.Name);
            this.EmailBase64Url = HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(person.Mail)));
            this.PhoneBase64Url = HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(person.Phone)));
        }
Esempio n. 13
0
        public void TestMethod1()
        {
            List <TestCase> testCaseList = new List <TestCase>();

            testCaseList.Add(new TestCase()
            {
                IdCard = 110040062874
            });
            foreach (TestCase testCase in testCaseList)
            {
                CheckDigit checkDigit  = new CheckDigit();
                int        output      = checkDigit.CalLastID(testCase.IdCard);
                int        checkOutput = Convert.ToInt32(testCase.IdCard.ToString().Substring(12, 1));
                Assert.AreEqual(checkOutput, output);
            }
        }
Esempio n. 14
0
 public Filter(InputFilter f)
 {
     this.inputFilter = f;
     regex            = inputFilter.Regex;
     filterName       = inputFilter.Filter_name;
     filterType       = inputFilter.Filter_type;
     filterSubType    = inputFilter.Filter_sub_type;
     if (inputFilter.Check_digit_class.Trim().Length > 0)
     {
         try
         {
             checkDigit = Assembly.GetExecutingAssembly().CreateInstance(inputFilter.Check_digit_class) as CheckDigit;
         }
         catch
         {
         }
     }
 }
Esempio n. 15
0
        /// <summary>
        /// Returns true if BranchIdentification instances are equal
        /// </summary>
        /// <param name="other">Instance of BranchIdentification to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BranchIdentification other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                     ) &&
                 (
                     Code == other.Code ||
                     Code != null &&
                     Code.Equals(other.Code)
                 ) &&
                 (
                     CheckDigit == other.CheckDigit ||
                     CheckDigit != null &&
                     CheckDigit.Equals(other.CheckDigit)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     RelatedBranch == other.RelatedBranch ||
                     RelatedBranch != null &&
                     RelatedBranch.Equals(other.RelatedBranch)
                 ) &&
                 (
                     OpeningDate == other.OpeningDate ||
                     OpeningDate != null &&
                     OpeningDate.Equals(other.OpeningDate)
                 ));
        }
        /// <summary>
        /// Returns true if BankAccountBban instances are equal
        /// </summary>
        /// <param name="other">Instance of BankAccountBban to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BankAccountBban other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AccountNumber == other.AccountNumber ||
                     AccountNumber != null &&
                     AccountNumber.Equals(other.AccountNumber)
                     ) &&
                 (
                     BankCode == other.BankCode ||
                     BankCode != null &&
                     BankCode.Equals(other.BankCode)
                 ) &&
                 (
                     BankName == other.BankName ||
                     BankName != null &&
                     BankName.Equals(other.BankName)
                 ) &&
                 (
                     BranchCode == other.BranchCode ||
                     BranchCode != null &&
                     BranchCode.Equals(other.BranchCode)
                 ) &&
                 (
                     CheckDigit == other.CheckDigit ||
                     CheckDigit != null &&
                     CheckDigit.Equals(other.CheckDigit)
                 ) &&
                 (
                     CountryCode == other.CountryCode ||
                     CountryCode != null &&
                     CountryCode.Equals(other.CountryCode)
                 ));
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            // Func Delegate is use when funcion returns any values
            // Func Delegates With Anonymous Method
            Mathamatic objAddition = new Mathamatic
                                     (
                delegate(int x, int y)
            {
                return(x + y);
            }
                                     );

            int _Result = objAddition(50, 60);

            Console.WriteLine("Func with Anonymous Method Addition is " + _Result.ToString());

            // Func Delegates With Lambda Expression
            Func <int, int, int> Addition = (x, y) => x + y;

            _Result = Addition(50, 80);
            Console.WriteLine("Func with Lambda Expression Addition is " + _Result.ToString());


            // *****************************************************************************************************************


            // Action Delegate is use when funcion does not returns any values
            // Actioin Delegates With Anonymous Method
            DisplayData objDisplay = new DisplayData
                                     (
                delegate(string x)
            {
                Console.WriteLine(x);
            }
                                     );

            objDisplay("Action with Anonymous Method");


            // Action Delegates With Lambda Expression
            Action <string> DisplyData = (x) => Console.WriteLine(x);;

            DisplyData("Action with Lambda Expression");


            // *****************************************************************************************************************

            // Predicate Delegate is use when funcion returns true/false values
            // Predicate Delegates With Anonymous Method
            CheckDigit objCheckOddEven = new CheckDigit
                                         (
                delegate(int x)
            {
                return(x % 2 == 0);
            }
                                         );

            bool chkOddEven = objCheckOddEven(15);

            Console.WriteLine("Predicate with Anonymous Method Check Odd Even is " + chkOddEven);


            // Predicate Delegates With Lambda Expression
            Predicate <int> oddEvenCheck = x => x % 2 == 0;
            bool            oddevenchk   = oddEvenCheck(56);

            Console.WriteLine("Predicate with Lambda Expr ession Check Odd Even is " + oddevenchk);



            Console.ReadLine();
        }
Esempio n. 18
0
        public static CheckDigit AsCheckDigit(this int value)
        {
            var checkDigit = new CheckDigit(value);

            return(checkDigit);
        }