public void PutLearnable(int id, LearnableModel model)
        {
            // Search by the given ID the modify
            var learnable = _context.Learnables.Single(l => l.LearnableID == id);

            learnable.CourseID   = model.CourseID;
            learnable.English    = model.English;
            learnable.Hungarian  = model.Hungarian;
            learnable.PictureUrl = model.PictureUrl;
            learnable.WordClass  = model.WordClass;
            _context.SaveChanges();
        }
        public void AddLearnable(LearnableModel model)
        {
            // It will get ID automatically in the DB
            var learnable = new Learnable
            {
                CourseID   = model.CourseID,
                English    = model.English,
                Hungarian  = model.Hungarian,
                PictureUrl = model.PictureUrl,
                WordClass  = model.WordClass
            };

            _context.Learnables.Add(learnable);
            _context.SaveChanges();
        }
        public LearnableEditor(List <CourseModel> courseList, LearnableModel word)
        {
            InitializeComponent();
            this.DataContext = this;

            Word = new LearnableModel {
                LearnableID = word.LearnableID,
                CourseID    = word.CourseID,
                English     = word.English,
                Hungarian   = word.Hungarian,
                WordClass   = word.WordClass,
                PictureUrl  = word.PictureUrl
            };
            AvailableCourses = courseList.Select(c => new CourseModel {
                CourseID = c.CourseID,
                Name     = c.Name
            }).ToList();
            SelectedCourse = AvailableCourses.Single(c => c.CourseID == Word.CourseID);
        }
        public LearnableEditor(List <CourseModel> courseList, CourseModel selectedCourse)
        {
            InitializeComponent();
            this.DataContext = this;

            Word             = new LearnableModel();
            AvailableCourses = courseList.Select(c => new CourseModel
            {
                CourseID = c.CourseID,
                Name     = c.Name
            }).ToList();
            if (selectedCourse == null)
            {
                SelectedCourse = null;
            }
            else
            {
                SelectedCourse = AvailableCourses.Single(c => c.CourseID == selectedCourse.CourseID);
            }
        }
 public IActionResult Put(int id, [FromBody] LearnableModel model)
 {
     _manager.PutLearnable(id, model);
     return(Json("OK"));
 }
 public IActionResult Post([FromBody] LearnableModel model)
 {
     _manager.AddLearnable(model);
     return(Json("OK"));
 }