public async Task <AddResult> AddKnoledge()
        {
            var itemId = Guid.NewGuid();

            var message = Request.Form["message"];

            // get all files from the Form body
            var files = Request.Form.Files.ToList();

            // save to disk
            var filePaths = await SaveFiles(itemId, files);

            // map to DocumentModel
            var documents = ParseFiles(filePaths);

            // parse and map to link
            var link = ParseFirstLink(message);

            var item = new AddKnoledgeItemModel
            {
                Content   = message,
                Link      = link,
                Documents = documents
            };

            _knowledgeService.AddKnowledgeItem(item);
            return(new AddResult("OK"));
        }
Beispiel #2
0
        public void AddKnowledgeItem(AddKnoledgeItemModel model)
        {
            var entry = new KnowledgeEntry
            {
                Content   = model.Content,
                Date      = DateTime.Now,
                User      = "******",
                Link      = ToLink(model.Link),
                Documents = ToDocuments(model.Documents)
            };

            _dbContext.KnoledgeEntries.Add(entry);
            _dbContext.SaveChanges();
        }