protected async Task SaveUserCommand() { var userService = DependencyResolver.Container.GetService <IUserService>(); try { ThrowExceptionIfInvalidDomain(Domain); //Service var result = userService.AddUser(Domain); if (result) { //Database Repository.Save(Domain); UnitWork.Commit(); //TODO .: Use internationalization for messages. await ActionMessage.DisplayAlert("Success", "User registered successfully.", "Ok"); Renew(); } else { await ActionMessage.DisplayAlert("Fail", "Service error.", "Ok"); } } catch (Exception invalidDomainException) { ActionMessage.DisplayAlert("Error", invalidDomainException.Message, "Ok"); } }
protected async Task ExecuteLoginCommand() { var userService = DependencyResolver.Container.GetService <IUserService>(); try { ThrowExceptionIfInvalidDomain(Domain); var result = userService.ValidateUser(Domain.Name, Domain.Password); if (result) { await Navigation.PushAsync(new RootPage()); } } catch (Exception invalidDomainException) { ActionMessage.DisplayAlert("Error", invalidDomainException.Message, "Ok"); } }