public async Task <ActionResult> ProcessBulkUpdate(BulkUpdateViewModel viewModel)
        {
            viewModel.CanOverrideCRProcess = User.IsInRole(R.ROLE_BACKOFFICE);

            if (ModelState.IsValid)
            {
                var fileName = FileHelper.GetTempFileName(Path.GetExtension(viewModel.BulkFile.FileName));
                viewModel.BulkFile.SaveAs(fileName);

                if (new FileInfo(fileName).Length > 1000000)
                {
                    viewModel.Result = new Services.Domain.BulkUpdateProgressModel
                    {
                        Errors = new[] { new Services.Domain.ApiError {
                                             Code = "error.maxRowsLimitReached.payload.bulkUpload"
                                         } }
                    };
                }
                else
                {
                    var payload = new BulkUpdateDto
                    {
                        BulkFileType      = viewModel.BulkUpdateType.Value,
                        FileName          = fileName,
                        OverrideCRProcess = viewModel.CanOverrideCRProcess && viewModel.OverrideCRProcess
                    };

                    var state    = UriHelper.SerializeToUrlToken(payload);
                    var response = await _establishmentWriteService.BulkUpdateAsync(payload, User);

                    System.IO.File.Delete(fileName);

                    if (response.HasErrors)
                    {
                        viewModel.Result = new Services.Domain.BulkUpdateProgressModel
                        {
                            Errors = response.Errors
                        };
                    }
                    else
                    {
                        return(RedirectToAction(nameof(Result), new { response.GetResponse().Id, state }));
                    }
                }
            }

            return(View("Index", viewModel));
        }
        public async Task <ActionResult> ProcessBulkUpdate(BulkUpdateViewModel viewModel)
        {
            viewModel.CanOverrideCRProcess = User.IsInRole(AuthorizedRoles.IsAdmin);

            if (ModelState.IsValid)
            {
                var fileName = FileHelper.GetTempFileName(Path.GetExtension(viewModel.BulkFile.FileName));
                viewModel.BulkFile.SaveAs(fileName);

                if (new FileInfo(fileName).Length > 1000000)
                {
                    ModelState.AddModelError("BulkFile", "The file size is too large. Please use a file size smaller than 1MB");
                }
                else
                {
                    var payload = new BulkUpdateDto
                    {
                        BulkFileType      = viewModel.BulkUpdateType.Value,
                        FileName          = fileName,
                        OverrideCRProcess = viewModel.CanOverrideCRProcess && viewModel.OverrideCRProcess
                    };

                    var state    = UriHelper.SerializeToUrlToken(payload);
                    var response = await _establishmentWriteService.BulkUpdateAsync(payload, User);

                    System.IO.File.Delete(fileName);

                    if (response.HasErrors)
                    {
                        viewModel.Result = new Services.Domain.BulkUpdateProgressModel
                        {
                            Errors = response.Errors
                        };
                    }
                    else
                    {
                        return(RedirectToAction(nameof(Result), new { response.GetResponse().Id, state }));
                    }
                }
            }

            return(View("Index", viewModel));
        }