public DriverLicenseRecord(int id, string licenseClass, DateTime expiration, PersonRecord person) { this.Id = id; this.Class = licenseClass; this.Expires = expiration; this.OwnerFirstName = person.FirstName; this.OwnerLastName = person.LastName; this.OwnerBirthDate = person.BirthDate; }
public async Task Handle(SavePerson savePerson) { var record = new PersonRecord { FirstName = savePerson.FirstName, LastName = savePerson.LastName }; using (var context = new MySqlDbContext()) { await context.People.AddAsync(record); await context.SaveChangesAsync(); } await _eventsBus.Publish(new PersonSaved(record.Id)); }
public PersonRecord[] ListEntries(int start, int num) { if (start < 0 || start + num > this.records.Count) { throw new ArgumentOutOfRangeException("Invalid start index or count."); } this.records.Sort(); PersonRecord[] ent = new PersonRecord[num]; for (int i = start; i <= start + num - 1; i++) { PersonRecord entry = this.records[i]; ent[i - start] = entry; } return ent; }
public PersonRecord[] ListEntries(int first, int num) { if (first < 0 || first + num > this.dict.Count) { Console.WriteLine("Invalid start index or count."); return null; } PersonRecord[] list = new PersonRecord[num]; for (int i = first; i <= first + num - 1; i++) { PersonRecord entry = this.sorted[i]; list[i - first] = entry; } return list; }
private void btn_ok_Click(object sender, RoutedEventArgs e) { if (this.id == -1) { PersonRecord insertThis = new PersonRecord(); insertThis.Name = this.tb_name.Text; insertThis.Birt_day = DateTime.Parse(this.tb_birth.Text); insertThis.Job_id = this.cb_job.SelectedIndex + 1; insertThis.Salary = int.Parse(this.tb_salary.Text); try { Logger.Info("Adding a new worker to the database"); client.InsertPerson(this.token, insertThis); } catch (FaultException <ServiceData> sd) { Logger.Error("[Service] " + sd.Message); MessageBox.Show(sd.Message); } this.Close(); } else //upate id alapján { PersonRecord record = new PersonRecord(); record.Id = this.id; record.Name = this.tb_name.Text; record.Birt_day = DateTime.Parse(this.tb_birth.Text); record.Job_id = this.cb_job.SelectedIndex + 1; record.Salary = int.Parse(this.tb_salary.Text); try { Logger.Info("Update a worker to the database"); client.UpdatePerson(this.token, record); } catch (FaultException <ServiceData> sd) { Logger.Error("[Service] " + sd.Message); MessageBox.Show(sd.Message); } this.Close(); } }
public async Task <Unit> Handle(SavePerson savePerson, CancellationToken cancellationToken = default) { var record = new PersonRecord { FirstName = savePerson.FirstName, LastName = savePerson.LastName }; await using var context = new MySqlDbContext(); await context.People.AddAsync(record, cancellationToken); await context.SaveChangesAsync(cancellationToken); await _eventsBus.Publish(new PersonSaved(record.Id), cancellationToken); return(Unit.Value); }
public TopicsViewModel(NavigationService navi, PersonRecord model) { NavigationService = navi; Model = model; Topics = model.Topics == null ? new ObservableCollection <Topic> { new Topic(), new Topic(), new Topic(), new Topic(), new Topic(), } : new ObservableCollection <Topic>(model.Topics.Select(e => new Topic { TopicName = e })); Explore = new ExploreCommand(); }
public void PersonRecord_construction_test() { string firstName = "Jack"; string lastName = "Sparrow"; PersonRecord person = new PersonRecord(firstName, lastName); /// Identified и Person должны быть интерфейсами Assert.IsInstanceOf(typeof(IIdentified <string>), person); Assert.IsInstanceOf(typeof(IPerson), person); Assert.NotNull(person.Id); Assert.IsInstanceOf(typeof(string), person.Id); Assert.AreNotEqual(Guid.Empty.ToString(), person.Id); Assert.AreEqual(firstName, person.FirstName); Assert.AreEqual(lastName, person.LastName); Assert.LessOrEqual(person.BirthDate, DateTime.Now); }
public void PersonRecord_construction_test() { string firstName = "Jack"; string lastName = "Sparrow"; PersonRecord person = new PersonRecord(firstName, lastName); /// Identified и Person должны быть интерфейсами Assert.IsInstanceOf(typeof(IIdentified<string>), person); Assert.IsInstanceOf(typeof(IPerson), person); Assert.NotNull(person.Id); Assert.IsInstanceOf(typeof(string), person.Id); Assert.AreNotEqual(Guid.Empty.ToString(), person.Id); Assert.AreEqual(firstName, person.FirstName); Assert.AreEqual(lastName, person.LastName); Assert.LessOrEqual(person.BirthDate, DateTime.Now); }
private async Task Handle(SavePerson savePerson) { var record = new PersonRecord { FirstName = savePerson.FirstName, LastName = savePerson.LastName }; using (var context = new MySqlDbContext()) { await context.People.AddAsync(record); await context.SaveChangesAsync(); } Context.System.ActorSelection("*/EventRootActor").Tell(new PersonSaved(record.Id)); Sender.Tell(new IdCommandResult(record.Id), Self); }
static void Main(string[] args) { var myPersonRecord = new PersonRecord("William", "Ploger"); Console.WriteLine("Hello {0}!", myPersonRecord.FirstName); var myPersonRecordCompare1 = new PersonRecord("Joe", "Schmoe"); var MyPersonRecordCompare2 = new PersonRecord("Jack B", "Nimble"); var myPersonRecordCompare3 = new PersonRecord("Joe", "Schmoe"); //The output of this line should be falsed based on the Record Values above. //"Person { LastName = Schmoe, FirstName = Joe }" //"Person { LastName = Nimble, FirstName = Jack B }" //The comparison is between two different string outputs based on the values. Console.WriteLine(RecordEquality.CompareEquality(myPersonRecordCompare1, MyPersonRecordCompare2)); //The output of this line should be true based on the Record Values above //"Person { LastName = Schmoe, FirstName = Joe }" //"Person { LastName = Schmoe, FirstName = Joe }" //The comparison is between two different string outputs based on the values. Console.WriteLine(RecordEquality.CompareEquality(myPersonRecordCompare1, myPersonRecordCompare3)); }
public void AppendRecord(PersonRecord toAdd) { string query = "insert into records (PersonID, Weight,RecordDate, Height, Comments) VALUES (" + toAdd.PersonId + "," + toAdd.Weight + ",'" + toAdd.RecordDate.ToShortDateString() + "',0,'');"; using (SqlConnection connection = new SqlConnection(Getconnectionstring())) { using (SqlCommand command = new SqlCommand(query, connection)) { connection.Open(); int resultaat = command.ExecuteNonQuery(); if (resultaat == 1) { } else { } } } LoadFilefromDB(); }
private PersonRecord GetDummyPersonRecord() { PersonRecord dummyPersonRecordPerson = new PersonRecord { Name = "Elias Weingaertner", PersonId = "0de77c08b76406e9eb6703c0663061e9f3445054d17fc1de490ff4b2da0f8ef7", Phonenumber = "+49 179 4969645", Coordinates = new GeoCoordinates { Longitude = 21.2257100, Latitude = 45.7537200 }, Topics = new List <string> { "Pizza", "Hydraulic Press Channel", "Coffee" } }; return(dummyPersonRecordPerson); }
private List <PersonRecord> LoadFilefromDB() { List <PersonRecord> resultSet = new List <PersonRecord>(); using (var conn = new SqlConnection(Getconnectionstring())) using (var command = new SqlCommand("dbo.sp_get_all_in_one", conn) { CommandType = System.Data.CommandType.StoredProcedure }) { conn.Open(); using (SqlDataReader rdr = command.ExecuteReader()) { // iterate through results, printing each to console while (rdr.Read()) { PersonRecord tmpPerson = new PersonRecord( Convert.ToInt32(rdr["RecordSN"]), Convert.ToInt32(rdr["PersonID"]), (string)rdr["Name"], Convert.ToDecimal(rdr["Weight"]), Convert.ToDecimal(rdr["Height"]), Convert.ToDateTime(rdr["RecordDate"]), (string)rdr["Comments"]); resultSet.Add(tmpPerson); } } } CacheItemPolicy newpolicy = new CacheItemPolicy(); newpolicy.SlidingExpiration = TimeSpan.FromMinutes(30.00); ObjectCache cache = MemoryCache.Default; cache.Set("loaded", resultSet, newpolicy); return(resultSet); }
public bool AddPhone(string name, IEnumerable<string> nums) { string name2 = name.ToLowerInvariant(); PersonRecord entry; bool flag = !this.dict.TryGetValue(name2, out entry); if (flag) { entry = new PersonRecord(); entry.Name = name; entry.PhoneNumbers = new SortedSet<string>(); this.dict.Add(name2, entry); this.sorted.Add(entry); } foreach (var num in nums) { this.multidict.Add(num, entry); } entry.PhoneNumbers.UnionWith(nums); return flag; }
public bool AddPhone(string name, IEnumerable<string> nums) { var old = from e in this.records where e.Name.ToLowerInvariant() == name.ToLowerInvariant() select e; bool isInPhonebook; if (old.Count() == 0) { PersonRecord personRecord = new PersonRecord(); personRecord.Name = name; foreach (var num in nums) { personRecord.PhoneNumbers.Add(num); } this.records.Add(personRecord); isInPhonebook = false; } else if (old.Count() == 1) { PersonRecord existingPersonRecord = old.First(); foreach (var num in nums) { existingPersonRecord.PhoneNumbers.Add(num); } isInPhonebook = true; } else { Console.WriteLine("Duplicated name in the phonebook found: " + name); return false; } return isInPhonebook; }
private static void RecordTypesDemo() { ConsoleLoggingHelper.WriteTestSeparator(nameof(RecordTypesDemo)); var personClassA = new PersonClass { Name = "Bob" }; var personClassB = new PersonClass { Name = "Bob" }; Console.WriteLine(personClassA == personClassB ? "PersonClassA is equal to PersonClassB" : "PersonClassA is NOT equal to PersonClassB"); var personRecordA = new PersonRecord { Name = "Bob" }; //newRecord.MyProperty = 47; var personRecordB = new PersonRecord { Name = "Bob" }; Console.WriteLine(personRecordA == personRecordB ? "PersonRecordA is equal to PersonRecordB" : "PersonRecordA is NOT equal to PersonRecordB"); }
public void Insert(PersonRecord record) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "InsertPerson"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@name", record.Name); cmd.Parameters.AddWithValue("@birth_day", record.Birt_day); cmd.Parameters.AddWithValue("@job_id", record.Job_id); cmd.Parameters.AddWithValue("@salary", record.Salary); try { cmd.Connection = getConnection(); } catch (Exception) { throw new DatabaseConnectionException(); } try { cmd.ExecuteNonQuery(); } catch (Exception) { throw new DatabaseCommandTextException(); } }
private void PopulateRecords() { var person = new Person { Cnic = "12321-1234321-1", CurrentAddress = "Shaheedanwali,", PermanentAddress = "Basti Bukna,", DateOfBirth = new DateTime(1979, 2, 11), Gender = Gender.Male, Name = "Maula Jatt" }; var evictions = new List <Eviction> { new Eviction { CaseNumber = 420, Cnic = person.Cnic, CourtOrder = "50 hazaar jurmaana", Date = new DateTime(2010, 1, 1), JudgeName = "Noori Natt", EvictionType = EvictionType.Criminal }, new Eviction { CaseNumber = 302, Cnic = person.Cnic, CourtOrder = "14 saal qaid ba mushaqat", Date = new DateTime(1990, 1, 1), JudgeName = "Bala Gaddee ", EvictionType = EvictionType.Terrorism, }, }; var record = new PersonRecord(person, evictions); Records.Add(record); }
private List <PersonRecord> CreatePersons() { var person = new PersonRecord { PersonId = 1, Name = "greg", Title = "Supreme Coder", Description = "Nada", Notes = "foo bar" }; var person2 = new PersonRecord { PersonId = 2, Name = "Sam", Title = "Junior Coder", Description = "Nada", Notes = "foo bar" }; var list = new List <PersonRecord> { person, person2 }; return(list); }
public static bool CompareEquality(PersonRecord record1, PersonRecord record2) { return(record1 == record2); }
public string CreateDonationProduct(string personName, string surname, string email, string phone, string price, string productId) { var addressId = "11"; var sellingCompanyId = "1"; var organisationId = "1"; var person = new PersonRecord() { FirstName = personName, Surname = surname, HomeAddId = addressId }; this.Provider.DataProvider.Contact.Person.Create(person); var addedPerson = this.Provider.DataProvider.Contact.Person.FetchAll().OrderByDescending(x => x.AddDate).FirstOrDefault(); var role = new PersonRoleRecord() { PersonId = addedPerson.Id, Email = email, Phone = phone, SelcoSpId = sellingCompanyId, OrgId = organisationId, AddId = addressId }; this.Provider.DataProvider.Contact.Role.Create(role); var addedRole = this.Provider.DataProvider.Contact.Role.FetchAll().OrderByDescending(x => x.AddDate).FirstOrDefault(); var booking = new BookingRecord() { ProleId = addedRole.Id, InvOrgId = addedRole.OrgId, SelcoSpId = addedRole.SelcoSpId, PaymentMethd = "05-Cash", CurrencyType = "GBP", NetTotal = Convert.ToInt32(price), PersonId = addedRole.PersonId }; this.Provider.DataProvider.Learning.Booking.Create(booking); var addedBooking = this.Provider.DataProvider.Learning.Booking.FetchAll().OrderByDescending(x => x.AddDate).FirstOrDefault(); var donationProduct = this.Provider.DataProvider.Learning.Product.FetchById(productId); var delegateRecord = new DelegateRecord() { BookId = addedBooking.Id, OrgId = addedBooking.OrgId, PersonId = addedBooking.PersonId, ProleId = addedBooking.ProleId, ProductId = donationProduct.Id, Quantity = 1 }; this.Provider.DataProvider.Learning.Learner.Create(delegateRecord); var addedDelegate = this.Provider.DataProvider.Learning.Learner.FetchAll().OrderByDescending(x => x.AddDate).FirstOrDefault(); var element = new ElementRecord() { BookId = addedBooking.Id, PaymentMethd = "01-Invoice", ProdId = donationProduct.Id, SelcoSpId = sellingCompanyId, Type = 29, Price = Convert.ToInt32(price), Description = donationProduct.Descrip, CostCode = donationProduct.CostCode, Qty = 1, UntPrice = Convert.ToInt32(price), PlId = "1", DelId = addedDelegate.Id }; this.Provider.DataProvider.Learning.Element.Create(element); return("/learning/donationbooking?id=" + addedBooking.Id); }
public void setUp() { this.person = new PersonRecord("Jack", "Sparrow"); }
public MapPageViewModel(NavigationService navi, PersonRecord model) { NavigationService = navi; TopicsCommand = new TopicsCommand(); }
private void lvUsers_MouseMove(object sender, MouseEventArgs e) { ListViewItem test = (ListViewItem)sender; _hoverPerson = (PersonRecord)test.Content; }
public MatchPage(PersonRecord match, string matchedTopicName) { InitializeComponent(); BindingContext = new MatchViewModel(match, matchedTopicName); }
public void UpdatePerson(string token, PersonRecord record) { bool ok; try { ok = Identification(token); } catch (DatabaseConnectionException e) { ServiceData sd = new ServiceData(); sd.ErrorMessage = e.Message; throw new FaultException <ServiceData>(sd, new FaultReason(sd.ErrorMessage)); } catch (DatabaseCommandTextException e) { ServiceData sd = new ServiceData(); sd.ErrorMessage = e.Message; throw new FaultException <ServiceData>(sd, new FaultReason(sd.ErrorMessage)); } catch (DatabaseParameterException e) { ServiceData sd = new ServiceData(); sd.ErrorMessage = e.Message; throw new FaultException <ServiceData>(sd, new FaultReason(sd.ErrorMessage)); } if (ok) { try { personsManager.Update(record); } catch (DatabaseConnectionException e) { ServiceData sd = new ServiceData(); sd.ErrorMessage = e.Message; throw new FaultException <ServiceData>(sd, new FaultReason(sd.ErrorMessage)); } catch (DatabaseParameterException e) { ServiceData sd = new ServiceData(); sd.ErrorMessage = e.Message; throw new FaultException <ServiceData>(sd, new FaultReason(sd.ErrorMessage)); } //try //{ // refreshManager.UpdateLastTime(DateTime.Now); //} //catch (DatabaseConnectionException e) //{ // ServiceData sd = new ServiceData(); // sd.ErrorMessage = e.Message; // throw new FaultException<ServiceData>(sd, new FaultReason(sd.ErrorMessage)); //} //catch (DatabaseParameterException e) //{ // ServiceData sd = new ServiceData(); // sd.ErrorMessage = e.Message; // throw new FaultException<ServiceData>(sd, new FaultReason(sd.ErrorMessage)); //} } }
//3. create new public void InsertNewData(PersonRecord newRecord) { GrowDB db = new GrowDB(); db.InsertNewData(newRecord); }
public MatchViewModel(PersonRecord match, string matchedTopicName) : this() { }