/// <summary>
        /// Save and Update AuthRepDoc Deatail
        /// </summary>
        /// <param name="listAuthRepDocDetails"></param>
        /// <param name="listAuthRepDocument"></param>
        public void SaveAndUpdateAuthRepDocDetails(IList<AuthRepDocDetailDTO> listAuthRepDocDetails, 
            IList<AuthRepDocumentsDTO> listAuthRepDocument)
        {
            using (TransactionScope transactionScope = new TransactionScope())
            {
                for (int i = 0; i < listAuthRepDocDetails.Count; i++)
                {
                    authrepdocdetail authrepdocdetailEntity = new authrepdocdetail();

                    AuthRepDocDetailDTO authRepDocDetails = GetAuthRepDocDetailsByAuthRepIdAndDocId(
                        listAuthRepDocDetails[i].AuthRep_Doc_AuthId, listAuthRepDocDetails[i].AuthRep_Doc_DocId);

                    if (authRepDocDetails.AuthRep_Doc_AuthId > 0)
                    {
                        AutoMapper.Mapper.Map(authRepDocDetails, authrepdocdetailEntity);

                        authrepdocdetailEntity.AuthRep_Doc_DocNo = listAuthRepDocDetails[i].AuthRep_Doc_DocNo;
                        authrepdocdetailEntity.AuthRep_Doc_FileName = listAuthRepDocDetails[i].AuthRep_Doc_FileName;
                        authrepdocdetailEntity.AuthRep_Doc_ExDate = listAuthRepDocDetails[i].AuthRep_Doc_ExDate;
                        ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocdetail>>().Update(authrepdocdetailEntity);
                    }
                    else
                    {
                        AutoMapper.Mapper.Map(listAuthRepDocDetails[i], authrepdocdetailEntity);
                        ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocdetail>>().Save(authrepdocdetailEntity);
                    }

                    AuthRepDocumentsDTO authRepDocument = GetAuthRepDocDetailsByDocId(authrepdocdetailEntity.AuthRep_Doc_Id);
                    authrepdocument authrepdocumentEntity = new authrepdocument();

                    if (authRepDocument.AuthRepDoc_Id > 0)
                    {
                        AutoMapper.Mapper.Map(authRepDocument, authrepdocumentEntity);

                        if (listAuthRepDocument[i].AuthRepDoc_File == null)
                        {
                            authrepdocdetailEntity.AuthRep_Doc_IsDeleted = true;
                        }
                        else
                        {
                            authrepdocumentEntity.AuthRepDoc_File = listAuthRepDocument[i].AuthRepDoc_File;
                        }

                        ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocument>>().Update(authrepdocumentEntity);
                    }
                    else
                    {
                        AutoMapper.Mapper.Map(listAuthRepDocument[i], authrepdocumentEntity);

                        authrepdocumentEntity.AuthRepDoc_Doc_Id = authrepdocdetailEntity.AuthRep_Doc_Id;

                        ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocument>>().Save(authrepdocumentEntity);
                    }
                }
                
                transactionScope.Complete();
            }
        }
        /// <summary>
        /// Delete Auth Rep Doc Details
        /// </summary>
        /// <param name="authRepDocs"></param>
        private static void DeleteAuthRepDocDetails(AuthRepDocDetailDTO authRepDocs)
        {
            authrepdocdetail authRepDocEntity = new authrepdocdetail();
            AutoMapper.Mapper.Map(authRepDocs, authRepDocEntity);

            ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocdetail>>().Update(authRepDocEntity);
        }