Merge pull request #8 from syncfusion/Update-Nuget-Version

Added validation to Expense description..
This commit is contained in:
samsudeenks 2018-05-07 21:10:13 +05:30 коммит произвёл GitHub
Родитель abf56c6280 7a2ef63b79
Коммит 3e3a351361
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 21 добавлений и 14 удалений

Просмотреть файл

@ -20,11 +20,12 @@ namespace ExpenseAnalysis
public class AddTransactionDetail
{
public double Spent { get; set; }
public CategoryPicker Category { get; set; }
[Display(Name = "Expense Description")]
[Required(AllowEmptyStrings = false, ErrorMessage = "Description should not be empty")]
public string ExpenseDescription { get; set; }
public DateTime Date { get; set; }

Просмотреть файл

@ -8,6 +8,8 @@ namespace ExpenseAnalysis
{
public TransactionPage TransactionPage;
bool isDescriptionValid;
public AddTransactionsPage()
{
InitializeComponent();
@ -15,20 +17,24 @@ namespace ExpenseAnalysis
private void DoneButton_Clicked(object sender, EventArgs e)
{
var newTransaction = ((ExpenseViewModel)BindingContext).SingleTransaction;
if (newTransaction.Spent != 0)
{
var transaction = new TransactionDetail
{
Category = newTransaction.Category.ToString(),
Date = newTransaction.Date,
Spent = newTransaction.Spent,
Name = newTransaction.ExpenseDescription
};
((ExpenseViewModel)BindingContext).AddTransaction(transaction);
TransactionPage.CanNotify = true;
isDescriptionValid = dataForm.Validate("ExpenseDescription");
if (isDescriptionValid)
{
var newTransaction = ((ExpenseViewModel)BindingContext).SingleTransaction;
if (newTransaction.Spent != 0)
{
var transaction = new TransactionDetail
{
Category = newTransaction.Category.ToString(),
Date = newTransaction.Date,
Spent = newTransaction.Spent,
Name = newTransaction.ExpenseDescription
};
((ExpenseViewModel)BindingContext).AddTransaction(transaction);
TransactionPage.CanNotify = true;
}
Navigation.PopToRootAsync();
}
Navigation.PopToRootAsync();
}
private void DataForm_AutoGeneratingDataFormItem(object sender, AutoGeneratingDataFormItemEventArgs e)