public void AddCustomer(int tenantId, Customer customer)
 {
     var sql = BuildInsertCustomerSql();
     ExecuteNonQuery(
         sql, CommandType.Text,
         command =>
             {
                 AddTenantParameters(command, tenantId);
                 AddCommonParameters(customer, command);
             });
 }
 private Customer CreateCustomerFromData(DbDataReader reader)
 {
     var customer = new Customer();
     customer.Id = (int) reader["Id"];
     customer.Username = DataHelper.GetStringValueOrEmptyString(reader["Username"]);
     customer.Name = DataHelper.GetStringValueOrEmptyString(reader["Name"]);
     customer.IdNumber = DataHelper.GetStringValueOrEmptyString(reader["IdNumber"]);
     customer.UniqueId = (Guid) reader["UniqueId"];
     customer.Phone = DataHelper.GetStringValueOrEmptyString(reader["Phone"]);
     customer.Email = DataHelper.GetStringValueOrEmptyString(reader["Email"]);
     customer.Address = DataHelper.GetStringValueOrEmptyString(reader["Address"]);
     customer.City = DataHelper.GetStringValueOrEmptyString(reader["City"]);
     customer.LastModified = DataHelper.DateAsUtc(DataHelper.GetSafeValue<DateTime?>(reader["LastModified"]));
     customer.CreatedAt = DataHelper.DateAsUtc(DataHelper.GetSafeValue<DateTime>(reader["CreatedAt"]));
     return customer;
 }
Example #3
0
 private void AddCustomer_Click(object sender, EventArgs e)
 {
     var customers = CustomersGrid.DataSource as Customer[];
     var index = 1;
     if (customers != null)
     {
         index = customers.Length + 1;
     }
     var customer = new Customer
                         {
                             Username ="******",
                             Name = "לקוח חדש #" + index,
                             Address = "כתובת ללקוח " + index,
                             City = "עיר ל" + index,
                             Phone = "052525360",
                             Email = "*****@*****.**",
                             IdNumber = "IdNum#" + index,
                             UniqueId = Guid.NewGuid()
                         };
     var ds = new CustomersDataService();
     ds.AddCustomer(GetTenantId(), customer);
     ReloadCustomers();
 }
 public void Post(Customer[] customers)
 {
     var dataService = ServiceProvider.Get<ICustomersDataService>();
     //customers.ForEach(customer => { dataService.SaveCustomer(1, customer); });
 }
 public void UpdateCustomer(int tenantId, Customer customer)
 {
     var sql = BuildUpdateCustomerSql();
     ExecuteNonQuery(
         sql, CommandType.Text,
         command =>
             {
                 AddTenantParameters(command, tenantId);
                 AddCommonParameters(customer, command);
                 DataHelper.AddParameterWithValue(command, "@Id", DbType.Int32, customer.Id);
             });
 }
 private static void AddCommonParameters(Customer customer, DbCommand command)
 {
     DataHelper.AddParameterWithValue(command, "@UserName", DbType.String, customer.Username);
     DataHelper.AddParameterWithValue(command, "@Name", DbType.String, customer.Name);
     DataHelper.AddParameterWithValue(command, "@IdNumber", DbType.String, customer.IdNumber);
     DataHelper.AddParameterWithValue(command, "@Phone", DbType.String, customer.Phone);
     DataHelper.AddParameterWithValue(command, "@Email", DbType.String, customer.Email);
     DataHelper.AddParameterWithValue(command, "@Address", DbType.String, customer.Address);
     DataHelper.AddParameterWithValue(command, "@City", DbType.String, customer.City);
     DataHelper.AddParameterWithValue(command, "@UniqueId", DbType.Guid, customer.UniqueId);
     DataHelper.AddParameterWithValue(command, "@CreatedAt", DbType.DateTime, DateTime.UtcNow);
 }