Ejemplo n.º 1
0
        public async Task <IActionResult> CreateSubject(CreateSubjectDto createSubjectDto)
        {
            try
            {
                var nSubject = await _subjectAppService.InsertSubject(createSubjectDto);

                if (nSubject > 0)
                {
                    return(Ok(nSubject));
                }
                return(BadRequest("Subject Creation Failed"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public async Task <long> MappSubjectClass(long classId, CreateSubjectDto createSubjectDto)
        {
            ClassSubjectMap classSubjectMap;
            var             retrieveClass = await _schoolHubDbContext.ClassName.FirstOrDefaultAsync(c => c.Id == classId);

            if (retrieveClass != null)
            {
                var createSubject = await _subjectAppService.InsertSubject(createSubjectDto);

                classSubjectMap = new ClassSubjectMap
                {
                    ClassId   = classId,
                    SubjectId = createSubject,
                    MappedOn  = DateTime.UtcNow
                };

                await _schoolHubDbContext.ClassSubjectMap.AddAsync(classSubjectMap);

                await _schoolHubDbContext.SaveChangesAsync();

                return(classSubjectMap.Id);
            }
            return(0);
        }