public async Task <IActionResult> PutContact(long id, IsuCorpTestData.Models.Contact contact) { if (id != contact.ContactId) { return(BadRequest("Bad Request")); } if (ModelState.IsValid) { contactBusiness.Update(contact); await contactBusiness.SaveChangeAsync(); } return(NoContent()); }
public async Task <ActionResult <IsuCorpTestData.Models.Contact> > GetContact(long id, string name = null) { var contact = new IsuCorpTestData.Models.Contact(); if (id != 0) { contact = await contactBusiness.GetByIdAsync(id); } else { contact = contactBusiness.GetByName(name); } if (contact == null) { return(NotFound("Contact not found")); //return contact = new IsuCorpTestData.Models.Contact { ContactId = 0 }; } return(contact); }
public async Task <ActionResult <IsuCorpTestData.Models.Contact> > PostContact(IsuCorpTestData.Models.Contact contact) { if (ModelState.IsValid) { contactBusiness.Add(contact); await contactBusiness.SaveChangeAsync(); } return(CreatedAtAction("GetContact", new { id = contact.ContactId }, contact)); }