Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }