Ejemplo n.º 1
0
        public virtual IActionResult TopicTemplateDelete(int id)
        {
            //try to get a topic template with the specified id
            TopicTemplate template = _topicTemplateService.GetTopicTemplateById(id)
                                     ?? throw new ArgumentException("No template found with the specified id");

            _topicTemplateService.DeleteTopicTemplate(template);

            return(new NullJsonResult());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the topic template
        /// </summary>
        /// <param name="topicTemplate">Topic template</param>
        public virtual void UpdateTopicTemplate(TopicTemplate topicTemplate)
        {
            if (topicTemplate == null)
            {
                throw new ArgumentNullException(nameof(topicTemplate));
            }

            _topicTemplateRepository.Update(topicTemplate);

            //event notification
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Delete topic template
        /// </summary>
        /// <param name="topicTemplate">Topic template</param>
        public virtual async Task DeleteTopicTemplate(TopicTemplate topicTemplate)
        {
            if (topicTemplate == null)
            {
                throw new ArgumentNullException("topicTemplate");
            }

            await _topicTemplateRepository.DeleteAsync(topicTemplate);

            //event notification
            await _eventPublisher.EntityDeleted(topicTemplate);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Inserts topic template
        /// </summary>
        /// <param name="topicTemplate">Topic template</param>
        public virtual async Task InsertTopicTemplate(TopicTemplate topicTemplate)
        {
            if (topicTemplate == null)
            {
                throw new ArgumentNullException("topicTemplate");
            }

            await _topicTemplateRepository.InsertAsync(topicTemplate);

            //event notification
            await _mediator.EntityInserted(topicTemplate);
        }
Ejemplo n.º 5
0
        public void UpdateTopicTemplate(TopicTemplate topicTemplate)
        {
            if (topicTemplate == null)
            {
                throw new ArgumentNullException("topicTemplate");
            }

            _topicTemplateRepository.Update(topicTemplate);

            //event notification
            _eventPublisher.EntityUpdated(topicTemplate);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Inserts topic template
        /// </summary>
        /// <param name="topicTemplate">Topic template</param>
        public virtual void InsertTopicTemplate(TopicTemplate topicTemplate)
        {
            if (topicTemplate == null)
            {
                throw new ArgumentNullException(nameof(topicTemplate));
            }

            _topicTemplateRepository.Insert(topicTemplate);

            //event notification
            _eventPublisher.EntityInserted(topicTemplate);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get topic template view path
        /// </summary>
        /// <param name="topicTemplateId">Topic template identifier</param>
        /// <returns>View path</returns>
        public virtual string PrepareTemplateViewPath(int topicTemplateId)
        {
            TopicTemplate template = _topicTemplateService.GetTopicTemplateById(topicTemplateId);

            if (template == null)
            {
                template = _topicTemplateService.GetAllTopicTemplates().FirstOrDefault();
            }
            if (template == null)
            {
                throw new Exception("No default template could be loaded");
            }
            return(template.ViewPath);
        }
Ejemplo n.º 8
0
        public virtual IActionResult TopicTemplateAdd(TopicTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            TopicTemplate template = new TopicTemplate();

            template = model.ToEntity(template);
            _topicTemplateService.InsertTopicTemplate(template);

            return(new NullJsonResult());
        }
Ejemplo n.º 9
0
        public void Can_save_and_load_topicTemplate()
        {
            var topicTemplate = new TopicTemplate
            {
                Name         = "Name 1",
                ViewPath     = "ViewPath 1",
                DisplayOrder = 1,
            };

            var fromDb = SaveAndLoadEntity(topicTemplate);

            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("Name 1");
            fromDb.ViewPath.ShouldEqual("ViewPath 1");
            fromDb.DisplayOrder.ShouldEqual(1);
        }
 public IActionResult TopicTemplateAdd(TopicTemplateModel model)
 {
     if (!ModelState.IsValid)
     {
         return(Json(new DataSourceResult {
             Errors = ModelState.SerializeErrors()
         }));
     }
     if (ModelState.IsValid)
     {
         var template = new TopicTemplate();
         template = model.ToEntity(template);
         _topicTemplateService.InsertTopicTemplate(template);
         return(new NullJsonResult());
     }
     return(ErrorForKendoGridJson(ModelState));
 }
Ejemplo n.º 11
0
        public virtual IActionResult TopicTemplateUpdate(TopicTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            //try to get a topic template with the specified id
            TopicTemplate template = _topicTemplateService.GetTopicTemplateById(model.Id)
                                     ?? throw new ArgumentException("No template found with the specified id");

            template = model.ToEntity(template);
            _topicTemplateService.UpdateTopicTemplate(template);

            return(new NullJsonResult());
        }
Ejemplo n.º 12
0
        public virtual IActionResult TopicTemplateAdd(TopicTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(ErrorJson(ModelState.SerializeErrors()));
            }

            var template = new TopicTemplate();

            template = model.ToEntity(template);
            _topicTemplateService.InsertTopicTemplate(template);

            return(Json(new { Result = true }));
        }
Ejemplo n.º 13
0
        public virtual ActionResult TopicTemplateAdd([Bind(Exclude = "Id")] TopicTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var template = new TopicTemplate();

            template = model.ToEntity(template);
            _topicTemplateService.InsertTopicTemplate(template);

            return(new NullJsonResult());
        }
        private void Initialize(OrganizationalContainer fallbackContainer)
        {
            {
                var path     = Path + ContentMetadata.FilenameExtension;
                var fallback = fallbackContainer?.ContentMetadata;
                ContentMetadata = File.Exists(path) ? new ContentMetadata(path, Container, this, fallback) : fallback;
            }

            {
                var path = Path + IndexTemplate.FilenameExtension;
                IndexTemplate = File.Exists(path) ? new IndexTemplate(path, Container, this) : fallbackContainer?.IndexTemplate;
            }

            {
                var path = Path + LogoTemplate.FilenameExtension;
                LogoTemplate = File.Exists(path) ? new LogoTemplate(path, Container, this) : fallbackContainer?.LogoTemplate;
            }

            {
                var path = Path + TopicTemplate.FilenameExtension;
                TopicTemplate = File.Exists(path) ? new TopicTemplate(path, Container, this) : fallbackContainer?.TopicTemplate;
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Inserts topic template
 /// </summary>
 /// <param name="topicTemplate">Topic template</param>
 public virtual async Task InsertTopicTemplateAsync(TopicTemplate topicTemplate)
 {
     await _topicTemplateRepository.InsertAsync(topicTemplate);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Updates the topic template
 /// </summary>
 /// <param name="topicTemplate">Topic template</param>
 public void UpdateTopicTemplate([FromBody] TopicTemplate topicTemplate)
 {
     _topicTemplateService.UpdateTopicTemplate(topicTemplate);
 }
Ejemplo n.º 17
0
 public override void Visit(TopicTemplate topicTemplate) => Visit(topicTemplate);
Ejemplo n.º 18
0
        private void Build()
        {
            Shell.SetFlyoutBehavior(this, FlyoutBehavior.Disabled);

            Shell.SetBackButtonBehavior(this, new BackButtonBehavior
            {
                Command = new Command(async() =>
                {
                    if (ViewModel.IsSaving)
                    {
                        toastService.ShortAlert("Aguarde a operação de salvar!");
                    }
                    else
                    {
                        await Shell.Current.Navigation.PopAsync(true);
                    }
                }),
            });

            Title = "Ata";

            var app = App.Current;
            var vm  = ViewModel = app.minuteViewModel;

            Content = new AbsoluteLayout
            {
                Children =
                {
                    // Page Content
                    new Grid
                    {
                        RowDefinitions = Rows.Define(
                            (Row.Minute, Star),
                            (Row.Banner, 50)),

                        ColumnDefinitions = Columns.Define(
                            (Col.TopicList, 70),
                            (Col.Information, Star)),

                        Children =
                        {
                            // Topic Collection
                            new CollectionView
                            {
                                BackgroundColor = Colors.Primary,

                                GestureRecognizers =
                                {
                                    new TapGestureRecognizer   {
                                    }.Invoke(c => c.Tapped += (s, e) =>
                                    {
                                        topicEntry.Unfocus();
                                    }),
                                },

                                // BODY - List of topics
                                ItemTemplate = TopicTemplate.New(vm),

                                // FOOTER - Action
                                Footer = new ContentView
                                {
                                    Padding = 5,

                                    Content = new Button       {
                                        ImageSource = Images.Add
                                    }.Standard().Round(40).Center()
                                    .Bind(nameof(vm.CreateTopic)),
                                },
                            }.VerticalListStyle().SingleSelection()
                            .Row(Row.Minute).Col(Col.TopicList)
                            .Bind(CollectionView.ItemsSourceProperty, nameof(vm.Topics))
                            .Bind(CollectionView.SelectionChangedCommandProperty, nameof(vm.SelectTopic), source: vm)
                            .Invoke(c =>
                            {
                                c.Bind(CollectionView.SelectionChangedCommandParameterProperty, nameof(CollectionView.SelectedItem), source: c);
                            }),

                            // Information Collection
                            new CollectionView
                            {
                                // BODY - List of information
                                ItemTemplate = InformationTemplate.New(vm),
                                Behaviors    =
                                {
                                    new FadingBehavior         {
                                    }
                                    .BindBehavior(FadingBehavior.IsActiveProperty, nameof(vm.SelectedTopic), converter: new NullToBool()),
                                },

                                // HEADER - Topic title with a button to delete the topic
                                Header = new ContentView
                                {
                                    Padding = 5,

                                    Content = new Frame
                                    {
                                        Padding = 5, CornerRadius = 6, BackgroundColor = Colors.Accent,

                                        Behaviors =
                                        {
                                            new MovingBehavior {
                                                MoveTo = EMoveTo.Top
                                            }
                                            .BindBehavior(MovingBehavior.IsActiveProperty, nameof(vm.SelectedTopic), converter: new NullToBool())
                                        },

                                        Content = new StackLayout
                                        {
                                            Spacing = 10, Orientation = StackOrientation.Horizontal,

                                            Children =
                                            {
                                                new Frame      {
                                                }.FramedCustomEntry(out topicEntry, Images.TextBlack).FillExpandH()
                                                .Invoke(c =>
                                                {
                                                    topicEntry.Placeholder = "Nome do tópico";
                                                    topicEntry.Bind(CustomEntry.TextProperty, $"{nameof(vm.SelectedTopic)}.{nameof(vm.SelectedTopic.Text)}");
                                                    topicEntry.Bind(CustomEntry.SaveCommandProperty, nameof(vm.SaveTopicTitle));
                                                    topicEntry.Bind(CustomEntry.IsSavingProperty, nameof(vm.IsSavingTopic), BindingMode.OneWayToSource);
                                                    topicEntry.Bind(CustomEntry.IsSavingEnabledProperty, nameof(vm.IsSavingEnabled));
                                                }),

                                                new Button     {
                                                    ImageSource = Images.Delete
                                                }.Standard().Danger().Round(40).Center()
                                                .Bind(nameof(vm.DeleteTopic)),
                                            },
                                        }
                                    }.Padding(5).SetTranslationY(-100),
                                },

                                // FOOTER - Actions
                                Footer = new ContentView
                                {
                                    Padding = 5,

                                    Content = new Button
                                    {
                                        ImageSource = Images.Add,

                                        Behaviors =
                                        {
                                            new FadingBehavior {
                                            }
                                            .BindBehavior(FadingBehavior.IsActiveProperty, nameof(vm.SelectedTopic), converter: new NullToBool()),
                                            new MovingBehavior {
                                                MoveTo = EMoveTo.End
                                            }
                                            .BindBehavior(MovingBehavior.IsActiveProperty, nameof(vm.SelectedTopic), converter: new NullToBool()),
                                        },
                                    }.Standard().Round(40).SetTranslationX(50).Right()
                                    .Bind(nameof(vm.CreateInformation)),
                                }
                            }.VerticalListStyle().SingleSelection().FillExpandV()
                            .Row(Row.Minute).Col(Col.Information)
                            .Bind(CollectionView.ItemsSourceProperty, nameof(vm.Information)),

                            new AdMobView                      {
                                AdUnitId = Constants.AdMinute
                            }
                            .Row(Row.Banner).ColSpan(2),
                        }
                    }.Standard(),
 public virtual void Visit(TopicTemplate topicTemplate)
 {
 }
 public virtual void Leave(TopicTemplate topicTemplate)
 {
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Updates the topic template
 /// </summary>
 /// <param name="topicTemplate">Topic template</param>
 public virtual void UpdateTopicTemplate(TopicTemplate topicTemplate)
 {
     _topicTemplateRepository.Update(topicTemplate);
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Inserts topic template
 /// </summary>
 /// <param name="topicTemplate">Topic template</param>
 public virtual void InsertTopicTemplate(TopicTemplate topicTemplate)
 {
     _topicTemplateRepository.Insert(topicTemplate);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Inserts topic template
 /// </summary>
 /// <param name="topicTemplate">Topic template</param>
 public void InsertTopicTemplate([FromBody] TopicTemplate topicTemplate)
 {
     _topicTemplateService.InsertTopicTemplate(topicTemplate);
 }
Ejemplo n.º 24
0
 public static TopicTemplateModel ToModel(this TopicTemplate entity)
 {
     return(entity.MapTo <TopicTemplate, TopicTemplateModel>());
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Updates the topic template
 /// </summary>
 /// <param name="topicTemplate">Topic template</param>
 public virtual async Task UpdateTopicTemplateAsync(TopicTemplate topicTemplate)
 {
     await _topicTemplateRepository.UpdateAsync(topicTemplate);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Delete topic template
 /// </summary>
 /// <param name="topicTemplate">Topic template</param>
 public virtual void DeleteTopicTemplate(TopicTemplate topicTemplate)
 {
     _topicTemplateRepository.Delete(topicTemplate);
 }
Ejemplo n.º 27
0
 public static TopicTemplate ToEntity(this TopicTemplateModel model, TopicTemplate destination)
 {
     return(model.MapTo(destination));
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Delete topic template
 /// </summary>
 /// <param name="topicTemplate">Topic template</param>
 public void DeleteTopicTemplate([FromBody] TopicTemplate topicTemplate)
 {
     _topicTemplateService.DeleteTopicTemplate(topicTemplate);
 }