コード例 #1
0
        public async Task <IActionResult> Edit(OrdemServicoExameViewModel ordemServicoExameViewModel)
        {
            var ordemServicoViewModel = await _ordemServicoAppService.GetById(ordemServicoExameViewModel.OrdemServico.Id);

            ordemServicoExameViewModel.OrdemServico = ordemServicoViewModel;

            if (ResponseHasErrors(await _ordemServicoExameAppService.Update(ordemServicoExameViewModel)))
            {
                return(View(ordemServicoExameViewModel));
            }

            return(RedirectToAction("edit", "ordem", new { id = ordemServicoViewModel.Id }));
        }
コード例 #2
0
        public async Task <IActionResult> Create(Guid?id, OrdemServicoExameViewModel ordemServicoExameViewModel)
        {
            ordemServicoExameViewModel.OrdemServico = await _ordemServicoAppService.GetById(id.Value);

            bool hasErrors = !ModelState.IsValid;

            if (!hasErrors)
            {
                hasErrors = ResponseHasErrors(await _ordemServicoExameAppService.Add(ordemServicoExameViewModel));
            }

            if (hasErrors)
            {
                ViewData["ExameId"]        = new SelectList(await _exameAppService.GetAll(), "Id", "Nome", ordemServicoExameViewModel.Exame?.Id);
                ViewData["OrdemServicoId"] = id;

                return(View(ordemServicoExameViewModel));
            }

            ViewBag.Sucesso = "Item registrado!";

            return(RedirectToAction("edit", "ordem", new { Id = id }));
        }
コード例 #3
0
        public async Task <ValidationResult> Update(OrdemServicoExameViewModel ordemServicoExameViewModel)
        {
            var updateCommand = _mapper.Map <UpdateOrdemServicoExameCommand>(ordemServicoExameViewModel);

            return(await _mediator.SendCommand(updateCommand));
        }
コード例 #4
0
        public async Task <ValidationResult> Add(OrdemServicoExameViewModel ordemServicoExameViewModel)
        {
            var addCommand = _mapper.Map <AddOrdemServicoExameCommand>(ordemServicoExameViewModel);

            return(await _mediator.SendCommand(addCommand));
        }