public async Task <IActionResult> PutReceivedSMSRequest([FromRoute] int id, [FromBody] ReceivedSMSRequest receivedSMSRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != receivedSMSRequest.Id) { return(BadRequest()); } _context.Entry(receivedSMSRequest).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReceivedSMSRequestExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostReceivedSMSRequest() { var receivedSMSRequest = new ReceivedSMSRequest(); using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { receivedSMSRequest.Body = await reader.ReadToEndAsync(); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ReceivedSMSRequests.Add(receivedSMSRequest); await _context.SaveChangesAsync(); return(CreatedAtAction("GetReceivedSMSRequest", new { id = receivedSMSRequest.Id }, receivedSMSRequest)); }