Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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));
        }