Exemple #1
0
        public async Task <ActionResult <SubjectGroupDTO> > Create([FromBody] SubjectGroupDTO subjectGroupDTO)
        {
            if (subjectGroupDTO == null)
            {
                subjectGroupDTO = new SubjectGroupDTO();
            }

            SubjectGroup subjectGroup = ConvertDTOtoBO(subjectGroupDTO);

            subjectGroup = await SubjectGrupService.Create(subjectGroup);

            subjectGroupDTO = new SubjectGroupDTO
            {
                Id     = subjectGroup.Id,
                Code   = subjectGroup.Code,
                Name   = subjectGroup.Name,
                Errors = subjectGroup.Errors
            };

            if (subjectGroup.HasError)
            {
                return(BadRequest(subjectGroupDTO));
            }
            return(Ok(subjectGroupDTO));
        }
Exemple #2
0
        public async Task <ActionResult <SubjectGroupDTO> > Delete([FromBody] SubjectGroupDTO subjectGroupDTO)
        {
            if (subjectGroupDTO == null)
            {
                subjectGroupDTO = new SubjectGroupDTO();
            }

            SubjectGroup subjectGroup = new SubjectGroup {
                Id = subjectGroupDTO.Id ?? default
            };

            subjectGroup = await SubjectGrupService.Delete(subjectGroup);

            subjectGroupDTO = new SubjectGroupDTO
            {
                Id     = subjectGroup.Id,
                Code   = subjectGroup.Code,
                Name   = subjectGroup.Name,
                Errors = subjectGroup.Errors
            };

            if (subjectGroup.HasError)
            {
                return(BadRequest(subjectGroupDTO));
            }
            return(Ok(subjectGroupDTO));
        }
Exemple #3
0
        private SubjectGroup ConvertDTOtoBO(SubjectGroupDTO subjectGroupDTO)
        {
            SubjectGroup subjectGroup = new SubjectGroup
            {
                Id   = subjectGroupDTO.Id ?? Guid.Empty,
                Code = subjectGroupDTO.Code,
                Name = subjectGroupDTO.Name
            };

            return(subjectGroup);
        }
Exemple #4
0
        public async Task <SubjectGroupDTO> Get([FromBody] SubjectGroupDTO subjectGroupDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            var subjectGroup = await SubjectGrupService.Get(subjectGroupDTO.Id);

            return(subjectGroup == null ? null : new SubjectGroupDTO(subjectGroup));
        }
Exemple #5
0
        public async Task <SubjectGroupDTO> Get([FromBody] SubjectGroupDTO subjectGroupDTO)
        {
            if (subjectGroupDTO == null)
            {
                subjectGroupDTO = new SubjectGroupDTO();
            }

            SubjectGroup subjectGroup = new SubjectGroup {
                Id = subjectGroupDTO.Id ?? default
            };

            subjectGroup = await SubjectGrupService.Get(subjectGroup.Id);

            subjectGroupDTO = new SubjectGroupDTO
            {
                Id     = subjectGroup.Id,
                Code   = subjectGroup.Code,
                Name   = subjectGroup.Name,
                Errors = subjectGroup.Errors
            };
            return(subjectGroupDTO);
        }