Пример #1
0
        public async Task <int> Edit(JokeViewModel model)
        {
            var joke = _repository.All().FirstOrDefault(x => x.Id == model.Id);

            joke.Content    = model.Content;
            joke.CategoryId = model.CategoryId;

            _repository.Update(joke);
            await _repository.SaveChangesAsync();

            return(joke.Id);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="viewModel">The JokeViewModel</param>
        public JokeDetailPage(JokeViewModel viewModel)
        {
            InitializeComponent();

            var jokeStore   = new SQLiteJokeStore(new SQLiteDb());
            var pageService = new PageService();

            // Set Title based on Text Content
            Title = (viewModel.Text == null) ? "New Joke" : "Edit Joke";

            BindingContext = new JokeDetailViewModel(viewModel ?? new JokeViewModel(), jokeStore, pageService);
        }
Пример #3
0
        public JokePage()
        {
            InitializeComponent();

            MessagingCenter.Subscribe <JokeViewModel>(this, "StoredJoke", (sender) =>
            {
                DisplayAlert("Alert", "Joke has been stored.", "OK");
            });
            //btnFetchJoke.BackgroundColor = Color.FromHex(ColorPaletteHelper.Green);
            //btnStoreJoke.BackgroundColor = Color.FromHex(ColorPaletteHelper.Yellow);

            BindingContext = new JokeViewModel(this);
        }
Пример #4
0
        public async Task <IActionResult> Edit(JokeViewModel model)
        {
            var id = await _jokesService.Edit(model);

            return(RedirectToAction("Details", new { id = id }));
        }
Пример #5
0
 public JokePage(string category)
 {
     InitializeComponent();
     BindingContext = viewModel = new JokeViewModel(category);
 }