Ejemplo n.º 1
0
        private async void OnShare()
        {
            if (!(ReceiverEmail.Contains("@") && ReceiverEmail.Contains(".")))
            {
                EmailError = "Please enter valid email!";
                return;
            }


            var      startDate = DateTime.UtcNow.ToLocalTime();
            DateTime endDate;

            try
            {
                endDate = DateTime.Parse(GetExpireDate());
            }
            catch (FormatException)
            {
                ExpireDateResult = "Date format is invalid";
                return;
            }

            if (startDate >= endDate)
            {
                ExpireDateResult = "Start date is later than expire date!";
                return;
            }
            IsBusy = true;
            var loginDataToShare = await DataStore.GetItemAsync(ItemId);

            var password = EncService.Decrypt(SecureStorageHelper.GetUserKey().Result,
                                              loginDataToShare.Password);
            LoginData newLoginData = new LoginData()
            {
                Name     = loginDataToShare.Name + " From " + SecureStorageHelper.GetUserEmail(),
                Login    = loginDataToShare.Login,
                Password = EncService.Encrypt(App.AppSettings.SecretEncryptionKey, password),
                Website  = loginDataToShare.Website,
                Email    = loginDataToShare.Email ?? "Not added"
            };
            var model = new ShareLoginModel
            {
                LoginData     = newLoginData,
                ReceiverEmail = ReceiverEmail,
                StartDate     = startDate,
                EndDate       = endDate
            };
            var apiResponse = await _apiService.HandleLoginShare(model);

            IsBusy = false;
            if (!apiResponse.Success)
            {
                MessagingCenter.Send(this, "ShareNotify", apiResponse.Messages.First());
                return;
            }
            MessagingCenter.Send(this, "ShareNotify", apiResponse.Messages.First());
            await App.Current.MainPage.Navigation.PopModalAsync();
        }
Ejemplo n.º 2
0
        private async void OnSave()
        {
            IsBusy = true;
            LoginData newLoginData = new LoginData()
            {
                Id       = Int32.Parse(Id),
                Name     = Name,
                Login    = Login,
                Password = EncService.Encrypt(SecureStorageHelper.GetUserKey().Result, Password),
                Website  = Website,
                Email    = Email ?? "Not added",
                UserId   = SecureStorageHelper.GetUserId().Result
            };

            await DataStore.UpdateItemAsync(newLoginData);

            IsBusy = false;
            // This will pop the current page off the navigation stack
            await App.Current.MainPage.Navigation.PopModalAsync();
        }