public async Task <ActionResult <Administrator> > Index() { var admin = new Administrator() { Name = "Matheus", Password = "******" }; _administratorRepository.Insert(admin); _administratorRepository.Save(); return(Ok(new { message = "Sucessfully" })); }
public async Task <ActionResult <List <Administrator> > > Post([FromBody] Administrator model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { try { _administratorRepository.Insert(model); _administratorRepository.Save(); return(Ok(model)); }catch (DBConcurrencyException E) { return(BadRequest(new { message = E.Message })); }catch (Exception E) { return(BadRequest(new { message = E.Message })); } } }