Exemplo n.º 1
0
 public void Add(ref classes.Client item)
 {
     DAL_DB.Client clientDB = Mapper.Map <DAL_DB.Client>(item);
     context.Client.Add(clientDB);
     context.SaveChanges();
     item.ClientID = clientDB.ClientID;
 }
Exemplo n.º 2
0
 public void Update(classes.Client client)
 {
     DAL_DB.Client clientDB = context.Client.First(clnt => clnt.ClientID == client.ClientID);
     clientDB.Organization = client.Organization;
     clientDB.Adress       = client.Adress;
     clientDB.Telephone    = client.Telephone;
     clientDB.Fax          = client.Fax;
     clientDB.PostIndex    = client.PostIndex;
     clientDB.BankAccount  = client.BankAccount;
 }
Exemplo n.º 3
0
        public void Delete(classes.Client item)
        {
            DAL_DB.Client          clientDB = Mapper.Map <DAL_DB.Client>(item);
            List <DAL_DB.Contract> clients  = new List <DAL_DB.Contract>(context.Contract.Cast <DAL_DB.Contract>());

            foreach (DAL_DB.Contract contract in clients)
            {
                if (contract.ClientID == clientDB.ClientID)
                {
                    foreach (DAL_DB.Building bld in contract.Building.ToArray())
                    {
                        context.Building.Remove(bld);
                    }
                    context.Contract.Remove(contract);
                }
            }
            context.Client.Remove(context.Client.First(clnt => clnt.ClientID == clientDB.ClientID));
            context.SaveChanges();
        }