public async Task <IActionResult> CreateSection([FromForm] SectionCreateDTO sectionDTO) { var properties = new Dictionary <dynamic, dynamic>(); properties.Add("SectionName", sectionDTO.SectionName); if (_repo.Exists <Section>(properties)) { return(Conflict(new { Error = "Section đã tồn tại" })); } var section = _mapper.Map <Section>(sectionDTO); var result = _cloud.UploadImage(sectionDTO.File); if (result != null) { section.PhotoUrl = result.PublicUrl; section.PublicId = result.PublicId; } _repo.Create(section); if (await _repo.SaveAll()) { return(Ok()); } return(StatusCode(500)); }
public ActionResult <SectionCreateDTO> SectionRegister(SectionCreateDTO s) { try { return(Ok(SqlSectionsRepository.SectionRegister(s.uc, s.semester, s.ht, s.hp, s.hl, s.name, s.description, s.type, s.fk_school))); } catch (DatabaseException) { return(StatusCode(500)); } }