public async Task <ActionResult <EntryBookDto> > Post([FromBody] EntryBookDto value) { var created = await _entryBookService.CreateEntry(value); if (created) { return(Ok(value)); } return(BadRequest("Either Duplicate primary key or no person name"));; }
public async Task <bool> CreateEntry(EntryBookDto entryBookDto) { var obj = _dbContext.EntryBook.Where(x => x.PersonId == entryBookDto.PersonId).FirstOrDefault(); if (obj == null && !(String.IsNullOrEmpty(entryBookDto.PersonName))) { await _dbContext.EntryBook.AddAsync(entryBookDto); int entryBook = await _dbContext.SaveChangesAsync(); if (entryBook != 0) { return(true); } return(false); } return(false); }
public async Task <bool> CreateEntry(EntryBookDto entryBook) { var created = await _entryBookRepo.CreateEntry(entryBook); return(created); }