Esempio n. 1
0
        protected override void DeleteChildEntities(string[] childEntityList, string parentID)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */

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

                case "AssetAttachments":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        AssetAttachmentsLibrary        library    = new AssetAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <AssetAttachments> resultList = library.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (AssetAttachments entity in resultList)
                        {
                            library.Delete(entity.ID.ToString());
                        }
                    }
                    break;
                }
                #endregion /* Case Statements - All child grids */
            }
        }
Esempio n. 2
0
        protected override void SaveChildEntities(string[] childEntityList, Asset entity)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */
                case "AssetAudit":
                    if (Session[ChildEntity] != null)
                    {
                        ILibrary <AssetAudit>    lib        = new AssetAuditLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <AssetAudit> resultList = (IList <AssetAudit>)Session[ChildEntity];
                        foreach (AssetAudit result in resultList)
                        {
                            result.Asset = new Asset()
                            {
                                ID = entity.ID
                            };
                            lib.Add(result);
                        }
                    }
                    break;

                case "AssetAttachments":
                    if (Session[ChildEntity] != null)
                    {
                        AssetAttachmentsLibrary        lib        = new AssetAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <AssetAttachments> resultList = (IList <AssetAttachments>)Session[ChildEntity];
                        string      destinationPath;
                        string      sourcePath;
                        FilelHelper fileHelper = new FilelHelper();
                        foreach (AssetAttachments result in resultList)
                        {
                            destinationPath      = fileHelper.GetSourceDirByFileRefId(result.Document_RefId.ToString());
                            sourcePath           = fileHelper.GetTempSourceDirByFileRefId(result.Document_RefId.ToString());
                            result.Document_Path = fileHelper.GetFilePath(sourcePath);
                            fileHelper.MoveFile(result.Document_Name, sourcePath, destinationPath);
                            result.Parent = new Asset {
                                ID = entity.ID
                            };
                            lib.Add(result);
                        }
                    }
                    break;

                    #endregion
                }
            }
        }