private void OnAdd(object param) { Movie movie = DataUtil.GetRandomMovie(); conflictsEntity entity = new conflictsEntity(); entity.Title = movie.Title; entity.Score = movie.Rating; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { transaction.GetModelSet <conflictsEntity>().InsertOnSubmit(entity); transaction.SubmitChanges(); } this.Entities.Add(entity); }
private void ScoreSelected(object arg) { int value = (int)arg; if (Mobeelizer.CheckSyncStatus().IsRunning()) { navigationService.ShowMessage(Resources.Errors.e_title, Resources.Errors.e_waitUntilSyncFinish); } else { using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var query = from conflictsEntity e in transaction.GetModelSet <conflictsEntity>() where e.Guid == modelGuid select e; conflictsEntity entity = query.Single(); entity.Score = value; transaction.SubmitChanges(); } this.navigationService.GoBack(); } }
public SelectScorePageViewModel(INavigationService navigationService, String modelGuid) : base(navigationService) { ICommand selectCommand = new DelegateCommand(ScoreSelected); this.modelGuid = modelGuid; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var query = from conflictsEntity e in transaction.GetModelSet <conflictsEntity>() where e.Guid == modelGuid select e; conflictsEntity entity = query.Single(); this.Title = entity.Title; } this.Options = new ObservableCollection <ListOption>(); for (int i = 1; i < 6; ++i) { this.Options.Add(new ListOption() { Score = i, Command = selectCommand }); } }