public ActionResult DeleteNewFile(string Id)
        {
            //RBACUser rUser = new RBACUser(Session["UserName"].ToString());
            //if (!rUser.HasPermission("NewFile_Delete"))
            //{
            //    return Json("D", JsonRequestBehavior.AllowGet);
            //}
            try
            {
                using (var transaction = new TransactionScope())
                {
                    var IsExits      = _fileMainService.All().Where(x => x.FileNo == Id).Select(x => x.MainID).FirstOrDefault();
                    var IsFileDetail = _fileDetailService.All().Where(x => x.MainID == IsExits).ToList();
                    // var ExistFD = _fileDetailService.All().ToList().Where(x => x.MainID == MainID);
                    if (IsFileDetail != null)
                    {
                        foreach (var item in IsFileDetail)
                        {
                            _fileDetailService.Delete(item);
                        }
                        _fileMainService.Save();
                    }
                    var IsUserBr = _fileMainService.All().Where(x => x.FileNo == Id).FirstOrDefault();

                    if (IsUserBr != null)
                    {
                        //For user branch table by Farhad
                        _fileMainService.Delete(IsUserBr);
                        _fileMainService.Save();
                        transaction.Complete();
                    }
                    else
                    {
                        return(Json("2", JsonRequestBehavior.AllowGet));
                    }
                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(Json("0", JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult ClosetoArchive(string FileNo)
        {
            //RBACUser rUser = new RBACUser(Session["UserName"].ToString());
            //if (!rUser.HasPermission("NewFile_Delete"))
            //{
            //    return Json("D", JsonRequestBehavior.AllowGet);
            //}
            using (var transaction = new TransactionScope())
            {
                try
                {
                    var FileMainNo = _fileMainService.All().Where(x => x.FileNo == FileNo).FirstOrDefault();
                    if (FileMainNo != null)
                    {
                        //For filemain and afilemain by Anna
                        var aFileMain = new AFileMain();
                        aFileMain.FileNo      = FileMainNo.FileNo;
                        aFileMain.FileRef     = FileMainNo.FileRef;
                        aFileMain.FileSub     = FileMainNo.FileSub;
                        aFileMain.FileText    = FileMainNo.FileText;
                        aFileMain.LastUpdDate = FileMainNo.LastUpdDate;
                        aFileMain.UpdUserID   = Convert.ToInt32(FileMainNo.UpdUserID);
                        aFileMain.UserID      = FileMainNo.UserID;
                        aFileMain.VersionNo   = FileMainNo.VersionNo;
                        aFileMain.CreateDate  = FileMainNo.CreateDate;
                        aFileMain.AttachNum   = FileMainNo.AttachNum;
                        _afileMainService.Add(aFileMain);
                        _afileMainService.Save();


                        _fileMainService.Delete(FileMainNo);
                        _fileMainService.Save();
                    }
                    //var FileDetailNo = _fileDetailService.All().Where(x => x.MainID == FileNo).FirstOrDefault();
                    //if (FileDetailNo != null)
                    //{
                    //    var aFileDetail = new AFileDetail();
                    //    aFileDetail.AttachFileName = FileDetailNo.AttachFileName;
                    //    aFileDetail.FileNo = FileDetailNo.MainID;
                    //    aFileDetail.FileSourcePath = FileDetailNo.FileSourcePath;
                    //    aFileDetail.FileType = FileDetailNo.FileType;
                    //    aFileDetail.Size = FileDetailNo.Size;

                    //    _afileDetailService.Add(aFileDetail);
                    //    _afileDetailService.Save();

                    //    _fileDetailService.Delete(FileDetailNo);
                    //    _fileDetailService.Save();
                    //    transaction.Complete();
                    //}
                    //else
                    //{
                    //    return Json("2", JsonRequestBehavior.AllowGet);
                    //}
                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
                catch (Exception)
                {
                    return(Json("0", JsonRequestBehavior.AllowGet));
                }
            }
        }