public ActionResult Edit(ObligationRequestPrimaryKey obligationRequestPrimaryKey, EditObligationRequestViewModel viewModel) { if (!ModelState.IsValid) { var firmaPage = FirmaPageTypeEnum.ObligationRequestFromGridDialog.GetFirmaPage(); return(ViewEdit(viewModel, firmaPage)); } viewModel.UpdateModel(obligationRequestPrimaryKey.EntityObject, CurrentFirmaSession); if (viewModel.IsModification) { var obligationRequest = obligationRequestPrimaryKey.EntityObject; var agreement = HttpRequestStorage.DatabaseEntities.Agreements.Single(x => x.AgreementID == viewModel.AgreementID.Value); var costAuthorities = HttpRequestStorage.DatabaseEntities.CostAuthorities.ToList(); var agreementCostAuthorities = agreement.AgreementCostAuthorities; var listOfCostAuthorityIDs = agreementCostAuthorities.Select(x => x.CostAuthorityID).ToList(); var currentListOfCostAuthoritiesOnObligationRequest = obligationRequest .CostAuthorityObligationRequests .Select(x => x.CostAuthorityID).ToList(); foreach (var costAuthorityID in listOfCostAuthorityIDs) { if (!currentListOfCostAuthoritiesOnObligationRequest.Contains(costAuthorityID)) { var costAuthority = costAuthorities.Single(x => x.CostAuthorityID == costAuthorityID); var newCostAuthorityReclamationAgreement = new CostAuthorityObligationRequest(costAuthority, obligationRequest); obligationRequest.CostAuthorityObligationRequests.Add(newCostAuthorityReclamationAgreement); } } } HttpRequestStorage.DatabaseEntities.SaveChanges(); ExcelUploadController.DoObligationRequestMatching(obReqLogger); return(new ModalDialogFormJsonResult()); }
private ActionResult MakeTheNewObligationRequest(EditObligationRequestViewModel viewModel) { var contractType = HttpRequestStorage.DatabaseEntities.ContractTypes.Single(x => x.ContractTypeID == viewModel.ContractTypeID); var requestStatus = ObligationRequestStatus.AllLookupDictionary[viewModel.ObligationRequestStatusID]; var obligationRequestFromViewModel = new ObligationRequest(viewModel.IsModification, contractType, requestStatus, viewModel.DescriptionOfNeed, DateTime.Now, CurrentFirmaSession.Person); viewModel.UpdateModel(obligationRequestFromViewModel, CurrentFirmaSession); if (viewModel.IsModification) { var agreement = HttpRequestStorage.DatabaseEntities.Agreements.Single(x => x.AgreementID == viewModel.AgreementID.Value); var costAuthorities = HttpRequestStorage.DatabaseEntities.CostAuthorities.ToList(); var agreementCostAuthorities = agreement.AgreementCostAuthorities; var listOfCostAuthorityIDs = agreementCostAuthorities.Select(x => x.CostAuthorityID).ToList(); foreach (var costAuthorityID in listOfCostAuthorityIDs) { var costAuthority = costAuthorities.Single(x => x.CostAuthorityID == costAuthorityID); var newCostAuthorityReclamationAgreement = new CostAuthorityObligationRequest(costAuthority, obligationRequestFromViewModel); obligationRequestFromViewModel.CostAuthorityObligationRequests.Add(newCostAuthorityReclamationAgreement); } } HttpRequestStorage.DatabaseEntities.SaveChanges(); ExcelUploadController.DoObligationRequestMatching(obReqLogger); return(new ModalDialogFormJsonResult()); }
public ActionResult EditCostAuthorityObligationRequests(ObligationRequestPrimaryKey reclamationObligationRequestPrimaryKey, EditCostAuthorityObligationRequestsViewModel viewModel) { var reclamationObligationRequest = reclamationObligationRequestPrimaryKey.EntityObject; if (!ModelState.IsValid) { var firmaPage = FirmaPageTypeEnum.AddCostAuthorityToObligationRequest.GetFirmaPage(); return(ViewEditCostAuthorityObligationRequests(reclamationObligationRequest, viewModel, firmaPage)); } var listOfCostAuthorityIDs = viewModel.CostAuthorityJsonList.Select(x => x.CostAuthorityID).ToList(); var existingCostAuthorityObligationRequests = reclamationObligationRequest.CostAuthorityObligationRequests; foreach (var costAuthorityID in listOfCostAuthorityIDs) { var costAuthorityJson = viewModel.CostAuthorityJsonList.Single(x => x.CostAuthorityID == costAuthorityID); if (!existingCostAuthorityObligationRequests.Select(x => x.CostAuthorityID).Contains(costAuthorityID)) { var newCostAuthorityReclamationAgreement = new CostAuthorityObligationRequest(costAuthorityID, reclamationObligationRequest.ObligationRequestID) { ProjectedObligation = costAuthorityJson.ProjectedObligation , CostAuthorityObligationRequestNote = costAuthorityJson.Note , TechnicalRepresentativePersonID = costAuthorityJson.TechnicalRepresentativePersonID , RecipientOrganizationID = costAuthorityJson.RecipientOrganizationID , BudgetObjectCodeID = costAuthorityJson.BudgetObjectCodeID }; reclamationObligationRequest.CostAuthorityObligationRequests.Add(newCostAuthorityReclamationAgreement); } } HttpRequestStorage.DatabaseEntities.SaveChanges(); ExcelUploadController.DoObligationRequestMatching(obReqLogger); return(new ModalDialogFormJsonResult()); }
public ActionResult EditRequisitionInformation(ObligationRequestPrimaryKey obligationRequestPrimaryKey, EditRequisitionInformationViewModel viewModel) { if (!ModelState.IsValid) { return(ViewEditRequisitionInformation(viewModel)); } viewModel.UpdateModel(obligationRequestPrimaryKey.EntityObject, CurrentFirmaSession); HttpRequestStorage.DatabaseEntities.SaveChanges(); ExcelUploadController.DoObligationRequestMatching(obReqLogger); return(new ModalDialogFormJsonResult()); }
public ActionResult EditCostAuthorityObligationRequest(CostAuthorityObligationRequestPrimaryKey costAuthorityObligationRequestPrimaryKey, EditCostAuthorityObligationRequestViewModel viewModel) { if (!ModelState.IsValid) { var firmaPage = FirmaPageTypeEnum.ObligationRequestFromGridDialog.GetFirmaPage(); return(ViewEditCostAuthorityObligationRequest(costAuthorityObligationRequestPrimaryKey.EntityObject, viewModel, firmaPage)); } viewModel.UpdateModel(costAuthorityObligationRequestPrimaryKey.EntityObject, CurrentFirmaSession); HttpRequestStorage.DatabaseEntities.SaveChanges(); ExcelUploadController.DoObligationRequestMatching(obReqLogger); return(new ModalDialogFormJsonResult()); }
public ActionResult ConfirmPotentialMatch(CostAuthorityObligationRequestPotentialObligationNumberMatchPrimaryKey costAuthorityObligationRequestPotentialObligationNumberMatchPrimaryKey, PotentialMatchInformationViewModel viewModel) { var matchToConfirm = costAuthorityObligationRequestPotentialObligationNumberMatchPrimaryKey.EntityObject; var obligationRequest = matchToConfirm.CostAuthorityObligationRequest.ObligationRequest; obligationRequest.ObligationNumberID = matchToConfirm.ObligationNumberID; HttpRequestStorage.DatabaseEntities.SaveChanges(this.CurrentFirmaSession); ExcelUploadController.DoObligationRequestMatching(obReqLogger); SetMessageForDisplay($"Confirmed match for Obligation {obligationRequest.ObligationNumber.GetDetailLink()}"); return(new ModalDialogFormJsonResult()); }
public ActionResult ConfirmObligationRequestUnmatch(ObligationRequestPrimaryKey obligationRequestPrimaryKey, ConfirmObligationRequestUnmatchViewModel viewModel) { ObligationRequest obligationRequest = obligationRequestPrimaryKey.EntityObject; var previouslyMatchedObligation = obligationRequest.ObligationNumber; obligationRequest.ObligationNumber = null; obligationRequest.ObligationNumberID = null; obligationRequest.Agreement = null; obligationRequest.AgreementID = null; HttpRequestStorage.DatabaseEntities.SaveChanges(this.CurrentFirmaSession); ExcelUploadController.DoObligationRequestMatching(obReqLogger); SetMessageForDisplay($"Unmatched Obligation Request {obligationRequest.GetDetailLink()} from Obligation {previouslyMatchedObligation.GetDetailLink()}"); return(new ModalDialogFormJsonResult()); }
public ActionResult Delete(ObligationRequestPrimaryKey obligationRequestPrimaryKey, ConfirmDialogFormViewModel viewModel) { var obligationRequest = obligationRequestPrimaryKey.EntityObject; var displayName = $"Obligation Request: {obligationRequest.GetObligationRequestNumber()}"; if (!ModelState.IsValid) { return(ViewDelete(obligationRequest, viewModel)); } obligationRequest.DeleteFull(HttpRequestStorage.DatabaseEntities); ExcelUploadController.DoObligationRequestMatching(obReqLogger); SetMessageForDisplay($"Successfully deleted \"{displayName}\"."); return(new ModalDialogFormJsonResult()); }
public ActionResult DeleteCostAuthority(CostAuthorityObligationRequestPrimaryKey costAuthorityObligationRequestPrimaryKey, ConfirmDialogFormViewModel viewModel) { var costAuthorityObligationRequest = costAuthorityObligationRequestPrimaryKey.EntityObject; var displayName = $"this Projected Obligation from Cost Authority: {costAuthorityObligationRequest.CostAuthority.CostAuthorityWorkBreakdownStructure}"; if (!ModelState.IsValid) { return(ViewDeleteCostAuthority(costAuthorityObligationRequest, viewModel)); } costAuthorityObligationRequest.DeleteFull(HttpRequestStorage.DatabaseEntities); ExcelUploadController.DoObligationRequestMatching(obReqLogger); SetMessageForDisplay($"Successfully deleted \"{displayName}\"."); return(new ModalDialogFormJsonResult()); }