private void DetailsToolPanel_EditClicked(object arg1, RoutedEventArgs arg2) { if (!this.DetailsListBox.HasItems || !this.DetailsListBox.SelectedIndex.IsInRange(0, this.DetailsListBox.Items.Count)) { return; } var SelectedDefCard = this.DetailsListBox.SelectedItem as DetailDefinitionCard; if (SelectedDefCard == null) { return; } /*- if (!ProductDirector.ConfirmImmediateApply("Detail Designator", "IdeaEditing.DetailDesignatorEdit", "ApplyDialogChangesDirectly")) * return; */ SelectedDefCard.Designator.Value.Name = SelectedDefCard.Name; var EditResult = DomainServices.EditDetailDesignator(SelectedDefCard.Designator.Value, true, this.SourceEngine); if (EditResult.Item1.IsTrue()) { SelectedDefCard.Name = SelectedDefCard.Designator.Value.Name; SelectedDefCard.Summary = SelectedDefCard.Designator.Value.Summary; } }
public static void SetUp() { // Create repository Func <IRepository> CreateRepository = () => new EntityFrameworkRepository(new ContosoDbContext(), new ContosoUniversityRepositoryInterceptors()); // Courses DomainServices.AddService <CourseCreate.Request>(request => DefaultWithValidation(request, p => CourseHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <CourseDelete.Request>(request => DefaultWithValidation(request, p => CourseHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <CourseUpdate.Request>(request => DefaultWithValidation(request, p => CourseHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <CourseUpdateCredits.Request>(request => DefaultWithValidation(request, p => CourseHandlers.Handle(CreateRepository(), request))); // Instructors DomainServices.AddService <InstructorDelete.Request>(request => DefaultWithValidation(request, p => InstructorHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <InstructorModifyAndCourses.Request>(request => DefaultWithValidation(request, p => InstructorHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <InstructorCreateWithCourses.Request>(request => DefaultWithValidation(request, p => InstructorHandlers.Handle(CreateRepository(), request))); // Students DomainServices.AddService <StudentDelete.Request>(request => DefaultWithValidation(request, p => StudentHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <StudentCreate.Request>(request => DefaultWithValidation(request, p => StudentHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <StudentModify.Request>(request => DefaultWithValidation(request, p => StudentHandlers.Handle(CreateRepository(), request))); // Departments DomainServices.AddService <DepartmentDelete.Request>(request => AministratorsOnly(request, p => DepartmentHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <DepartmentCreate.Request>(request => AministratorsOnly(request, p => DepartmentHandlers.Handle(CreateRepository(), request))); DomainServices.AddService <DepartmentUpdate.Request>(request => AministratorsOnly(request, p => DepartmentHandlers.Handle(CreateRepository(), request))); }
/// <summary> /// Exposes to the user a data editor, for the the supplied Detail Table, Designator and Custom-Look, and returns indication of change. /// </summary> public static bool Edit(Table DetailTable, TableDetailDesignator Designator, TableAppearance CustomLook = null, bool ForceSingleRecord = false) { if (DetailTable.Definition.FieldDefinitions.Count < 1) { if (Display.DialogMessage("Warning!", "No declared fields in the '" + DetailTable.Definition.Name + "' Table-Structure.\n\n" + "Do you want to declare them for " + (Designator.Owner.IsGlobal ? "all Ideas of type '" : "the Idea '") + ((IIdentifiableElement)Designator.Owner.Owner).Name + "' ?", EMessageType.Warning, MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return(false); } var EditResult = DomainServices.EditDetailDesignator(Designator, Designator.Owner.IsGlobal, Designator.EditEngine); if (!EditResult.Item1.IsTrue()) { return(false); } } var WorkTable = DetailTable.CreateClone(ECloneOperationScope.Deep, null); var Editor = new DetailTableEditor(WorkTable, Designator, CustomLook.NullDefault(new TableAppearance()), ForceSingleRecord); DialogOptionsWindow EditingWindow = null; // Do not declare as static to allow multiple dialogs open! var Changed = Display.OpenContentDialogWindow <DetailTableEditor>(ref EditingWindow, "Edit data of table '" + WorkTable.Designation.Name + "'", Editor).IsTrue(); if (Editor.ApplyChanges) { DetailTable.UpdateContentFrom(WorkTable); } return(Editor.ApplyChanges); //? || Changed); }
private void BtnExtractContent_Click(object sender, RoutedEventArgs e) { var Row = ((FrameworkElement)e.OriginalSource).GetNearestVisualDominantOfType <ListBoxItem>(); if (Row == null || Row.Content == null) { return; } var SelectedEditCard = Row.Content as DetailEditingCard; if (SelectedEditCard == null) { return; } var Annex = SelectedEditCard.DetailContent as Attachment; if (Annex != null) { this.SourceEngine.ExportAttachment(Annex, this.SourceIdea); return; } var Matrix = SelectedEditCard.DetailContent as Table; if (Matrix != null) { DomainServices.ExportTableDataToFile(Matrix, null); return; } Console.WriteLine("Nothing to extract."); }
public Application() { _editionServices = new EditionServices(); _userServices = new UserServices(); _domainServices = new DomainServices(); _bookServices = new BookServices(); _borrowServices = new BorrowServices(); }
/// <summary> /// Executes the appropriate action for creating a new item for the specified Palette. /// </summary> public override void ApplyPaletteItemCreation(IRecognizableElement Palette) { if (Palette.IsIn(this.TargetComposition.Engine.GetExposedConceptsPalettes())) { CurrentView.Engine.StartCommandVariation("Create Concept Definition"); var Result = DomainMaintainer.ConceptDefinitionCreate(CurrentView.Engine.TargetComposition.CompositeContentDomain, CurrentView.Engine.TargetComposition.CompositeContentDomain.ConceptDefinitions); if (Result != null) { CurrentView.Engine.TargetComposition.CompositeContentDomain.ConceptDefinitions.Add(Result); DomainServices.UpdateDomainDependants(CurrentView.Engine.TargetComposition.CompositeContentDomain); CurrentView.Engine.CompleteCommandVariation(); } else { CurrentView.Engine.DiscardCommandVariation(); } } else if (Palette.IsIn(this.TargetComposition.Engine.GetExposedRelationshipsPalettes())) { CurrentView.Engine.StartCommandVariation("Create Relationship Definition"); var Result = DomainMaintainer.RelationshipDefinitionCreate(CurrentView.Engine.TargetComposition.CompositeContentDomain, CurrentView.Engine.TargetComposition.CompositeContentDomain.RelationshipDefinitions); if (Result != null) { CurrentView.Engine.TargetComposition.CompositeContentDomain.RelationshipDefinitions.Add(Result); DomainServices.UpdateDomainDependants(CurrentView.Engine.TargetComposition.CompositeContentDomain); CurrentView.Engine.CompleteCommandVariation(); } else { CurrentView.Engine.DiscardCommandVariation(); } } else if (Palette.IsIn(this.TargetComposition.CompositeContentDomain.MarkerClusters)) { CurrentView.Engine.StartCommandVariation("Create Marker Definition"); var Result = DomainMaintainer.MarkerDefinitionCreate(CurrentView.Engine.TargetComposition.CompositeContentDomain, CurrentView.Engine.TargetComposition.CompositeContentDomain.MarkerDefinitions); if (Result != null) { CurrentView.Engine.TargetComposition.CompositeContentDomain.MarkerDefinitions.Add(Result); DomainServices.UpdateDomainDependants(CurrentView.Engine.TargetComposition.CompositeContentDomain); CurrentView.Engine.CompleteCommandVariation(); } else { CurrentView.Engine.DiscardCommandVariation(); } } }
public MessageWorkflow(DomainServices.ApplicationService applicationServices, DomainServices.EmailService emailService, DomainServices.TransactionBatchService transactionBatchService, DomainServices.SMSLogService smsLogService, DomainServices.SMSService smsService) { _transactionBatchService = transactionBatchService; _emailService = emailService; _applicationService = applicationServices; _smsLogService = smsLogService; _smsService = smsService; }
public void CheckContextualValidationRules() { Func <CourseDelete.Request, ValidationMessageCollection> CallSut = request => { var response = DomainServices.Dispatch(request); return(response.ValidationDetails); }; Assert2.CheckContextualValidation("CourseId", "CourseId must have a minimum value of 1", () => CallSut(CreateValidRequest(p => p.CommandModel.CourseId = 0))); }
public ActionResult DeleteConfirmed(int id) { var request = new CourseDelete.Request(SystemPrincipal.Name, new CourseDelete.CommandModel { CourseId = id }); DomainServices.Dispatch(request); return(RedirectToAction("Index")); }
private void DetailsToolPanel_AddClicked(object arg1, RoutedEventArgs arg2) { /*- if (!ProductDirector.ConfirmImmediateApply("IdeaEditing.DetailAdd", "ApplyDialogChangesDirectly")) * return; */ var DetailOptions = new List <IRecognizableElement>(); DetailOptions.Add(new SimplePresentationElement(AttachmentDetailDesignator.KindTitle, AttachmentDetailDesignator.KindName, AttachmentDetailDesignator.KindSummary, AttachmentDetailDesignator.KindPictogram)); DetailOptions.Add(new SimplePresentationElement(LinkDetailDesignator.KindTitle, LinkDetailDesignator.KindName, LinkDetailDesignator.KindSummary, LinkDetailDesignator.KindPictogram)); if (ProductDirector.ValidateEditionPermission(AppExec.LIC_EDITION_LITE, "designate Table detail", false)) { DetailOptions.Add(new SimplePresentationElement(TableDetailDesignator.KindTitle, TableDetailDesignator.KindName, TableDetailDesignator.KindSummary, TableDetailDesignator.KindPictogram)); } var DetailToCreate = Display.DialogMultiOption("Designation of Detail", "Select the type of detail to be designated...", "", null, true, TableDetailDesignator.KindName, DetailOptions.ToArray()); if (DetailToCreate == null) { return; } var SelectedDetailOption = DetailOptions.FirstOrDefault(det => det.TechName == DetailToCreate); var DesignationName = SelectedDetailOption.Name + " - Detail Definition " + (this.DetailsSource.Count + 1).ToString(); DetailDefinitionCard NewEditCard = null; var Owner = Ownership.Create <IdeaDefinition, Idea>(this.SourceDefinitor); DetailDesignator CreatedDesignation = null; if (DetailToCreate == TableDetailDesignator.KindName) { CreatedDesignation = DomainServices.CreateTableDesignation(this.SourceEngine, Owner, DesignationName); } else if (DetailToCreate == AttachmentDetailDesignator.KindName) { CreatedDesignation = DomainServices.CreateAttachmentDesignation(Owner, DesignationName); } else if (DetailToCreate == LinkDetailDesignator.KindName) { CreatedDesignation = DomainServices.CreateLinkDesignation(Owner, DesignationName); } if (CreatedDesignation == null) { return; } NewEditCard = new DetailDefinitionCard(false, new Assignment <DetailDesignator>(CreatedDesignation, this.DetailsSourceIsGlobal)); this.DetailsSource.Add(NewEditCard); this.DetailsListBox.SelectedItem = NewEditCard; }
public void CheckContextualValidationRules() { Func <CourseUpdate.Request, ValidationMessageCollection> CallSut = request => { var reponse = DomainServices.Dispatch(request); return(reponse.ValidationDetails); }; Assert2.CheckContextualValidation("CourseId", "CourseId cannot be less than 1", () => CallSut(CreateValidRequest(p => p.CommandModel.CourseID = 0))); Assert2.CheckContextualValidation("DepartmentId", "DepartmentId cannot be less than 1", () => CallSut(CreateValidRequest(p => p.CommandModel.DepartmentID = 0))); }
public void CheckInvariantValidationRules() { Action <CourseUpdate.Request> CallSut = request => { DomainServices.Dispatch(request); }; // Example (not really an invariant rule) Assert2.CheckInvariantValidation("Title cannot be set to Title", () => CallSut(CreateValidRequest(p => p.CommandModel.Title = "Title"))); Assert2.CheckInvariantValidation("Title cannot be null", () => CallSut(CreateValidRequest(p => p.CommandModel.Title = null))); }
public PaymentAccountWorkflow(DomainServices.ApplicationService applicationServices, DomainServices.Interfaces.IEmailService emailService, DomainServices.TransactionBatchService transactionBatchService, DomainServices.SMSLogService smsLogService, DomainServices.SMSService smsService) { _ctx = new Context(); _transactionBatchService = transactionBatchService; _emailService = emailService; _applicationService = applicationServices; _smsLogService = smsLogService; _smsService = smsService; }
public void CheckContextualValidationRules() { Func <CourseCreate.Request, ValidationMessageCollection> CallSut = request => { var response = DomainServices.Dispatch(request); return(response.ValidationDetails); }; Assert2.CheckContextualValidation("Title", "The field Title must be a string with a minimum length of 3 and a maximum length of 50.", () => CallSut(CreateValidRequest(p => p.CommandModel.Title = "X"))); Assert2.CheckContextualValidation("Credits", "The field Credits must be between 1 and 5.", () => CallSut(CreateValidRequest(p => p.CommandModel.Credits = 0))); }
public void should_fail_when_there_is_no_conversion_path_in_simple_case() { var deviceSource = new Currency("EUR"); var deviceTarget = new Currency("JPY"); var rates = new List <ChangeRate>() { new ChangeRate("EUR", "CHF", (decimal)2.111), }; var result = new DomainServices().Calculate(deviceSource, deviceTarget, 10, rates); }
public async Task <ActionResult> DeleteConfirmed(int id) { var request = new InstructorDelete.Request( SystemPrincipal.Name, new InstructorDelete.CommandModel { InstructorId = id }); await DomainServices.DispatchAsync(request); return(RedirectToAction("Index")); }
public ActionResult Edit(StudentModify.CommandModel commandModel) { var request = new StudentModify.Request(SystemPrincipal.Name, commandModel); var response = DomainServices.Dispatch(request); if (!response.HasValidationIssues) { return(RedirectToAction("Index")); } ModelState.AddRange(response.ValidationDetails); return(View(commandModel)); }
public void should_return_same_change_rate_when_only_one_input_data() { var deviceSource = new Currency("EUR"); var deviceTarget = new Currency("JPY"); var rates = new List <ChangeRate>() { new ChangeRate("EUR", "JPY", (decimal)1), }; var result = new DomainServices().Calculate(deviceSource, deviceTarget, 1, rates); Assert.IsTrue(result == 1); }
public ActionResult Delete(int id) { var request = new StudentDelete.Request(SystemPrincipal.Name, new StudentDelete.CommandModel { StudentId = id }); var response = DomainServices.Dispatch(request); if (!response.HasValidationIssues) { return(RedirectToAction("Index")); } return(RedirectToAction("Delete", new { id = id, saveChangesError = true })); }
public async Task <ActionResult> Create(CourseCreate.CommandModel commandModel) { var request = new CourseCreate.Request(SystemPrincipal.Name, commandModel); var response = DomainServices.Dispatch(request); if (!response.HasValidationIssues) { return(RedirectToAction("Index")); } ViewBag.DepartmentID = await CreateDepartmentSelectList(commandModel.DepartmentID); return(View(commandModel)); }
public void should_return_correct_lower_rounded_value_for_one_input_value() { var deviceSource = new Currency("EUR"); var deviceTarget = new Currency("JPY"); var rates = new List <ChangeRate>() { new ChangeRate("EUR", "JPY", (decimal)1.23), }; var result = new DomainServices().Calculate(deviceSource, deviceTarget, 1, rates); Assert.IsTrue(result == 1); }
public ActionResult UpdateCourseCredits(int?multiplier) { if (multiplier != null) { var request = new CourseUpdateCredits.Request(SystemPrincipal.Name, new CourseUpdateCredits.CommandModel { Multiplier = multiplier.Value }); var response = DomainServices.Dispatch <CourseUpdateCredits.Response>(request); ViewBag.RowsAffected = response.RowsEffected; } return(View()); }
public void should_return_correct_rounded_value_for_one_input_value_and_quantity_different_than_one() { var deviceSource = new Currency("EUR"); var deviceTarget = new Currency("JPY"); var rates = new List <ChangeRate>() { new ChangeRate("EUR", "JPY", (decimal)2.111), }; var result = new DomainServices().Calculate(deviceSource, deviceTarget, 10, rates); Assert.IsTrue(result == 21); }
should_return_correct_inverted_value_for_one_input_value_with_quantity_one_and_change_rate_smaller_than_one() { var deviceSource = new Currency("EUR"); var deviceTarget = new Currency("JPY"); var rates = new List <ChangeRate>() { new ChangeRate("JPY", "EUR", (decimal)0.119), }; var result = new DomainServices().Calculate(deviceSource, deviceTarget, 1, rates); Assert.IsTrue(result == 8); }
private void BtnEditDesignator_Click(object sender, RoutedEventArgs e) { var Row = (sender is ListBoxItem ? (ListBoxItem)sender : ((FrameworkElement)e.OriginalSource).GetNearestVisualDominantOfType <ListBoxItem>(true)); if (Row == null || Row.Content == null) { return; } var SelectedEditCard = Row.Content as DetailEditingCard; if (SelectedEditCard == null) { return; } /*? if (!ProductDirector.ConfirmImmediateApply("Detail Designator", "IdeaEditing.DetailDesignatorEdit", "ApplyDialogChangesDirectly")) * return; */ SelectedEditCard.Designator.Value.Name = SelectedEditCard.Name; var EditResult = DomainServices.EditDetailDesignator(SelectedEditCard.Designator.Value, false, this.SourceEngine, true); if (EditResult.Item1.IsTrue()) { SelectedEditCard.Name = SelectedEditCard.Designator.Value.Name; SelectedEditCard.Summary = SelectedEditCard.Designator.Value.Summary; if (EditResult.Item2 != null && SelectedEditCard.Designator.Value is TableDetailDesignator) { var DetailTable = SelectedEditCard.DetailContent as Table; if (DetailTable != null) { Table.UpdateTableFrom(DetailTable, EditResult.Item2); } else { DetailTable = Table.CreateTableFrom(SelectedEditCard.Designator, EditResult.Item2, SourceIdea); SelectedEditCard.DetailContent = DetailTable; SelectedEditCard.DetailContent.UpdateDesignatorIdentification(); SelectedEditCard.SetContent(); // Not needed? this.SourceIdea.Details.AddNew(DetailTable); } } } }
public void should_return_upper_middle_point_rounded_when_two_input_data_with_middle_point_data() { var deviceSource = new Currency("EUR"); var deviceTarget = new Currency("JPY"); var rates = new List <ChangeRate>() { new ChangeRate("EUR", "CHF", (decimal)1), new ChangeRate("CHF", "JPY", (decimal)1.5), }; var result = new DomainServices().Calculate(deviceSource, deviceTarget, 1, rates); Assert.IsTrue(result == 2); }
public async Task <ActionResult> Edit(ModifyInstructorAndCoursesViewModel viewModel) { var request = new InstructorModifyAndCourses.Request(SystemPrincipal.Name, viewModel.CommandModel); var response = DomainServices.Dispatch(request); if (response.HasValidationIssues) { ModelState.AddRange(response.ValidationDetails); await PopulateAssignedCourseData(viewModel.SelectedCourses); return(View(viewModel)); } return(RedirectToAction("Index")); }
public void GivenIHaveTheFollowingCourses(Table table) { foreach (var row in table.Rows) { var commandModel = DataHelper.CreateCommandModelFromTable <CourseCreate.CommandModel>(table, row); var response = DomainServices.Dispatch <CourseCreate.Response>(new CourseCreate.Request("test", commandModel)); if (response.HasValidationIssues) { throw new ApplicationException(string.Join(" | ", response.ValidationDetails.Select(p => p.ErrorMessage))); } DataHelper.AddEntityToRemove(EntityType.Course, response.CourseId); } }
public void should_return_correct_value_for_two_input_data() { var deviceSource = new Currency("EUR"); var deviceTarget = new Currency("JPY"); var rates = new List <ChangeRate>() { new ChangeRate("EUR", "CHF", (decimal)0.9661), new ChangeRate("CHF", "JPY", (decimal)13.1151), }; var result = new DomainServices().Calculate(deviceSource, deviceTarget, 1000, rates); Assert.IsTrue(result == 12670); }
public async Task <ActionResult> Create(DepartmentCreate.CommandModel commandModel) { var request = new DepartmentCreate.Request(SystemPrincipal.Name, commandModel); var response = await DomainServices.DispatchAsync <DepartmentCreate.Response>(request); if (!response.HasValidationIssues) { return(RedirectToAction("Index")); } var instructors = await _QueryRepository.GetEntitiesAsync <Instructor>(new AsNoTrackingQueryStrategy());; ViewBag.InstructorID = new SelectList(instructors, "ID", "FullName", commandModel.InstructorID); ModelState.AddRange(response.ValidationDetails); return(View(commandModel)); }
public void GivenIHaveTheFollowingDepartments(Table table) { using (var repository = new ContosoUniversityEntityFrameworkRepository()) { foreach (var row in table.Rows) { var commandModel = DataHelper.CreateCommandModelFromTable <DepartmentCreate.CommandModel>(table, row); var response = DomainServices.Dispatch <DepartmentCreate.Response>(new DepartmentCreate.Request("test", commandModel)); if (response.HasValidationIssues) { throw new ApplicationException(string.Join(" | ", response.ValidationDetails.Select(p => p.ErrorMessage))); } DataHelper.AddEntityToRemove(EntityType.Department, response.DepartmentId); } } }
public DetailTableEditor(Table SourceTable, TableDetailDesignator SourceDesignator, TableAppearance SourceCustomLook, bool ForceSingleRecord = false) : this() { this.SourceTable = SourceTable; this.SourceDesignator = SourceDesignator; this.SourceCustomLook = SourceCustomLook; // Operations: Append-Record and Reset-Records... Tuple <Action <TableRecord>, Action> RecordOperations = null; if (this.SourceCustomLook.IsMultiRecord && !ForceSingleRecord) { RecordOperations = SetMultiRecordEditor(); } else { RecordOperations = SetSingleRecordEditor(); } var ImportWidget = DomainServices.CreateTransferWidget(SourceDesignator, SourceTable.OwnerIdea, false, false, (compatdef, datarecords, append) => { if (compatdef == null) { Display.DialogMessage("Attention", "Cannot load data with incomptaible table-structure.", EMessageType.Warning); return; } if (!append) { RecordOperations.Item2(); // Reset-Records } foreach (var datarecord in datarecords) { RecordOperations.Item1(new TableRecord(SourceTable, datarecord)); // Append-Record } }, this.SourceTable); ImportWidget.MaxWidth = 300; ImportWidget.HorizontalAlignment = HorizontalAlignment.Left; DockPanel.SetDock(ImportWidget, Dock.Left); this.BottomPanel.Children.Add(ImportWidget); }
public Insert(DomainServices.Game.Base.IInsert _insertGame) { this._insertGame = _insertGame; }
public Insert(DomainServices.User.Base.IInsert insertUser) { this._insertUser = insertUser; }