public async Task <IActionResult> PutTask(int id, EFRepo.Entities.Task task) { if (id != task.TaskId) { return(BadRequest()); } _context.Entry(task).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <EFRepo.Entities.Task> > PostTask(EFRepo.Entities.Task task) { _context.Tasks.Add(task); await _context.SaveChangesAsync(); var createdAtAction = CreatedAtAction("GetTask", new { id = task.TaskId }, task); var contractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() }; var taskJSON = JsonConvert.SerializeObject(task, new JsonSerializerSettings { ContractResolver = contractResolver, Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore }); await SendTaskCreatedEventToAMQP(createdAtAction, taskJSON); return(createdAtAction); }