Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.49 KB | None | 0 0
  1. Models
  2.  
  3. public class ViewPropostasPropriedadeModel{
  4.    
  5.     [DisplayFormat(DataFormatString = "{0:000}", ApplyFormatInEditMode = true)]
  6.     public long id                                                      { get; set; }
  7.  
  8.     [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
  9.     public DateTime dtPedido                                            { get; set; }
  10.     public String investidorNome                                        { get; set; }
  11.     public String refAnuncio                                            { get; set; }
  12.     public String observacoes                                           { get; set; }
  13.  
  14.     [DisplayFormat(DataFormatString = "{0:N}", ApplyFormatInEditMode = true)]
  15.     public decimal valorInvestimento                                    { get; set; }
  16.  
  17.     public String statusDesc                                            { get; set; }
  18.  
  19.     public long idAnuncio                                               { get; set; }
  20.    
  21.  
  22.     public ViewPropostasPropriedadeModel() { }
  23.  
  24. }
  25.  
  26.  
  27. public class SearchPropostaPropriedadeModel{
  28.  
  29.     public IPagedList<ViewPropostasPropriedadeModel> lista          { get; set; }
  30.  
  31.     [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
  32.     public DateTime dtIni                                           { get; set; }
  33.  
  34.     [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
  35.     public DateTime dtFim                                           { get;set; }    
  36.  
  37.     //Status
  38.     public IEnumerable<SelectListItem> status                       { get; set; }    
  39.     public int statusSelected                                       { get; set; }
  40.  
  41.     public SearchPropostaPropriedadeModel() { }
  42. }
  43.  
  44. Controller
  45.  
  46.         [HttpGet]
  47.         [PermissionFilter(RoleType.Administrador, RoleType.Gerente, RoleType.InvestidorMaster)]
  48.         public ViewResult viewAllPropPropriedadeIM(int? page, DateTime? dtIni, DateTime? dtFim, int? statusSelected){
  49.             IList<PropInvestPropriedadeIM> _lista = new List<PropInvestPropriedadeIM>();
  50.             IList<ViewPropostasPropriedadeModel> _listaModel = new List<ViewPropostasPropriedadeModel>();
  51.  
  52.             SearchPropostaPropriedadeModel model = new SearchPropostaPropriedadeModel();
  53.  
  54.             try{
  55.                 int pageSize = 20;
  56.                 int pagina = page ?? 1;
  57.  
  58.                 //params (always null)                
  59.                 model.dtIni = dtIni ?? DateControl.getFirstDayOfMonth();
  60.                 model.dtFim = dtFim ?? DateControl.getLastDayOfMonth();
  61.                 Debug.WriteLine("Start: " + model.dtIni);
  62.                 Debug.WriteLine("End: " + model.dtFim);
  63.  
  64.                 //Request (not null)
  65.                 //String di = Request["dtIni"]; // not null
  66.                 //String df = Request["dtFim"]; // not null                
  67.                 //model.dtIni = di == null ? DateControl.getFirstDayOfMonth() : DateControl.convertStringToDate(di);
  68.                 //model.dtFim = df == null ? DateControl.getLastDayOfMonth() : DateControl.convertStringToDate(df);
  69.                
  70.                 model.status = getStatus();
  71.                 model.statusSelected = statusSelected ?? 1;              
  72.  
  73.                 _lista = new PropInvestPropriedadeDAO().findAllByData(model.dtIni, model.dtFim, model.statusSelected);
  74.                 foreach (PropInvestPropriedadeIM p in _lista){
  75.                     ViewPropostasPropriedadeModel vppm = new ViewPropostasPropriedadeModel();
  76.                     vppm.id = p.id;
  77.                     vppm.dtPedido = p.dtPedido;
  78.                     vppm.investidorNome = p.investidorMaster.nome;
  79.                     vppm.refAnuncio = "#" + String.Format("{0:000}", p.anuncio.id);
  80.                     vppm.valorInvestimento = p.anuncio.valorInvestimento;
  81.                     vppm.idAnuncio = p.anuncio.id;
  82.                     vppm.statusDesc = getDescStatus(p.status);
  83.                     _listaModel.Add(vppm);
  84.                 }
  85.                 model.lista = _listaModel.ToPagedList(pagina, pageSize);
  86.             } catch (Exception e){
  87.                 Debug.WriteLine("Erro viewAllPropPropriedadeIM PropostaInvestimentoController: " + e.Message);
  88.             }
  89.             return View(model);
  90.         }  
  91.  
  92. HTML
  93.  
  94. @model SearchPropostaPropriedadeModel
  95. @using PagedList.Mvc
  96.  
  97. @{
  98.     ViewBag.Title = "viewAllPropPropriedadeIM";
  99.     Layout = "~/Views/Shared/_LayoutAdministracao.cshtml";
  100. }
  101.  
  102. <!--consulta-->
  103. <div class="panel panel-red">
  104.     <div class="panel-body">
  105.  
  106.     <h1>@Model.dtIni</h1>
  107.     <h1>@Model.dtFim</h1>
  108.  
  109.         @using (Html.BeginForm("viewAllPropPropriedadeIM", "PropostaInvestimento", FormMethod.Get, new { Class = "form-inline", role = "form" }))        {
  110.                
  111.  
  112.             <div class="form-group">  
  113.                 <div class="input-group">                    
  114.                     @Html.TextBoxFor(model => model.dtIni, new{
  115.                                                                
  116.                                                                Class = "form-control date",
  117.                                                                placeholder = "Data inicial",
  118.                                                                style = "z-index:0 !important;"
  119.                                                            })
  120.                     <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
  121.                 </div>
  122.             </div>
  123.  
  124.             <div class="form-group">
  125.                 <div class="input-group">                    
  126.                     @Html.TextBoxFor(model => model.dtFim, new{
  127.                                                                Class = "form-control date",
  128.                                                                placeholder = "Data final",
  129.                                                                style = "z-index:0 !important;"                                                                                                                          
  130.                                                            })
  131.                     <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
  132.                 </div>
  133.             </div>
  134.  
  135.             <div class="form-group">
  136.                 <div class="input-group">                    
  137.                     @Html.DropDownListFor(model => model.statusSelected, Model.status, new{
  138.                                                                                            Class = "form-control",
  139.                                                                                            placeholder = "Status",
  140.                                                                                            style = "z-index:0 !important;"
  141.                                                                                        })
  142.                     @*<input type="text" class="form-control money2" placeholder="Investimento máximo USD$" id="max" name="max" size="25" style="z-index:0 !important;" />*@
  143.                 </div>
  144.             </div>
  145.  
  146.             <button type="submit" class="btn btn-default glyphicon glyphicon-search"></button>
  147.         }
  148.  
  149.     </div><!--/panel body-->
  150. </div><!--/panel-->
  151. <!--/consulta-->
  152.  
  153.  
  154. <div class="panel panel-red center-block">
  155.     <div class="panel-heading bg-red clearfix">
  156.         <strong>Propostas de investimentos em propriedades</strong>
  157.     </div>
  158.     <div class="panel-body">
  159.         <table class="table table-bordered table-responsive table-striped table-hover" id="tableView">
  160.             <thead class="CabecalhoTabela">
  161.                 <tr>
  162.                     <th>#ID</th>
  163.                     <th>Data</th>
  164.                     <th>Investidor</th>
  165.                     <th>Ref.Anúncio</th>
  166.                     <th>Investimento USD$</th>
  167.                     <th>Status</th>                  
  168.                     <th>Controles</th>
  169.                 </tr>
  170.             </thead>
  171.             <tbody class="conteudoTabela">
  172.                 @foreach (ViewPropostasPropriedadeModel m in Model.lista){
  173.                     <tr>
  174.                         <td class="text-right">@Html.DisplayFor(i => m.id)</td>
  175.                         <td class="text-center">@Html.DisplayFor(i => m.dtPedido)</td>
  176.                         <td>@Html.DisplayFor(i => m.investidorNome)</td>
  177.                         <td class="text-center">@Html.DisplayFor(i => m.refAnuncio)</td>
  178.                         <td class="text-right">@Html.DisplayFor(i => m.valorInvestimento)</td>
  179.                         <td class="text-center">@Html.DisplayFor(i => m.statusDesc)</td>                      
  180.                         <td>
  181.                             @*@Html.ActionLink(" ", "edit", "Propriedade", new { id = EncodingParams.encode(Convert.ToString(@m.id)) }, new { Class = "glyphicon glyphicon-pencil", title = "editar" })*@                            
  182.                             @Html.ActionLink(" ", "detailPesquisa", "Pesquisa", new { id = EncodingParams.encode(Convert.ToString(@m.id)) }, new { Class = "glyphicon glyphicon-eye-open ", title = "detalhar" })
  183.                         </td>
  184.                     </tr>
  185.                 }
  186.             </tbody>
  187.         </table>
  188.     </div>
  189.     <div class="panel-footer">
  190.         Pagina @Model.lista.PageNumber de @Model.lista.PageCount
  191.         @Html.PagedListPager(Model.lista, page => Url.Action("viewAllPropPropriedadeIM", new { pagina = page, Model.dtIni, Model.dtFim, Model.statusSelected }))
  192.     </div>
  193. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement