コード例 #1
0
ファイル: LegalEntityClass.cs プロジェクト: afitzy111/Trade
 //Create new legal entity
 public void CreateLegalEntity(LegalEntity legalEntity)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         if (legalEntity == null)
         {
             context.LegalEntities.Add(legalEntity);
             context.SaveChanges();
         }
     }
 }
コード例 #2
0
        //Method to retrieve a single Legal Entity
        public LegalEntity GetSingleLegalEntity(int id)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                LegalEntity LegalEntityToFind = (from l in context.LegalEntities
                                                 where l.id == id
                                                 select l).FirstOrDefault();

                return(LegalEntityToFind);
            }
        }
コード例 #3
0
ファイル: LegalEntityClass.cs プロジェクト: afitzy111/Trade
        //Method to retrieve a single Legal Entity
        public LegalEntity GetSingleLegalEntity(int id)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                LegalEntity LegalEntityToFind = (from l in context.LegalEntities
                                                 where l.id == id
                                                 select l).FirstOrDefault();

                return LegalEntityToFind;
            }
        }
コード例 #4
0
 //Method to create a new address
 public void CreateAddress(Address address)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         if (address == null)
         {
             context.Addresses.Add(address);
             context.SaveChanges();
         }
     }
 }
コード例 #5
0
 //Create new legal entity
 public void CreateLegalEntity(LegalEntity legalEntity)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         if (legalEntity == null)
         {
             context.LegalEntities.Add(legalEntity);
             context.SaveChanges();
         }
     }
 }
コード例 #6
0
ファイル: AddressClass.cs プロジェクト: afitzy111/Trade
 //Method to create a new address
 public void CreateAddress(Address address)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         if (address == null)
         {
             context.Addresses.Add(address);
             context.SaveChanges();
         }
     }
 }
コード例 #7
0
        //Method to retrieve a single address
        public Address GetSingleAddress(int id)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                /* Address addressToFind = (from a in context.Addresses
                 *                        where a.ID == id
                 *                        select a).FirstOrDefault();*/
                Address addressToFind = context.Addresses.First(a => a.ID == id);

                return(addressToFind);
            }
        }
コード例 #8
0
 //Retrieve all addresses method
 public List <Address> GetAddresses()
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         List <Address> allAddresses = new List <Address>();
         foreach (Address a in context.Addresses)
         {
             allAddresses.Add(a);
         }
         return(allAddresses);
     }
 }
コード例 #9
0
ファイル: AddressClass.cs プロジェクト: afitzy111/Trade
        //Method to retrieve a single address
        public Address GetSingleAddress(int id)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                /* Address addressToFind = (from a in context.Addresses
                                          where a.ID == id
                                          select a).FirstOrDefault();*/
               Address addressToFind = context.Addresses.First(a => a.ID == id);

                return addressToFind;
            }
        }
コード例 #10
0
ファイル: AddressClass.cs プロジェクト: afitzy111/Trade
 //Retrieve all addresses method
 public List<Address> GetAddresses()
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         List<Address> allAddresses = new List<Address>();
         foreach (Address a in context.Addresses)
         {
             allAddresses.Add(a);
         }
         return allAddresses;
     }
 }
コード例 #11
0
 //Retrieve all Legal Entities method
 public List <LegalEntity> GetLegalEntities()
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         List <LegalEntity> allLegalEntities = new List <LegalEntity>();
         foreach (LegalEntity l in context.LegalEntities)
         {
             allLegalEntities.Add(l);
         }
         return(allLegalEntities);
     }
 }
コード例 #12
0
ファイル: LegalEntityClass.cs プロジェクト: afitzy111/Trade
 //Retrieve all Legal Entities method
 public List<LegalEntity> GetLegalEntities()
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         List<LegalEntity> allLegalEntities = new List<LegalEntity>();
         foreach (LegalEntity l in context.LegalEntities)
         {
             allLegalEntities.Add(l);
         }
         return allLegalEntities;
     }
 }
コード例 #13
0
ファイル: LegalEntityClass.cs プロジェクト: afitzy111/Trade
 //Method to delete a Legal Entity
 public void DeleteLegalEntity(int id)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         LegalEntity legalEntityToDelete = (from l in context.LegalEntities
                                    where l.id == id
                                    select l).FirstOrDefault();
         if (legalEntityToDelete != null)
         {
             context.LegalEntities.Remove(legalEntityToDelete);
             context.SaveChanges();
         }
     }
 }
コード例 #14
0
 //Method to delete an address
 public void DeleteAddress(int id)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         Address addressToDelete = (from a in context.Addresses
                                    where a.ID == id
                                    select a).FirstOrDefault();
         if (addressToDelete != null)
         {
             context.Addresses.Remove(addressToDelete);
             context.SaveChanges();
         }
     }
 }
コード例 #15
0
 //Method to delete a Legal Entity
 public void DeleteLegalEntity(int id)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         LegalEntity legalEntityToDelete = (from l in context.LegalEntities
                                            where l.id == id
                                            select l).FirstOrDefault();
         if (legalEntityToDelete != null)
         {
             context.LegalEntities.Remove(legalEntityToDelete);
             context.SaveChanges();
         }
     }
 }
コード例 #16
0
ファイル: AddressClass.cs プロジェクト: afitzy111/Trade
 //Method to delete an address
 public void DeleteAddress(int id)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         Address addressToDelete = (from a in context.Addresses
                                    where a.ID == id
                                    select a).FirstOrDefault();
         if (addressToDelete != null)
         {
             context.Addresses.Remove(addressToDelete);
             context.SaveChanges();
         }
     }
 }
コード例 #17
0
ファイル: LegalEntityClass.cs プロジェクト: afitzy111/Trade
        //Method to update an existing legal entity
        public void UpdateLegalEntity(int id, LegalEntity newLegalEntity)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                LegalEntity legalEntityToUpdate = (from l in context.LegalEntities
                                           where l.id == id
                                           select l).FirstOrDefault();
                if (newLegalEntity != null)
                {
                    legalEntityToUpdate.Name = legalEntityToUpdate.Name;
                    legalEntityToUpdate.Address = legalEntityToUpdate.Address;

                    context.SaveChanges();
                }
            }
        }
コード例 #18
0
        //Method to update an existing legal entity
        public void UpdateLegalEntity(int id, LegalEntity newLegalEntity)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                LegalEntity legalEntityToUpdate = (from l in context.LegalEntities
                                                   where l.id == id
                                                   select l).FirstOrDefault();
                if (newLegalEntity != null)
                {
                    legalEntityToUpdate.Name    = legalEntityToUpdate.Name;
                    legalEntityToUpdate.Address = legalEntityToUpdate.Address;

                    context.SaveChanges();
                }
            }
        }
コード例 #19
0
ファイル: AddressClass.cs プロジェクト: afitzy111/Trade
        //Method to update an existing address
        public void UpdateAddress(int id, Address newAddress)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                Address addressToUpdate = (from a in context.Addresses
                                           where a.ID == id
                                           select a).FirstOrDefault();
                if (newAddress != null)
                {
                    addressToUpdate.Line_1 = newAddress.Line_1;
                    addressToUpdate.Line_2 = newAddress.Line_2;
                    addressToUpdate.Line_3 = newAddress.Line_3;
                    addressToUpdate.City = newAddress.City;
                    addressToUpdate.Country = newAddress.Country;
                    addressToUpdate.Postcode = newAddress.Postcode;

                    context.SaveChanges();
                }
            }
        }
コード例 #20
0
        //Method to update an existing address
        public void UpdateAddress(int id, Address newAddress)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                Address addressToUpdate = (from a in context.Addresses
                                           where a.ID == id
                                           select a).FirstOrDefault();
                if (newAddress != null)
                {
                    addressToUpdate.Line_1   = newAddress.Line_1;
                    addressToUpdate.Line_2   = newAddress.Line_2;
                    addressToUpdate.Line_3   = newAddress.Line_3;
                    addressToUpdate.City     = newAddress.City;
                    addressToUpdate.Country  = newAddress.Country;
                    addressToUpdate.Postcode = newAddress.Postcode;

                    context.SaveChanges();
                }
            }
        }