示例#1
0
        public void AddConcept(Concept concept)
        {
            var concepts = new Concepts()
            {
                Id   = Guid.NewGuid(),
                Name = concept.ToString(),
            };

            foreach (var subcategory in concept.Subcategories)
            {
                concepts.AddSubcategory(subcategory.Id);
            }
            context.Concepts.Add(concepts);
        }
示例#2
0
        public async Task EditConcept(Concept concept)
        {
            var concepts = await context.Concepts
                           .Include(x => x.SubcategoriesInconcepts)
                           .FirstOrDefaultAsync(x => x.Id.Equals(concept.Id));

            if (concepts != null)
            {
                concepts.Name       = concept.ToString();
                concepts.Difficulty = concept.Difficulty.Value;
                concepts.Type       = concept.Type;
                concepts.UpdateSubcategorias(concept.Subcategories.Select(x => (Guid)x.Id));
                context.Entry(concepts).State = EntityState.Modified;
            }
        }