public async Task <IActionResult> CreateAsync([FromBody] ProposalVM vm) { var newProposal = vm.ToProposal(); var result = await _bo.CreateAsync(newProposal); if (!result.Success) { return(InternalServerError(result.Exception)); } return(Created(Request.Path.Value, null)); }
public void TestCreateAndListProposalAsync() { ApplicationSeeder.Seed(); var bo = new ProposalBO(); var foreignBO = new JobBO(); var proposal = new Proposal("User Teste", "Mensagem de teste", foreignBO.ListUndeleted().Result.First().Id); var resCreate = bo.CreateAsync(proposal).Result; var resGet = bo.ReadAsync(proposal.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public async Task <IActionResult> New(ProposalVM vm) { if (ModelState.IsValid) { var model = vm.ToProposal(); var createOperation = await _bo.CreateAsync(model); if (!createOperation.Success) { return(OperationErrorBackToIndex(createOperation.Exception)); } return(OperationSuccess("The record was successfully created.")); } return(View(vm)); }