public async Task <Guid> CreateNew(Guid teacherGuid, SubjectCreateModel newSubject) { var teacher = await _readRepository.FindByIdAsync <Domain.Entities.Teacher>(teacherGuid); var subject = Domain.Entities.Subject.Create(teacher, newSubject.Name); await this._writeRepository.AddNewAsync(subject); await this._writeRepository.SaveAsync(); return(subject.Id); }
public async Task <Guid> Update(Guid id, SubjectCreateModel updatedSubject) { var subject = await _readRepository.FindByIdAsync <Domain.Entities.Subject>(id); if (subject != null) { subject.Update(updatedSubject.Name, updatedSubject.Year); await _writeRepository.UpdateAsync(id, subject); await _writeRepository.SaveAsync(); } return(subject.Id); }