예제 #1
0
 /// <summary>
 /// Get Staff by PesonModel - Searching in the publicvariables.Owners
 /// </summary>
 /// <param name="person"></param>
 /// <returns></returns>
 public static OwnerModel GetPersonAsAOwner(PersonModel person)
 {
     return(PublicVariables.Owners.Find(x => x.Person.Id == person.Id));
 }
예제 #2
0
 /// <summary>
 /// Get Staff by PesonModel - Searching in the publicvariables.staffs
 /// </summary>
 /// <param name="person"></param>
 /// <returns></returns>
 public static StaffModel GetPersonAsAStaff(PersonModel person)
 {
     return(PublicVariables.Staffs.Find(x => x.Person.Id == person.Id));
 }
예제 #3
0
 /// <summary>
 ///  Get Supplier by PesonModel in the publicvariables.Suppliers
 /// </summary>
 /// <param name="person"></param>
 /// <returns></returns>
 public static SupplierModel GetPersonAsASupplier(PersonModel person)
 {
     return(PublicVariables.Suppliers.Find(x => x.Person.Id == person.Id));
 }
예제 #4
0
 /// <summary>
 ///  Get Customer by PesonModel by searching in the publicVariables.Customers
 /// </summary>
 /// <param name="person"></param>
 /// <returns></returns>
 public static CustomerModel  GetPersonAsACustomer(PersonModel person)
 {
     return(PublicVariables.Customers.Find(x => x.Person.Id == person.Id));
 }
예제 #5
0
        /// <summary>
        /// Get person model
        /// Add to the person table in the database
        /// Get the Id of this Person
        /// </summary>
        public static PersonModel AddPersonToTheDatabase(PersonModel person, string db)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnVal(db)))
            {
                var p = new DynamicParameters();
                p.Add("@FirstName", person.FirstName);
                if (!string.IsNullOrWhiteSpace(person.LastName))
                {
                    p.Add("@LastName", person.LastName);
                }
                else
                {
                    p.Add("@LastName", null);
                }
                if (!string.IsNullOrWhiteSpace(person.PhoneNumber))
                {
                    p.Add("@PhoneNumber", person.PhoneNumber);
                }
                else
                {
                    p.Add("@PhoneNumber", null);
                }
                if (!string.IsNullOrWhiteSpace(person.NationalNumber))
                {
                    p.Add("@NationalNumber", person.NationalNumber);
                }
                else
                {
                    p.Add("@NationalNumber", null);
                }

                p.Add("@BirthDate", person.BirthDate);

                if (!string.IsNullOrWhiteSpace(person.JopTitle))
                {
                    p.Add("@JopTitle", person.JopTitle);
                }
                else
                {
                    p.Add("@JopTitle", null);
                }

                if (!string.IsNullOrWhiteSpace(person.JopAddress))
                {
                    p.Add("@JopAddress", person.JopAddress);
                }
                else
                {
                    p.Add("@JopAddress", null);
                }

                p.Add("@GradutionDate", person.GraduationDate);


                if (!string.IsNullOrWhiteSpace(person.Qualification))
                {
                    p.Add("@Qualification", person.Qualification);
                }
                else
                {
                    p.Add("@Qualification", null);
                }


                if (!string.IsNullOrWhiteSpace(person.Email))
                {
                    p.Add("@Email", person.Email);
                }
                else
                {
                    p.Add("@Email", null);
                }
                if (!string.IsNullOrWhiteSpace(person.Address))
                {
                    p.Add("@Address", person.Address);
                }
                else
                {
                    p.Add("@Address", null);
                }
                if (!string.IsNullOrWhiteSpace(person.City))
                {
                    p.Add("@City", person.City);
                }
                else
                {
                    p.Add("@City", null);
                }
                if (!string.IsNullOrWhiteSpace(person.Country))
                {
                    p.Add("@Country", person.Country);
                }
                else
                {
                    p.Add("@Country", null);
                }
                if (!string.IsNullOrWhiteSpace(person.Details))
                {
                    p.Add("@Details", person.Details);
                }
                else
                {
                    p.Add("@Details", null);
                }
                p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
                connection.Execute("dbo.spPerson_CreatePerson", p, commandType: CommandType.StoredProcedure);
                person.Id = p.Get <int>("@Id");
            }
            return(person);
        }
예제 #6
0
 /// <summary>
 /// Update person data with the database
 /// </summary>
 /// <param name="person"></param>
 /// <param name="db"></param>
 public static void UpdatePersonData(PersonModel person, string db)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnVal(db)))
     {
         var p = new DynamicParameters();
         p.Add("@Id", person.Id);
         p.Add("@FirstName", person.FirstName);
         if (!string.IsNullOrWhiteSpace(person.LastName))
         {
             p.Add("@LastName", person.LastName);
         }
         else
         {
             p.Add("@LastName", null);
         }
         if (!string.IsNullOrWhiteSpace(person.PhoneNumber))
         {
             p.Add("@PhoneNumber", person.PhoneNumber);
         }
         else
         {
             p.Add("@PhoneNumber", null);
         }
         if (!string.IsNullOrWhiteSpace(person.NationalNumber))
         {
             p.Add("@NationalNumber", person.NationalNumber);
         }
         else
         {
             p.Add("@NationalNumber", null);
         }
         if (!string.IsNullOrWhiteSpace(person.Email))
         {
             p.Add("@Email", person.Email);
         }
         else
         {
             p.Add("@Email", null);
         }
         if (!string.IsNullOrWhiteSpace(person.Address))
         {
             p.Add("@Address", person.Address);
         }
         else
         {
             p.Add("@Address", null);
         }
         if (!string.IsNullOrWhiteSpace(person.City))
         {
             p.Add("@City", person.City);
         }
         else
         {
             p.Add("@City", null);
         }
         if (!string.IsNullOrWhiteSpace(person.Country))
         {
             p.Add("@Country", person.Country);
         }
         else
         {
             p.Add("@Country", null);
         }
         if (!string.IsNullOrWhiteSpace(person.Details))
         {
             p.Add("@Details", person.Details);
         }
         else
         {
             p.Add("@Details", null);
         }
         connection.Execute("dbo.spPerson_Update", p, commandType: CommandType.StoredProcedure);
     }
 }