예제 #1
0
        protected override void SaveChildEntities(string[] childEntityList, Party entity)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */
                case "AddressBook":
                    if (Session[ChildEntity] != null)
                    {
                        ILibrary <AddressBook>    contactLibrary = new AddressBookLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <AddressBook> resultList     = (IList <AddressBook>)Session[ChildEntity];
                        //if (resultList.Count() == 1 || resultList.Count(o => o.Primary_Flag == true) <= 0)
                        //  resultList.FirstOrDefault().Primary_Flag = true;

                        foreach (AddressBook contact in resultList)
                        {
                            contact.Party = new Party()
                            {
                                ID = entity.ID
                            };
                            contactLibrary.Add(contact);
                        }
                    }
                    break;

                case "Bank":
                    if (Session[ChildEntity] != null)
                    {
                        ILibrary <Bank>    contactLibrary = new BankLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Bank> resultList     = (IList <Bank>)Session[ChildEntity];
                        foreach (Bank contact in resultList)
                        {
                            contact.Party = new Party()
                            {
                                ID = entity.ID
                            };
                            contactLibrary.Add(contact);
                        }
                    }
                    break;

                case "Bin":
                    if (Session[ChildEntity] != null)
                    {
                        ILibrary <Bin>    contactLibrary = new BinLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Bin> resultList     = (IList <Bin>)Session[ChildEntity];
                        foreach (Bin contact in resultList)
                        {
                            contact.Party = new Party()
                            {
                                ID = entity.ID
                            };
                            contactLibrary.Add(contact);
                        }
                    }
                    break;

                case "Contact":
                    if (Session[ChildEntity] != null)
                    {
                        ILibrary <Contact>    contactLibrary = new ContactLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Contact> resultList     = (IList <Contact>)Session[ChildEntity];
                        foreach (Contact contact in resultList)
                        {
                            contact.Party = new Party()
                            {
                                ID = entity.ID
                            };
                            contactLibrary.Add(contact);
                        }
                    }
                    break;

                case "Note":
                    if (Session[ChildEntity] != null)
                    {
                        ILibrary <Note>    contactLibrary = new NoteLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Note> resultList     = (IList <Note>)Session[ChildEntity];
                        foreach (Note contact in resultList)
                        {
                            contact.Party = new Party()
                            {
                                ID = entity.ID
                            };
                            contactLibrary.Add(contact);
                        }
                    }
                    break;

                    #endregion
                }
            }
        }
예제 #2
0
        protected override void DeleteChildEntities(string[] childEntityList, string parentID)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */

                case "AddressBook":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        AddressBookLibrary        library    = new AddressBookLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <AddressBook> resultList = library.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (AddressBook entity in resultList)
                        {
                            library.Delete(entity.ID.ToString());
                        }
                    }
                    break;

                case "Bank":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        BankLibrary        library    = new BankLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Bank> resultList = library.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (Bank entity in resultList)
                        {
                            library.Delete(entity.ID.ToString());
                        }
                    }
                    break;

                case "Bin":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        BinLibrary        lib        = new BinLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Bin> resultList = lib.GetAllByParentID(Convert.ToInt32(parentID));

                        foreach (Bin bin in resultList)
                        {
                            lib.Delete(bin.ID.ToString());
                        }
                    }
                    break;

                case "Contact":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        ContactLibrary        lib        = new ContactLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Contact> resultList = lib.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (Contact contact in resultList)
                        {
                            lib.Delete(contact.ID.ToString());
                        }
                    }
                    break;

                case "Note":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        NoteLibrary        lib        = new NoteLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Note> resultList = lib.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (Note note in resultList)
                        {
                            lib.Delete(note.ID.ToString());
                        }
                    }
                    break;
                    #endregion
                }
            }
        }