Beispiel #1
0
 public CharactersController(MarvelLibraryContext context, CharacterService charService, FavService favService, AccountService accountService)
 {
     _context        = context;
     _charService    = charService;
     _favService     = favService;
     _accountService = accountService;
 }
Beispiel #2
0
        private async void Delete_Tapped(object sender, EventArgs e)
        {
            using (UserDialogs.Instance.Loading(""))
            {
                try
                {
                    var        s         = (TappedEventArgs)e;
                    var        castedObj = s.Parameter as Favourite;
                    FavService fs        = new FavService();

                    bool r = await fs.DeleteFavorite(castedObj).ConfigureAwait(false);

                    if (r)
                    {
                        IntroPageViewModel ivm = new IntroPageViewModel();
                        ivm.Initializefavourites();
                    }
                }
                catch (Exception ex)
                {
                    var log = ex;
                    LogService.LogErrors(ex.ToString());
                }
            }
        }
Beispiel #3
0
        private async void TapPlus_Tapped(object sender, EventArgs e)
        {
            using (Acr.UserDialogs.UserDialogs.Instance.Loading(""))
            {
                try
                {
                    var img  = sender as Image;
                    var item = img.BindingContext as NewCategoryDetailModel.Deal;
                    //var item2 = img.BindingContext as Category;
                    //Application.Current.MainPage.Navigation.PushAsync(new Favorites(item), true);
                    FavService fs        = new FavService();
                    Favourite  favourite = new Favourite()
                    {
                        Address     = item.Owner_Location,
                        Description = item.Details,
                        ImageURL    = item.ImagePath,
                        Name        = item.Name,
                        UserId      = GlobalStaticFields.Username,
                        Id          = Convert.ToInt32(item.Id)
                    };

                    var result = await fs.SaveFavorites(favourite);

                    if (result)
                    {
                        RefreshFavourites();

                        await DisplayAlert("", "Great!! Just added " + item.Name + " to your list of favorites", "Ok");
                    }
                    else
                    {
                        await DisplayAlert("", "Sorry!! Could not add " + item.Name + " to your list of favorites right now.", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    var log = ex;
                    await DisplayAlert("", "Sorry. Error occured", "Ok");

                    await LogService.LogErrorsNew(error : ex.Message.ToString());
                }
            }
        }