Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public ActionResult Adiciona(AbastecimentoModel viewModel)
  2. {
  3. viewModel.TotalGasto = viewModel.Litro * viewModel.VlrUnit;
  4.  
  5.  
  6. if (ModelState.IsValid)
  7. {
  8. Abastecimento abastecimento = viewModel.CriaAbastecimento();
  9. dao.Adiciona(abastecimento);
  10. //return View();
  11. return RedirectToAction("Index");
  12. }
  13. else
  14. {
  15. ViewBag.Usuarios = usuarioDAO.Lista();
  16. ViewBag.Veiculo = veiculoDAO.Lista();
  17. return View("Form",viewModel);
  18. }
  19.  
  20. }
  21.  
  22. @model IList<BlogWeb.Models.Abastecimento>
  23. <!DOCTYPE HTML>
  24. <p>@Html.ActionLink("Novo Abastecimento", "Form")</p>
  25. <table class="table table-hover">
  26.  
  27. <thead>
  28.  
  29. <tr>
  30. <th>NΒΊ do Carro</th>
  31. <th>Data</th>
  32. <th>Litro</th>
  33. <th>Valor Unitario</th>
  34. <th>Valor Total</th>
  35. <th>Usuario</th>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. @foreach (var a in Model)
  40. {
  41. <tr>
  42.  
  43. <td>@a.NumCarro.NCarro</td>
  44. <td>@a.DtAbastecido</td>
  45. <td>@a.Litro</td>
  46. <td>@a.VlrUnit</td>
  47. <td>@a.TotalGasto</td>
  48. <td>@a.Autor.Nome</td>
  49.  
  50.  
  51.  
  52. </tr>
  53.  
  54. }
  55. </tbody>
  56. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement