public async Task <ELearningModel> Update(ELearningModel eLearningModel)
        {
            _context.ELearningTable.Update(eLearningModel);
            await _context.SaveChangesAsync();

            return(eLearningModel);
        }
        public async Task <ELearningModel> Get(long Id)
        {
            ELearningModel eLearningModel = _context.ELearningTable.Find(Id);

            await _context.SaveChangesAsync();

            return(eLearningModel);
        }
Exemple #3
0
        public async Task <IActionResult> PostELearning([FromBody] ELearningModel eLearningModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            await _context.Add(eLearningModel);

            return(Ok(eLearningModel));
        }
        public async Task <ELearningModel> Delete(long Id)
        {
            ELearningModel eLearningModel = _context.ELearningTable.Find(Id);

            if (eLearningModel != null)
            {
                _context.ELearningTable.Remove(eLearningModel);
                await _context.SaveChangesAsync();
            }
            return(eLearningModel);
        }
        public IActionResult Delete(long Id)
        {
            ELearningModel eLearningModel = _eLearning.GetELearning(Id);

            if (eLearningModel == null)
            {
                //error message
                return(RedirectToAction("Lists"));
            }
            return(View(eLearningModel));
        }
        public ELearningModel Delete(long Id)
        {
            ELearningModel eLearningModel = _dataContext.ELearningTable.Find(Id);

            if (eLearningModel != null)
            {
                _dataContext.ELearningTable.Remove(eLearningModel);
                _dataContext.SaveChanges();
            }

            return(eLearningModel);
        }
Exemple #7
0
        public async Task <IActionResult> PutELearning([FromRoute] long id, ELearningModel eLearningModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != eLearningModel.Id)
            {
                return(BadRequest("Course ID doesn't exist "));
            }

            await _context.Update(eLearningModel);

            return(NoContent());
        }
 public void EditELearning(ELearningModel eLearningModel)
 {
     _dataContext.Entry(eLearningModel).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     _dataContext.SaveChanges();
 }
 public void AddELearning(ELearningModel eLearningModel)
 {
     _dataContext.ELearningTable.Add(eLearningModel);
     _dataContext.SaveChanges();
 }
        public IActionResult Edit(ELearningModel eLearningModel)
        {
            _eLearning.EditELearning(eLearningModel);

            return(View(eLearningModel));
        }
        public IActionResult Edit(long Id)
        {
            ELearningModel eLearningModel = _eLearning.GetELearning(Id);

            return(View(eLearningModel));
        }
 public IActionResult Create(ELearningModel eLearning)
 {
     _eLearning.AddELearning(eLearning);
     return(View(eLearning));
 }