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)); }
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)); }
private SubjectGroup ConvertDTOtoBO(SubjectGroupDTO subjectGroupDTO) { SubjectGroup subjectGroup = new SubjectGroup { Id = subjectGroupDTO.Id ?? Guid.Empty, Code = subjectGroupDTO.Code, Name = subjectGroupDTO.Name }; return(subjectGroup); }
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)); }
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); }