public ActionResult InstructionAdd(InstructionViewModel viewModel) { if (ValidateContactsModel()) { ModelState.Clear(); var itemToValidate = viewModel.LenderInstructions.SingleOrDefault(e => e.IsEditable); if (itemToValidate != null) { if (!viewModel.LenderInstructions.Any(i => string.IsNullOrWhiteSpace(i.Text))) { ViewBag.NotificationMessage = itemToValidate.IsNew ? Constants.Notifications.InstructionSaved : Constants.Notifications.InstructionUpdated; _clientCompanyLetterService.SaveInstruction(itemToValidate, viewModel.CompanyId); itemToValidate.IsEditable = false; CommitProviderInstance.Commit(); } else { viewModel.AlertMessage = Constants.ErrorMessages.InstructionEmptyText; } } viewModel.LenderInstructions.Add(new InstructionItemViewModel { Id = Guid.NewGuid().ToString(), IsEditable = true }); } return PartialView("Instructions", viewModel); }
public ActionResult SaveLetter(ClientCompanyLetterViewModel viewModel, InstructionViewModel instructionsCollection) { if (ModelState.IsValid) { var itemToValidate = instructionsCollection.LenderInstructions.SingleOrDefault(e => e.IsEditable); if (itemToValidate != null) { if (!instructionsCollection.LenderInstructions.Any(i => string.IsNullOrWhiteSpace(i.Text))) { ViewBag.NotificationMessage = itemToValidate.IsNew ? Constants.Notifications.InstructionSaved : Constants.Notifications.InstructionUpdated; _clientCompanyLetterService.SaveInstruction(itemToValidate, instructionsCollection.CompanyId); itemToValidate.IsEditable = false; CommitProviderInstance.Commit(); } else { instructionsCollection.AlertMessage = Constants.ErrorMessages.InstructionEmptyText; } } viewModel.InstructionsCollection = instructionsCollection; _clientCompanyLetterService.SaveClientCompanyLetter(viewModel, PluginResults.Find<UserAccessPluginResult>().CompnayId); CommitProviderInstance.Commit(); return PluginResults.Plugins<CurrentMenuPluginResule>().GetRedirectToTab(); } return View(); }
public ActionResult InstructionCancel(InstructionViewModel viewModel, string instructionCancel) { ModelState.Clear(); var model = _clientCompanyLetterService.GetClientCompanyLetterViewModel(viewModel.CompanyId); return PartialView("Instructions", model.InstructionsCollection); }
public ActionResult InstructionDelete(InstructionViewModel viewModel, string instructionDelete) { if (ValidateContactsModel()) { ModelState.Clear(); var item = viewModel.LenderInstructions.SingleOrDefault(e => e.Id.Equals(instructionDelete)); if (item == null) throw new ApplicationException("contact not found"); var itemToValidate = viewModel.LenderInstructions.SingleOrDefault(e => e.IsEditable); if (itemToValidate != null) { _clientCompanyLetterService.SaveInstruction(itemToValidate, viewModel.CompanyId); } ViewBag.NotificationMessage = Constants.Notifications.InstructionDeleted; _clientCompanyLetterService.DeleteInstruction(instructionDelete, viewModel.CompanyId); CommitProviderInstance.Commit(); viewModel = _clientCompanyLetterService.GetClientCompanyLetterViewModel(viewModel.CompanyId).InstructionsCollection; } return PartialView("Instructions", viewModel); }
public ActionResult InstructionEdit(InstructionViewModel viewModel, string instructionEdit) { if (ValidateContactsModel()) { ModelState.Clear(); var item = viewModel.LenderInstructions.SingleOrDefault(e => e.Id.Equals(instructionEdit)); if (item == null) throw new ApplicationException("instruction not found"); var itemToValidate = viewModel.LenderInstructions.SingleOrDefault(e => e.IsEditable); if (itemToValidate != null) { if (!viewModel.LenderInstructions.Any(i => string.IsNullOrWhiteSpace(i.Text))) { ViewBag.NotificationMessage = itemToValidate.IsNew ? Constants.Notifications.InstructionSaved : Constants.Notifications.InstructionUpdated; _clientCompanyLetterService.SaveInstruction(itemToValidate, viewModel.CompanyId); CommitProviderInstance.Commit(); } else { viewModel.AlertMessage = Constants.ErrorMessages.InstructionEmptyText; } } item.IsEditable = true; item.AlertMessage = null; } return PartialView("Instructions", viewModel); }