示例#1
0
 /// <summary>
 /// Converts to dictionary.
 /// </summary>
 /// <returns>
 /// </returns>
 public new IDictionary <string, object> ToDictionary()
 {
     if (ID.GetIndex() > -1 &&
         Verify.Input(Section.GetValue()) &&
         Verify.Input(FirstName.GetValue()) &&
         Verify.Input(LastName.GetValue()) &&
         Verify.Input(Office.GetValue()) &&
         Verify.Input(PhoneNumber.GetValue()) &&
         Verify.Input(CellNumber.GetValue()) &&
         Verify.Input(Email.GetValue()))
     {
         try
         {
             return(new Dictionary <string, object>
             {
                 [PrimaryKey.EmployeeId.ToString()] = ID,
                 [Field.Section.ToString()] = Section.GetValue(),
                 [Field.LastName.ToString()] = LastName.GetValue(),
                 [Field.FirstName.ToString()] = FirstName.GetValue(),
                 [Field.Office.ToString()] = Office.GetValue(),
                 [Field.PhoneNumber.ToString()] = PhoneNumber.GetValue(),
                 [Field.CellNumber.ToString()] = CellNumber.GetValue(),
                 [Field.Email.ToString()] = Email.GetValue()
             });
         }
         catch (Exception ex)
         {
             Fail(ex);
             return(default);
        // ***************************************************************************************************************************
        // ************************************************  METHODS   ***************************************************************
        // ***************************************************************************************************************************

        /// <summary>
        /// Converts to string.
        /// </summary>
        /// <returns>
        /// A <see cref = "string"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            if (Verify.Element(FirstName) &&
                Verify.Element(LastName))
            {
                try
                {
                    return(FirstName.GetValue() + " " + LastName.GetValue());
                }
                catch (Exception ex)
                {
                    Fail(ex);
                    return(string.Empty);
                }
            }

            return(string.Empty);
        }