Exemplo n.º 1
0
        public void DeleteCompanyContact(Contact contact)
        {
            if (contact == null)
            {
                throw new ArgumentNullException(nameof(contact));
            }

            _context.Contact.Remove(contact);

            //remove the company assignment
            CompanyContacts companyContacts = new CompanyContacts();

            companyContacts.ContactId = contact.Id;
            DeleteCompanyContactsAssignment(companyContacts);

            //remove the site assignment
            SiteContacts siteContacts = new SiteContacts();

            siteContacts.ContactId = contact.Id;
            DeleteSiteContactsAssignment(siteContacts);

            //remove the terminal assignment
            TerminalContacts terminalContacts = new TerminalContacts();

            terminalContacts.ContactId = contact.Id;
            DeleteTerminalContactsAssignment(terminalContacts);
        }
Exemplo n.º 2
0
        public SiteContacts GetCompanySiteContact(Guid companyId, Guid siteId, Guid contactId)
        {
            SiteContacts contact = new SiteContacts();

            if (siteId == null || contactId == null)
            {
                throw new ArgumentNullException(nameof(GetCompanySiteContact));
            }

            var siteContact = (from c in _context.Company
                               join con in _context.Contact on c.Id equals con.CompanyId
                               join sc in _context.SiteContacts on con.Id equals sc.ContactId
                               join s in _context.Site on sc.SiteId equals s.Id
                               where con.Id == contactId || sc.SiteId == siteId
                               select new { s.Id, sc.ContactId, s.SiteName, con.FirstName, con.LastName, con.Title, con.CountryCode, con.Phone, con.Mobile, con.Fax, con.Email });

            foreach (var item in siteContact)
            {
                contact.SiteId    = item.Id;
                contact.ContactId = item.ContactId;

                /* contact.FirstName = item.FirstName;
                 * contact.LastName = item.LastName;
                 * contact.Title = item.Title;
                 * contact.CountryCode = item.CountryCode;
                 * contact.Phone = item.Phone;
                 * contact.Mobile = item.Mobile;
                 * contact.Fax = item.Fax;
                 * contact.Email = item.Email; */
            }
            return(contact);
        }
Exemplo n.º 3
0
        public void CreateCompanySiteContact(SiteContacts SiteContacts)
        {
            if (SiteContacts == null)
            {
                throw new ArgumentNullException(nameof(SiteContacts));
            }

            _context.SiteContacts.Add(SiteContacts);
        }
Exemplo n.º 4
0
        public void DeleteSiteContactsAssignment(SiteContacts siteContacts)
        {
            if (siteContacts == null)
            {
                throw new ArgumentNullException(nameof(siteContacts));
            }

            _context.SiteContacts.Remove(siteContacts);
        }
Exemplo n.º 5
0
        public void CreateSiteContactsAssignment(SiteContacts siteContacts)
        {
            if (siteContacts == null)
            {
                throw new ArgumentNullException(nameof(siteContacts));
            }

            _context.SiteContacts.Add(siteContacts);
        }