Skip to content

Instantly share code, notes, and snippets.

@brunoportess
Last active November 4, 2017 02:30
Show Gist options
  • Save brunoportess/fff1addc44fda2fb02a0ada50ae249af to your computer and use it in GitHub Desktop.
Save brunoportess/fff1addc44fda2fb02a0ada50ae249af to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cliente.Models.Entities
{
public class Orcamento
{
public string Nome { get; set; }
public string ValorMaximo { get; set; }
public string Mensagem { get; set; }
public string Prazo { get; set; }
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
x:Class="Cliente.Views.Orcamento.OrcamentoMensagem"
Title="mensagem">
<StackLayout
Margin="10">
<Label Text="Nome" VerticalTextAlignment="Center" FontSize="Medium"/>
<Entry Placeholder="Escreva seu nome" Text="{Binding DadosOrcamento.Nome, Mode=TwoWay}" HorizontalOptions="FillAndExpand"/>
<Label Text="Valor máximo" VerticalTextAlignment="Center" FontSize="Medium"/>
<Entry Placeholder="0.00" Text="{Binding DadosOrcamento.ValorMaximo, Mode=TwoWay}" Keyboard="Numeric" HorizontalOptions="FillAndExpand" />
<Label Text="Prazo" VerticalTextAlignment="Center" FontSize="Medium"/>
<DatePicker
HorizontalOptions="FillAndExpand"
Date="{Binding DadosOrcamento.Prazo, Mode=TwoWay}"
MinimumDate="{Binding PrazoMinimo}"
Format="dd/MM/yyyy">
</DatePicker>
<Label Text="Mensagem" FontSize="Medium"/>
<Editor Text="{Binding DadosOrcamento.Mensagem, Mode=TwoWay}" HeightRequest="150"/>
<!--<Button Text="Solicitar orçamento" Command="{Binding SolicitarCommand}" />-->
</StackLayout>
</ContentPage>
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using Cliente.Helpers;
using Cliente.Models.Entities;
using Prism.Navigation;
using Prism.Services;
namespace Cliente.ViewModels.Orcamento
{
public class OrcamentoTabbedViewModel : BaseViewModel
{
private INavigationService _navigationService;
private readonly IPageDialogService _dialogService;
public DelegateCommand EnviaOrcamentoCommand { get; set; }
private string _nome = Settings.UserNomeSettings;
public string Nome
{
get => _nome;
set => SetProperty(ref _nome, value);
}
private string _valorMaximo;
public string ValorMaximo
{
get => _valorMaximo;
set => SetProperty(ref _valorMaximo, value);
}
private string _mensagem = "";
public string Mensagem
{
get => _mensagem;
set => SetProperty(ref _mensagem, value);
}
private DateTime _prazo;
public DateTime Prazo
{
get => _prazo;
set => SetProperty(ref _prazo, value);
}
private Models.Entities.Orcamento _dadosOrcamento;
public Models.Entities.Orcamento DadosOrcamento
{
get => _dadosOrcamento;
set => SetProperty(ref _dadosOrcamento, value);
}
private DateTime _prazoMinimo = DateTime.Now;
public DateTime PrazoMinimo
{
get => _prazoMinimo;
set => SetProperty(ref _prazoMinimo, value);
}
private List<EmpresaLista> _listCompanies;
public List<EmpresaLista> ListCompanies
{
get => _listCompanies;
set => SetProperty(ref _listCompanies, value);
}
public OrcamentoTabbedViewModel(INavigationService navigationService, IPageDialogService dialogService)
{
DadosOrcamento = new Models.Entities.Orcamento {Nome = Settings.UserNomeSettings};
_navigationService = navigationService;
_dialogService = dialogService;
EnviaOrcamentoCommand = new DelegateCommand(ExecuteEnviaOrcamentoCommand);
}
private void ExecuteEnviaOrcamentoCommand()
{
var empresas = ListCompanies.FirstOrDefault(l => l.EnviaOrcamento);
if (empresas != null) _dialogService.DisplayAlertAsync("Oops", "Selecione alguma empresa", "OK");
}
public override void OnNavigatingTo(NavigationParameters parameters)
{
if (parameters.ContainsKey("listaEmpresas"))
{
ListCompanies = (List<EmpresaLista>)parameters["listaEmpresas"];
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment