예제 #1
0
        public Task <bool> Handle(RegisterNewKnowledgeCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(Task.FromResult(false));
            }

            var model = new Knowledge()
            {
                PeopleId           = request.PeopleId,
                EntityState        = EntityStateOptions.Active,
                KnowledgeDesigner  = request.KnowledgeDesigner,
                KnowledgeDeveloper = request.KnowledgeDeveloper,
                UrlLinkCRUD        = request.UrlLinkCRUD,
                Other = request.Other
            };

            //TODO Validar se não existe!

            knowledgeRepository.Add(model);

            if (Commit())
            {
                bus.RaiseEvent(new KnowledgeRegisteredEvent(model.Id, "user"));
            }
            return(Task.FromResult(true));
        }
        public ViewResult AddKnowledge(string?skillTitle, string?significiantPoints, string?feedback)
        {
            _showViewModel.PageTitle = "Nouvelle connaissance ajoutée :";
            List <string> listSignificiantPoints = new List <string>();

            if (significiantPoints != null)
            {
                foreach (var s in significiantPoints.Split("\r\n"))
                {
                    listSignificiantPoints.Add(s);
                }
            }
            Knowledge knowledge = new Knowledge(skillTitle, listSignificiantPoints, feedback);

            _knowledgeRepository.Add(knowledge);
            _showViewModel.Knowledges = _knowledgeRepository.GetKnowledges();
            return(View("~/Views/Knowledge/ShowKnowledge.cshtml", _showViewModel));
        }