Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- using System.Data.Entity;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Db.Model
- {
- public class Consumer : INotifyPropertyChanged
- {
- private String name;
- private String address;
- private ICollection<Meter> meters = new List<Meter>();
- [Key]
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int Id { get; set; }
- public String Name {
- get { return this.name; }
- set {
- if(this.name == value) { return; }
- this.name = value;
- Notify("Name");
- }
- }
- public String Address {
- get { return address; }
- set
- {
- if(this.address == value) { return; }
- this.address = value;
- Notify("Address");
- }
- }
- public ICollection<Meter> Meters {
- get { return meters; }
- set
- {
- this.meters = value;
- Notify("Meters");
- }
- }
- public Consumer() {
- }
- public Consumer(String name, String address)
- {
- Name = name;
- Address = address;
- }
- public event PropertyChangedEventHandler PropertyChanged;
- protected void Notify(String propName)
- {
- if (this.PropertyChanged != null)
- {
- PropertyChanged(this, new PropertyChangedEventArgs(propName));
- }
- }
- public override string ToString()
- {
- return Id + "\t" + Name + "\t\t\t" + Address + "\tMeters: " + Meters.Count;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement