public async Task <IActionResult> Post(SectionDtoForAdd section) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (await _repo.SectionExists(section.SectionName)) { return(BadRequest(new { message = "Section Already Exist" })); } var createdObj = await _repo.AddSection(section); return(Ok(_response)); }
public async Task <ServiceResponse <object> > AddSection(SectionDtoForAdd section) { var objToCreate = new Section { SectionName = section.SectionName, CreatedById = _LoggedIn_UserID, CreationDatetime = DateTime.UtcNow, Active = true, SchoolBranchId = _LoggedIn_BranchID }; await _context.Sections.AddAsync(objToCreate); await _context.SaveChangesAsync(); _serviceResponse.Success = true; _serviceResponse.Message = CustomMessage.Added; return(_serviceResponse); }