Exemplo n.º 1
0
        public async Task <ActionResult <StudyingEntityWord> > Post([FromBody] StudyingEntityWord newStudyingEntityWord)
        {
            _logger.LogInformation("{Time}: Add new word.", DateTime.UtcNow);
            _repository.Add(newStudyingEntityWord);
            await _repository.CommitAsync();

            return(CreatedAtAction("Get", new { id = newStudyingEntityWord.Id }, newStudyingEntityWord));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Put(long id, StudyingEntityWord studyingEntityWord)
        {
            _logger.LogInformation("{Time}: Update word by {id}.", DateTime.UtcNow, id);
            if (id != studyingEntityWord.Id)
            {
                return(BadRequest());
            }
            _repository.Update(studyingEntityWord);
            await _repository.CommitAsync();

            return(Ok(await _repository.GetByIdAsync(id)));
        }
 public void Update(StudyingEntityWord studyingEntityWord)
 {
     //var entity = ctx.StudyingEntityWords.Attach(studyingEntityWord);
     //entyti.State = EntityState.Modified;
     ctx.Entry(studyingEntityWord).State = EntityState.Modified;
     if (studyingEntityWord.Word != null)
     {
         ctx.Entry(studyingEntityWord.Word).State = EntityState.Modified;
     }
     if (studyingEntityWord.StudyingProcesInfo != null)
     {
         ctx.Entry(studyingEntityWord.StudyingProcesInfo).State = EntityState.Modified;
     }
     if (studyingEntityWord.StudyingEntityWordTags != null)
     {
         ctx.Entry(studyingEntityWord.StudyingEntityWordTags).State = EntityState.Modified;
     }
 }
 public void Add(StudyingEntityWord newStudyingEntityWord)
 {
     ctx.Add(newStudyingEntityWord);
 }