private async void CheckSubjectAction_ExecuteAsync(Object sender, SimpleActionExecuteEventArgs e) { var selectedSpecificationEnum = selectCheckSpecificationActionController.SelectedSpecification; var selectedSpecificationName = selectedSpecificationEnum.ToString().RemoveUnderline(); CheckSubject currentObject = ((DetailView)View).CurrentObject as CheckSubject; if (currentObject.Date == new DateTime()) { currentObject.Date = DateTime.Now; } var selectedSpecificationData = currentObject.GetType().GetProperty($"{selectedSpecificationName}").GetValue(currentObject) as IList; if (!DataIsValid(currentObject, selectedSpecificationData)) { return; } subjectService = new SubjectService(); var selectedSpecificationObject = new CheckSpecificationData { SelectedSpecification = ((BaseSpecification)selectedSpecificationData[0]).Number, BankAccount = currentObject.BankAccount[0].Number }; var response = await subjectService.CheckSubject(selectedSpecificationObject, selectedSpecificationEnum, currentObject.Date); ShowNewDetailView(response); }
private bool DataIsValid(CheckSubject currentObject, IList selectedSpecificationData) { if (selectedSpecificationData == null || selectedSpecificationData.Count == 0) { ErrorService.ShowError(this, selectedSpecificationData.GetType().GetGenericArguments().First().Name, "Pole nie może być puste"); return(false); } if (currentObject.BankAccount == null || currentObject.BankAccount.Count == 0) { ErrorService.ShowError(this, currentObject.BankAccount.GetType().GetGenericArguments().First().Name, "Pole nie może być puste"); return(false); } return(true); }