private async Task SaveAchievement() { var model = AchievementRepository.GetAchievementAsync(_achievementId); model.Description = Description; model.Title = Title; model.GeneralTimeSpent = GeneralTimeSpent; model.AchievementSteps = AchievementSteps.ToAchievementStepViewModels(); AchievementRepository.Save(model); if (_stepsToDelete.Any()) { foreach (var stepViewModel in _stepsToDelete) { var stepToDelete = AchievementStepRepository.GetAchievementStepAsync(stepViewModel.Id); AchievementStepRepository.DeleteAchievementStep(stepToDelete); } _stepsToDelete.Clear(); } if (GeneralTimeSpent >= 10000) { // TODO: make custom alert (at top of screen with animation) await UserDialogs.Instance.AlertAsync("Achieved"); model.AchievedDate = DateTime.Now; } await NavigationService.NavigateBackAsync(); }
public override Task InitializeAsync(object navigationData) { _achievementId = (int)navigationData; if (_achievementId == 0) { Title = Resmgr.Value.GetString(ConstantsHelper.CreateAchievement, CultureInfo.CurrentCulture); } else { var model = AchievementRepository.GetAchievementAsync(_achievementId); GeneralTimeSpent = model.GeneralTimeSpent; Title = model.Title; Description = model.Description; AchievementSteps = model.AchievementSteps.ToAchievementStepViewModels(); } return(base.InitializeAsync(navigationData)); }