public async Task <IActionResult> Create(InvestmentFormViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                viewModel.CreatedById = user.Id;

                _investmentRepository.AddVer(viewModel.MapToInvestmentModelVer());
                _toastNotification.AddSuccessToastMessage("Element has been Created successfully.");

                _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Add, "Definitions > Economic Indicators > Investment > Add", " Id :" + viewModel.Id);

                return(RedirectToAction(nameof(Index)));
            }
            FormCommon();
            return(View(viewModel));
        }
        private IActionResult EditInvetment(InvestmentFormViewModel viewModel, out int id, bool fromDelete = false)
        {
            var invetmentVersion = _investmentRepository.GetByInvetmentId(viewModel.Investmentid ?? 0);
            var investmentById   = _investmentRepository.GetVerById(viewModel.Id);

            invetmentVersion = investmentById == null ? invetmentVersion : investmentById;
            var invementVersionModel = viewModel.MapToInvestmentModelVer();

            invementVersionModel.InvestmentsId = viewModel.Investmentid > 0 ? viewModel.Investmentid : (int?)null;
            if (!fromDelete)
            {
                invementVersionModel.ChangeActionEnum = ChangeActionEIEnum.Update;
                invementVersionModel.isDeleted        = false;
            }
            else
            {
                invementVersionModel.ChangeActionEnum = ChangeActionEIEnum.Delete;
            }
            if (invetmentVersion == null || invementVersionModel.VersionStatusEnum == VersionStatusEIEnum.Approved || invementVersionModel.VersionStatusEnum == VersionStatusEIEnum.Ignored)
            {
                invementVersionModel.VersionStatusEnum = VersionStatusEIEnum.Draft;
                invementVersionModel.Id = 0;
                var user = _userManager.GetUserAsync(HttpContext.User);
                invementVersionModel.CreatedById = user.Result.Id;


                _investmentRepository.AddVer(invementVersionModel);
                _toastNotification.AddSuccessToastMessage(ToasrMessages.EditSuccess);
                id = invementVersionModel.Id;
                return(RedirectToAction(nameof(Index)));
            }

            invementVersionModel.Id = invetmentVersion != null ? invetmentVersion.Id : viewModel.Id;

            _investmentRepository.UpdateVer(invementVersionModel);
            id = invementVersionModel.Id;

            _toastNotification.AddSuccessToastMessage("Element has been Edited successfully.");

            _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Update, "Definitions > Economic Indicators > Investment > Edit", " Id :" + viewModel.Id);

            return(RedirectToAction(nameof(Index)));
        }