public IActionResult Get(long id) { var category = _contactRepository.Query().FirstOrDefault(x => x.Id == id); var model = new ContactAreaForm { Id = category.Id, Name = category.Name }; return(Json(model)); }
public IActionResult Put(long id, [FromBody] ContactAreaForm model) { if (ModelState.IsValid) { var category = _contactRepository.Query().FirstOrDefault(x => x.Id == id); category.Name = model.Name; _contactRepository.SaveChanges(); return(Ok()); } return(BadRequest(ModelState)); }
public IActionResult Post([FromBody] ContactAreaForm model) { if (ModelState.IsValid) { var category = new ContactArea { Name = model.Name }; _contactRepository.Add(category); _contactRepository.SaveChanges(); return(Ok()); } return(BadRequest(ModelState)); }