public virtual ActionResult FileUpload(int authenticationType, HttpPostedFileBase excelFile) { try { if (excelFile == null) { return(Json(new { IsError = true, Message = "خطا در انتخاب فایل" })); } var savetoPath = Server.MapPath("~/App_Data/"); var data = _fileManagementService.FileUpload(excelFile, savetoPath); if (data.Item1) { var listAuthentication = _fileManagementService.GetExcelContent(Path.Combine(savetoPath, excelFile.FileName)); //مشخص کردن سطح رکورد احراز هویت بر اساس سطح مربوط به کاربر لاگین شده AuthenticationType authen = (AuthenticationType)authenticationType; AuthenticationType userAuthenticationType = (AuthenticationType)Enum.Parse(typeof(AuthenticationType), User.AuthenType(), true); long levelId = Convert.ToInt64(User.LevelId()); var listAuthen = new List <AuthenticationModel>(); for (int i = 0; i <= listAuthentication.Rows.Count - 1; i++) { AuthenticationModel authentication = new AuthenticationModel { IdentityCode = listAuthentication.Rows[i][0].ToString(), AuthenticationType = authen }; if (userAuthenticationType == AuthenticationType.AdminCentral) { authentication.CentralOrganizationId = levelId; } else if (userAuthenticationType == AuthenticationType.AdminCentral) { authentication.BranchProvinceId = levelId; } else { authentication.UniversityId = levelId; } listAuthen.Add(authentication); } var lstAllAuthentication = _roleManagementService.GetAllAuthentication(userAuthenticationType, levelId) .Select(s => new AuthenticationModel { IdentityCode = s.IdentityCode, AuthenticationType = s.AuthenticationType }).ToList(); var listNewAuthentication = listAuthen.Except(lstAllAuthentication, new AuthenticationComparer()).ToList(); data = _roleManagementService.AddListAuthentication(listNewAuthentication, StateOperation.درج); return(Json(new { IsError = !data.Item1, Message = data.Item2 })); } return(Json(new { IsError = true, Message = data.Item2 })); } catch (Exception ex) { return(Json(new { IsError = true, Message = "خطا در انتقال کاربران" })); } }