Esempio n. 1
0
        public async Task <ActionResult> Create([FromRoute] int?id)
        {
            var technology = await _context.SoftwareLanguages.FirstOrDefaultAsync(SL => SL.Id == id);


            var viewModel = new AddNewConceptwithDescriptionViewModel();

            viewModel.SoftwareLanguage = technology;


            return(View(viewModel));
        }
Esempio n. 2
0
        public async Task <ActionResult> Create(AddNewConceptwithDescriptionViewModel addNewConceptwithDescriptionViewModel, int id)
        {
            try
            {
                var user = await GetCurrentUserAsync();

                var concept = new Concept
                {
                    Name = addNewConceptwithDescriptionViewModel.ConceptName,
                    SoftwareLanguageId = id,
                    ApplicationUserId  = user.Id
                };
                _context.Concepts.Add(concept);
                await _context.SaveChangesAsync();

                //Do I need to add the decription to a list of Descriptions in the Concept?
                var description = new Description
                {
                    Paragraph         = addNewConceptwithDescriptionViewModel.ConceptDescription,
                    ApplicationUserId = user.Id,
                    ConceptId         = concept.Id
                };
                _context.Descriptions.Add(description);
                await _context.SaveChangesAsync();


                ///How do I grab the ConceptId from the concept I just created



                // TODO: Add insert logic here

                return(RedirectToAction(nameof(Index), new { id = id }));
            }
            catch
            {
                return(View());
            }
        }