Пример #1
0
        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());
        }
Пример #2
0
        public async Task <IActionResult> UpdateSubject([FromBody] UpdateSubjectDto updateSubject)
        {
            await _subjectService.UpdateSubject(updateSubject);

            return(Ok());
        }