public IActionResult Update([FromBody] UpdateSubjectDto UpdateSubjectDto) { var subject = _abstractUnitOfWork.Repository <Subjects>().Find(UpdateSubjectDto.Id); if (subject == null) { return(NotFound()); } if (subject.StudySemesterId != UpdateSubjectDto.StudySemesterId) { var dependancySubject = _abstractUnitOfWork.Repository <DependenceSubject>().Get(c => c.SubjectId == UpdateSubjectDto.Id || c.DependsOnSubjectId == UpdateSubjectDto.Id).ToList(); dependancySubject.ForEach(ds => { _abstractUnitOfWork.Remove(ds, SentencesHelper.System); }); var equivalentSubject = _abstractUnitOfWork.Repository <EquivalentSubject>().Get(c => c.FirstSubject == UpdateSubjectDto.Id || c.SecoundSubject == UpdateSubjectDto.Id).ToList(); equivalentSubject.ForEach(es => { _abstractUnitOfWork.Remove(es, SentencesHelper.System); }); } _mapper.Map <UpdateSubjectDto, Subjects>(UpdateSubjectDto, subject); _abstractUnitOfWork.Update(subject, UserName()); return(Ok()); }
public async Task <IActionResult> UpdateSubject([FromBody] UpdateSubjectDto updateSubject) { await _subjectService.UpdateSubject(updateSubject); return(Ok()); }