private PartialViewResult ViewDeleteGrantModificationFile(GrantModificationFileResource grantModificationFileResource, ConfirmDialogFormViewModel viewModel) { var confirmMessage = $"Are you sure you want to delete this \"{grantModificationFileResource.DisplayName}\" file created on '{grantModificationFileResource.FileResource.CreateDate}' by '{grantModificationFileResource.FileResource.CreatePerson.FullNameFirstLast}'?"; var viewData = new ConfirmDialogFormViewData(confirmMessage, true); return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel)); }
public void UpdateModel(Models.GrantModification grantModification, Person currentPerson, List <GrantModificationGrantModificationPurpose> allGrantModificationGrantModificationPurposes) { grantModification.GrantModificationName = GrantModificationName; grantModification.GrantModificationStatusID = GrantModificationStatusID; grantModification.GrantModificationStartDate = GrantModificationStartDate; grantModification.GrantModificationEndDate = GrantModificationEndDate; grantModification.GrantModificationDescription = GrantModificationDescription; grantModification.GrantID = GrantID; grantModification.GrantModificationAmount = GrantModificationAmount; if (GrantModificationFileResourceData?[0] != null) { var fileResources = GrantModificationFileResourceData.Select(fileData => FileResource.CreateNewFromHttpPostedFile(fileData, currentPerson)); foreach (var fileResource in fileResources) { HttpRequestStorage.DatabaseEntities.FileResources.Add(fileResource); var grantModificationFileResource = new GrantModificationFileResource(grantModification, fileResource, fileResource.OriginalCompleteFileName); grantModification.GrantModificationFileResources.Add(grantModificationFileResource); } } var existingRecordsToClear = HttpRequestStorage.DatabaseEntities.GrantModificationGrantModificationPurposes .Where(gmgmp => gmgmp.GrantModificationID == grantModification.GrantModificationID).ToList(); HttpRequestStorage.DatabaseEntities.GrantModificationGrantModificationPurposes.RemoveRange(existingRecordsToClear); var grantModificationPurposesUpdated = GrantModificationPurposeIDs.Select(x => new GrantModificationGrantModificationPurpose(grantModification.GrantModificationID, x)).ToList(); HttpRequestStorage.DatabaseEntities.GrantModificationGrantModificationPurposes.AddRange(grantModificationPurposesUpdated); }