Exemplo n.º 1
0
        private async Task AddFarmerVisitAsync()
        {
            try
            {
                AddFarmerVisitRequest request = RefrenceTypeValidatables.Populate <AddFarmerVisitRequest>();
                if (Validate(request).IsValidOverall&& Validator.Validate(request).IsValid)
                {
                    AddFarmerVisitResponse result = await mediator.Send(request).ConfigureAwait(false);

                    switch (result)
                    {
                    case null:
                        ResponseMessage = ConstantsViewModel.AddFarmerVisitResponseNull;
                        break;

                    default:
                        ResponseMessage = result.Message;
                        ResetValidateableFields();
                        break;
                    }
                    IsResponseVisible = true;
                }
            }
            catch (Exception Exception)
            {
                Console.WriteLine(Exception.Message);
            }
            return;
        }
        private async Task LoginMethodAsync()
        {
            try
            {
                LoginRequest login = RefrenceTypeValidatables.Populate <LoginRequest>();
                if (Validate(login).IsValidOverall&& Validator.Validate(login).IsValid)
                {
                    LoginResponse result = await mediator.Send(login).ConfigureAwait(false);

                    if (result == null)
                    {
                        ResponseMessage   = ConstantsViewModel.LoginResponseNull;
                        IsResponseVisible = true;
                    }
                    else
                    {
                        if (result.Success)
                        {
                            IsResponseVisible = false;
                            var item = AddSettingsRequest.CreateSettingRequest(ConstantFlags.LoginFlag, true.ToString());
                            AddSettingsResponse response = await mediator.Send(item).ConfigureAwait(false);

                            if (!response.Success)
                            {
                                Console.WriteLine(ConstantsViewModel.SettingSaveFailure);
                            }

                            await NavigationService.Navigate <MasterDetailViewModel>();

                            await NavigationService.Close(this);
                        }
                        else
                        {
                            ResponseMessage   = result.Message;
                            IsResponseVisible = true;
                        }
                    }
                }
            }
            catch (Exception Exception)
            {
                Console.WriteLine(Exception.Message);
            }
            return;
        }
Exemplo n.º 3
0
        private async Task AddFarmerAsync()
        {
            AddNewFarmerRequest validObj = RefrenceTypeValidatables.Populate <AddNewFarmerRequest>();

            if (Validate(validObj).IsValidOverall&& Validator.Validate(validObj).IsValid)
            {
                var addNewFarmerRequest = AddNewFarmerRequest.CreateAddNewFarmerRequest(validObj.MobileNo, validObj.FarmerName, validObj.Acre, validObj.Area);

                AddNewFarmerResponse result = await mediator.Send(addNewFarmerRequest).ConfigureAwait(false);

                if (result == null)
                {
                    ResponseMessage = ConstantsViewModel.AddFarmerResponseNull;
                }
                else if (result.Success)
                {
                    ResetValidateableFields();

                    ResponseMessage = result.Message;
                }
                IsResponseVisible = true;
            }
        }