protected override IEnumerable <IGrouping <string, Session> > GetGroupedItems()
        {
            var allSessions = SessionManager.GetSessions();

            if (FilterFavorites)
            {
                var favs = FavoritesManager
                           .GetFavorites()
                           .Select(f => f.SessionKey)
                           .ToDictionary(x => x);
                return(from s in allSessions
                       where favs.ContainsKey(s.Key)
                       group s by GetGroupKey(s));
            }
            else if (FilterDayOfWeek.HasValue)
            {
                return(from s in allSessions
                       where s.Start.DayOfWeek == FilterDayOfWeek.Value
                       group s by GetGroupKey(s));
            }
            else
            {
                return(from s in allSessions
                       group s by GetGroupKey(s));
            }
        }
Exemplo n.º 2
0
        public GreenWerx.Models.App.ServiceResult Update(Favorite s)
        {
            if (s == null)
            {
                return(ServiceResponse.Error("Invalid Favorite sent to server."));
            }

            FavoritesManager favoriteManager = new FavoritesManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            var res = favoriteManager.Get(s.UUID);

            if (res.Code != 200)
            {
                return(res);
            }

            var dbS = (Favorite)res.Result;

            if (dbS.DateCreated == DateTime.MinValue)
            {
                dbS.DateCreated = DateTime.UtcNow;
            }
            dbS.Deleted   = s.Deleted;
            dbS.Name      = s.Name;
            dbS.Status    = s.Status;
            dbS.SortOrder = s.SortOrder;
            dbS.Active    = s.Active;
            dbS.ItemUUID  = s.ItemUUID;
            dbS.ItemType  = s.ItemType;

            return(favoriteManager.Update(dbS));
        }
Exemplo n.º 3
0
        public ServiceResult GetFavorites(string type)
        {
            if (Request.Headers.Authorization == null || string.IsNullOrWhiteSpace(this.GetAuthToken(Request)))
            {
                return(ServiceResponse.Error("You must be logged in to access this functionality."));
            }

            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }

            FavoritesManager favoriteManager = new FavoritesManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            var tmp = favoriteManager.GetFavorites(type, CurrentUser.UUID, CurrentUser.AccountUUID);

            if (tmp == null)
            {
                return(ServiceResponse.OK("", null, 0));
            }

            List <dynamic> Favorites = tmp.Cast <dynamic>()?.ToList();

            DataFilter filter = this.GetFilter(Request);

            Favorites = Favorites.Filter(ref filter);

            return(ServiceResponse.OK("", Favorites, filter.TotalRecordCount));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Used in ViewWillAppear (SessionsScreen, SessionDayScheduleScreen)
 /// to sync favorite-stars that have changed in other views
 /// </summary>
 public void UpdateFavorite()
 {
     if (showSession != null)
     {
         UpdateImage(FavoritesManager.IsFavorite(showSession.Key));
     }
 }
Exemplo n.º 5
0
 private void RemoveBookFromFavorites(object obj)
 {
     if (obj is Book book)
     {
         FavoritesManager.RemoveBookFromFavorites(book);
     }
 }
Exemplo n.º 6
0
 private void AddBookToFavorites(object obj)
 {
     if (obj is Book book)
     {
         FavoritesManager.AddBookToFavorites(book);
     }
 }
Exemplo n.º 7
0
 private static void Initialize()
 {
     Log("Initializing...");
     CustomUI.Initialize();
     FavoritesManager.CreateFavoritesFileIfNotExists();
     NetworkManager.Initialize();
     isInitialized = true;
 }
        public void UpdateIsFavorite()
        {
            IsFavorite         = FavoritesManager.IsFavorite(Key);
            FavoriteVisibility = IsFavorite ? Visibility.Visible : Visibility.Collapsed;

            OnPropertyChanged("IsFavorite");
            OnPropertyChanged("FavoriteVisibility");
        }
        public void UpdateCell(Session showSession, string big, string small)
        {
            session = showSession;
            UpdateImage(FavoritesManager.IsFavorite(session.Key));

            titleLabel.Font = bigFont;
            titleLabel.Text = big;

            speakerLabel.Text = small;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_product_detail);

            SupportActionBar.SetTitle(Resource.String.detail);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            var id = Intent.GetLongExtra("product_id", -1);

            if (id < 0)
            {
                Finish();
            }
            product = AppData.Products.Find(x => x.Id == id);

            ImageView productImage = FindViewById <ImageView>(Resource.Id.detailProductImage);


            Utils.AsyncImageSet(product.Photo, productImage);

            TextView       productTitle       = FindViewById <TextView>(Resource.Id.detailProductName);
            TextView       productDescription = FindViewById <TextView>(Resource.Id.detailProductDescription);
            TextView       productDiscount    = FindViewById <TextView>(Resource.Id.detailProductSale);
            TextView       productValue       = FindViewById <TextView>(Resource.Id.detailProductPrice);
            TextView       itemCountText      = FindViewById <TextView>(Resource.Id.detailQuantity);
            RelativeLayout discountLayout     = FindViewById <RelativeLayout>(Resource.Id.detailSaleLayout);


            var discount = AppData.CurrentCart.DiscountFor(product);
            var price    = AppData.CurrentCart.PriceFor(product);
            var quantity = AppData.CurrentCart.QuantityFor(product);


            productTitle.Text         = product.Name;
            productDescription.Text   = product.Description;
            itemCountText.Text        = string.Format("{0} UN", quantity);
            productValue.Text         = price.ToString("C", CultureInfo.CreateSpecificCulture("pt-BR"));
            itemCountText.Text        = string.Format("{0} UN", quantity);
            discountLayout.Visibility = discount <= 0.0 ? ViewStates.Invisible : ViewStates.Visible;
            productDiscount.Text      = String.Format("↓{0:0.0}%", discount).Replace(".", ",");


            Button addButton = FindViewById <Button>(Resource.Id.addButon);
            Button subButton = FindViewById <Button>(Resource.Id.subButon);

            addButton.Click += AddButton_Click;
            subButton.Click += SubButton_Click;;

            ImageButton favButton = FindViewById <ImageButton>(Resource.Id.favoriteBtn);

            favButton.Click += FavButton_Click;
            favButton.SetImageResource(FavoritesManager.GetInstance().IsFavorite(product) ? Resource.Mipmap.ic_star : Resource.Mipmap.ic_star_border);
        }
Exemplo n.º 11
0
        public ServiceResult GetBy(string uuid)
        {
            if (string.IsNullOrWhiteSpace(uuid))
            {
                return(ServiceResponse.Error("You must provide a name for the Favorite."));
            }

            FavoritesManager favoriteManager = new FavoritesManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            return(favoriteManager.Get(uuid));
        }
Exemplo n.º 12
0
        public ActionResult GetProducts(List <FavoriteProduct> favoritesModel)
        {
            var model = new FavoritesModel();

            if (favoritesModel != null)
            {
                model.FavoriteProducts = FavoritesManager.GetFavoriteProducts(favoritesModel);
            }


            return(PartialView(PathFromView("Partials/Favorites/_FavoriteItemPartial"), model));
        }
 void OnFavoriteButtonClicked(object sender, EventArgs args)
 {
     if (FavoritesManager.GetInstance().IsFavorite(CurrentProduct))
     {
         FavoritesManager.GetInstance().RemoveFavorite(CurrentProduct);
     }
     else
     {
         FavoritesManager.GetInstance().AddFavorite(CurrentProduct);
     }
     UpdateFavorite();
 }
Exemplo n.º 14
0
        public void OnClick(View v)
        {
            if (FavoritesManager.GetInstance().IsFavorite(product))
            {
                FavoritesManager.GetInstance().RemoveFavorite(product);
            }
            else
            {
                FavoritesManager.GetInstance().AddFavorite(product);
            }

            favButton.SetImageResource(FavoritesManager.GetInstance().IsFavorite(product) ? Resource.Mipmap.ic_star : Resource.Mipmap.ic_star_border);
        }
 void UpdateFavorite()
 {
     if (FavoritesManager.GetInstance().IsFavorite(CurrentProduct))
     {
         favoritedBtn.SetTitle("★", UIControlState.Normal);
         favoritedBtn.TintColor = UIColor.Gray;
     }
     else
     {
         favoritedBtn.SetTitle("☆", UIControlState.Normal);
         favoritedBtn.TintColor = UIColor.LightGray;
     }
 }
Exemplo n.º 16
0
        public ServiceResult Insert(Favorite s)
        {
            if (s == null)
            {
                return(ServiceResponse.Error("Invalid data sent."));
            }

            string         authToken      = Request.Headers.Authorization?.Parameter;
            SessionManager sessionManager = new SessionManager(Globals.DBConnectionKey);

            UserSession us = sessionManager.GetSession(authToken);

            if (us == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }

            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }

            if (string.IsNullOrWhiteSpace(s.AccountUUID) || s.AccountUUID == SystemFlag.Default.Account)
            {
                s.AccountUUID = CurrentUser.AccountUUID;
            }

            if (string.IsNullOrWhiteSpace(s.CreatedBy))
            {
                s.CreatedBy = CurrentUser.UUID;
            }

            if (s.DateCreated == DateTime.MinValue)
            {
                s.DateCreated = DateTime.UtcNow;
            }

            s.Active  = true;
            s.Deleted = false;

            FavoritesManager favoriteManager = new FavoritesManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            ServiceResult sr = favoriteManager.Insert(s);

            if (sr.Code != 200)
            {
                return(sr);
            }

            return(sr);
        }
Exemplo n.º 17
0
        public ActionResult Email(FavoritesEmailModel model)
        {
            if (ModelState.IsValid)
            {
                model.Brand    = this.CurrentBrand;
                model.FavProds = string.IsNullOrEmpty(model.FavCodes) ? new List <String>() : model.FavCodes.Split(',').Where(f => !string.IsNullOrEmpty(f)).ToList();
                FavoritesManager.EmailFavs(model);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 18
0
        private Venue[] GetAllShows(Show[] shows)
        {
            var result =
                new [] {
                new Venue(new Entity(), null)
                {
                    Shows = shows
                            .Where(s => !ShowOnlyFavorites || FavoritesManager.IsShowFavorite(OrgEvent.Id, s))
                            .OrderBy(s => s, new ShowComparer(SortBy))
                            .ToArray()
                }
            };

            return(result);
        }
Exemplo n.º 19
0
        public ServiceResult Delete(string uuid)
        {
            if (string.IsNullOrWhiteSpace(uuid))
            {
                return(ServiceResponse.Error("Invalid id was sent."));
            }

            FavoritesManager favoriteManager = new FavoritesManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            var fav = favoriteManager.Get(uuid);

            if (fav.Code != 200)
            {
                return(fav);
            }
            return(favoriteManager.Delete((Favorite)fav.Result, true));
        }
        private void FavButton_Click(object sender, EventArgs e)
        {
            if (FavoritesManager.GetInstance().IsFavorite(product))
            {
                FavoritesManager.GetInstance().RemoveFavorite(product);
            }
            else
            {
                FavoritesManager.GetInstance().AddFavorite(product);
            }

            ImageButton favButton = FindViewById <ImageButton>(Resource.Id.favoriteBtn);

            favButton.SetImageResource(FavoritesManager.GetInstance().IsFavorite(product) ? Resource.Mipmap.ic_star : Resource.Mipmap.ic_star_border);
            UpdateData();
        }
 bool ToggleFavorite()
 {
     if (FavoritesManager.IsFavorite(session.Key))
     {
         FavoritesManager.RemoveFavoriteSession(session.Key);
         return(false);
     }
     else
     {
         var fav = new Favorite {
             SessionID = session.ID, SessionKey = session.Key
         };
         FavoritesManager.AddFavoriteSession(fav);
         return(true);
     }
 }
Exemplo n.º 22
0
        public ServiceResult Get(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(ServiceResponse.Error("You must provide a name for the Favorite."));
            }

            FavoritesManager favoriteManager = new FavoritesManager(Globals.DBConnectionKey, this.GetAuthToken(Request));

            List <Favorite> s = favoriteManager.Search(name);

            if (s == null || s.Count == 0)
            {
                return(ServiceResponse.Error("Favorite could not be located for the name " + name));
            }

            return(ServiceResponse.OK("", s));
        }
        static void Main()
        {
            _movieDatabaseContext = new MovieDatabaseContext();
            //Load Managers
            _loginManager     = new LoginManager(new UserRepository(_movieDatabaseContext));
            _movieManager     = new MoviesManager(new MovieRepository(_movieDatabaseContext));
            _userManager      = new UserManager(new UserRepository(_movieDatabaseContext));
            _scoreManager     = new ScoreManager(new ScoreRepository(_movieDatabaseContext));
            _favoritesManager = new FavoritesManager(new FavoriteRepository(_movieDatabaseContext));
            _reviewsManager   = new ReviewsManager(new ReviewRepository(_movieDatabaseContext));
            _watchedManager   = new WatchedManager(new WatchedRepository(_movieDatabaseContext));
            _connection       = new Connection();

            Console.Title = "Server";
            SetupServer();
            Console.ReadLine();
            CloseAllSockets();
        }
Exemplo n.º 24
0
 bool ToggleFavorite()
 {
     if (FavoritesManager.IsFavorite(session.Key))
     {
         FavoriteButton.SetImage(new UIImage(AppDelegate.ImageNotFavorite), UIControlState.Normal);
         FavoritesManager.RemoveFavoriteSession(session.Key);
         return(false);
     }
     else
     {
         FavoriteButton.SetImage(new UIImage(AppDelegate.ImageIsFavorite), UIControlState.Normal);
         var fav = new Favorite {
             SessionID = session.ID, SessionKey = session.Key
         };
         FavoritesManager.AddFavoriteSession(fav);
         return(true);
     }
 }
Exemplo n.º 25
0
        private void HandleFavoriteClick(object sender, EventArgs e)
        {
            var vm = (SessionDetailsViewModel)DataContext;

            if (FavoritesManager.IsFavorite(vm.Key))
            {
                FavoritesManager.RemoveFavoriteSession(vm.Key);
                UpdateFavoriteButtonIcon(false);
            }
            else
            {
                FavoritesManager.AddFavoriteSession(new Favorite {
                    SessionKey = vm.Key,
                });
                UpdateFavoriteButtonIcon(true);
            }

            vm.UpdateIsFavorite();
        }
Exemplo n.º 26
0
        public ServiceResult DeleteEventFromFavorites(string eventUUID)
        {
            if (string.IsNullOrWhiteSpace(eventUUID))
            {
                return(ServiceResponse.Error("No id sent."));
            }

            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }

            FavoritesManager reminderManager = new FavoritesManager(Globals.DBConnectionKey, this.GetAuthToken(Request));
            var r = reminderManager.GetByEvent(eventUUID);

            if (r == null)
            {
                return(ServiceResponse.Error("Record does not exist for id."));
            }
            return(reminderManager.Delete(r, true));
        }
Exemplo n.º 27
0
        void Update()
        {
            titleLabel.Text = showSession.Title;
            timeLabel.Text  = showSession.Start.ToString("dddd") + " " +
                              showSession.Start.ToString("H:mm") + " - " +
                              showSession.End.ToString("H:mm");
            locationLabel.Text = showSession.Room;

            if (!String.IsNullOrEmpty(showSession.Overview))
            {
                descriptionTextView.Text      = showSession.Overview;
                descriptionTextView.Font      = UIFont.FromName("Helvetica-Light", AppDelegate.Font10_5pt);
                descriptionTextView.TextColor = UIColor.Black;
            }
            else
            {
                descriptionTextView.Font      = UIFont.FromName("Helvetica-LightOblique", AppDelegate.Font10_5pt);
                descriptionTextView.TextColor = UIColor.Gray;
                descriptionTextView.Text      = "No background information available.";
            }
            UpdateImage(FavoritesManager.IsFavorite(showSession.Key));
        }
Exemplo n.º 28
0
        public ActionResult SetFavorite()
        {
            var    res     = false;
            string message = null;
            var    id      = -1;

            try
            {
                var parameters = AjaxModel.GetAjaxParameters(HttpContext);
                var itemId     = AjaxModel.GetAjaxParameter("itemId", parameters);
                var appName    = AjaxModel.GetAjaxParameter("appName", parameters);
                var favorite   = new BLL.as_favorites {
                    appName = appName, created = DateTime.Now, itemID = int.Parse(itemId), userGuid = new BLL.Core.CoreManager().GetUserGuid()
                };
                id = new FavoritesManager().AddFavorites(favorite);
                if (id > 0)
                {
                    message = "Добавлено в избранное";
                    res     = true;
                }
                else
                {
                    message = "Ошибка добавления в избранное.";
                    res     = false;
                }
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
                message = "Ошибка добавления в избранное";
            }
            return(Json(new
            {
                result = res,
                msg = message,
                id = id
            }));
        }
        public List<FavoriteItem> GetRandomFavorites(int countOfWords, TranslateDirection direction)
        {
            IEnumerable<int> srcDefView = getSourceDefinitionByTranslateDirection(direction);
            IEnumerable<FavoriteItem> favView = getFavoritesBySourceDefinition(srcDefView);
            IEnumerable<FavoriteItem> favDistinctView = getFavoritesDistinct(favView);
            var favElements = favDistinctView.Distinct();

            int countOfRecords = favElements.Count();
            FavoritesManager favManager = new FavoritesManager(db);
            Random rnd = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
            int maxCountOfWords = countOfWords <= countOfRecords ? countOfWords : countOfRecords;
            List<FavoriteItem> items = new List<FavoriteItem>();
            List<int> usedIdList = new List<int>();
            for(int i=0;i< maxCountOfWords;i++)
            {
                int indexOfRecord = rnd.Next(0, maxCountOfWords - 1);
                if (usedIdList.Contains(indexOfRecord))
                    indexOfRecord = rnd.Next(0, maxCountOfWords - 1);
                //ToDo:нужна проверка в цикле, может быть ситуация с повторными ид
                items.Add(favElements.ElementAt(indexOfRecord));
                usedIdList.Add(indexOfRecord);
            }
            return items;
        }
        public LocationDialog(
            string apiKey,
            string prompt,
            BotState state,
            string dialogId         = DefaultLocationDialogId,
            bool skipPrompt         = false,
            bool useAzureMaps       = true,
            LocationOptions options = LocationOptions.None,
            LocationRequiredFields requiredFields   = LocationRequiredFields.None,
            LocationResourceManager resourceManager = null) : base(dialogId)
        {
            resourceManager = resourceManager ?? new LocationResourceManager();

            if (!options.HasFlag(LocationOptions.SkipFavorites) && state == null)
            {
                throw new ArgumentNullException(nameof(state),
                                                "If LocationOptions.SkipFavorites is not used then BotState object must be " +
                                                "provided to allow for storing / retrieval of favorites");
            }

            var favoriteLocations = state.CreateProperty <List <FavoriteLocation> >($"{nameof(LocationDialog)}.Favorites");
            var favoritesManager  = new FavoritesManager(favoriteLocations);

            IGeoSpatialService geoSpatialService;

            if (useAzureMaps)
            {
                geoSpatialService = new AzureMapsSpatialService(apiKey);
            }
            else
            {
                geoSpatialService = new BingGeoSpatialService(apiKey);
            }

            InitialDialogId = dialogId;

            AddDialog(new ChoicePrompt(PromptDialogIds.Choice));
            AddDialog(new TextPrompt(PromptDialogIds.Text));
            AddDialog(new ConfirmPrompt(PromptDialogIds.Confirm));

            AddDialog(new WaterfallDialog(InitialDialogId, new WaterfallStep[]
            {
                async(dc, cancellationToken) =>
                {
                    if (options.HasFlag(LocationOptions.SkipFavorites) ||
                        !favoritesManager.GetFavorites(dc.Context).Result.Any())
                    {
                        var isFacebookChannel = StringComparer.OrdinalIgnoreCase.Equals(
                            dc.Context.Activity.ChannelId, "facebook");

                        if (options.HasFlag(LocationOptions.UseNativeControl) && isFacebookChannel)
                        {
                            return(await dc.BeginDialogAsync(DialogIds.LocationRetrieverFacebookDialog));
                        }

                        return(await dc.BeginDialogAsync(DialogIds.LocationRetrieverRichDialog));
                    }

                    return(await dc.BeginDialogAsync(DialogIds.HeroStartCardDialog));
                },
                async(dc, cancellationToken) =>
                {
                    var selectedLocation = (Bing.Location)dc.Result;
                    dc.Values[StepContextKeys.SelectedLocation] = selectedLocation;

                    if (options.HasFlag(LocationOptions.SkipFinalConfirmation))
                    {
                        return(await dc.NextAsync());
                    }

                    await dc.PromptAsync(PromptDialogIds.Confirm,
                                         new PromptOptions()
                    {
                        Prompt = new Activity
                        {
                            Type = ActivityTypes.Message,
                            Text = string.Format(resourceManager.ConfirmationAsk,
                                                 selectedLocation.GetFormattedAddress(resourceManager.AddressSeparator))
                        },
                        RetryPrompt = new Activity
                        {
                            Type = ActivityTypes.Message,
                            Text = resourceManager.ConfirmationInvalidResponse
                        }
                    });

                    return(EndOfTurn);
                },
                async(dc, cancellationToken) =>
                {
                    if (dc.Result is bool result && !result)
                    {
                        await dc.Context.SendActivityAsync(resourceManager.ResetPrompt);
                        return(await dc.ReplaceDialogAsync(InitialDialogId));
                    }

                    if (!options.HasFlag(LocationOptions.SkipFavorites))
                    {
                        return(await dc.BeginDialogAsync(DialogIds.AddToFavoritesDialog,
                                                         new AddToFavoritesDialogOptions()
                        {
                            Location = (Bing.Location)dc.Values[StepContextKeys.SelectedLocation]
                        }
                                                         ));
                    }
                    else
                    {
                        await dc.NextAsync();
                    }

                    return(EndOfTurn);
                },
                async(dc, cancellationToken) =>
                {
                    var selectedLocation = (Bing.Location)dc.Values[StepContextKeys.SelectedLocation];
                    return(await dc.EndDialogAsync(CreatePlace(selectedLocation)));
                }
            }));
 internal void ListItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
 {
     ListView lvVariants = (ListView)sender;
     var objItem = GetItem(e.Position);
     FavoritesManager favoritesManager = new FavoritesManager(SqlLiteInstance.DB);
     favoritesManager.DeleteWord(objItem.Cast<FavoritesItem>().FavoritesId);
     var sourceTextView = e.View.FindViewById<TextView>(Resource.Id.SourceTextView);
     sourceTextView.SetTextAppearance(context, Resource.Style.FavoritesDeletedItemTextView);
     var translatedTextView = e.View.FindViewById<TextView>(Resource.Id.TranslatedTextView);
     translatedTextView.SetTextAppearance(context, Resource.Style.FavoritesDeletedItemTextView);
     var transcriptionTextView = e.View.FindViewById<TextView>(Resource.Id.TranscriptionTextView);
     transcriptionTextView.SetTextAppearance(context, Resource.Style.FavoritesDeletedItemTextView);
     var posTextView = e.View.FindViewById<TextView>(Resource.Id.PosTextView);
     posTextView.SetTextAppearance(context, Resource.Style.FavoritesDeletedItemTextView);
     Toast.MakeText(context, Resource.String.msg_string_deleted_from_fav, ToastLength.Short).Show();
 }
Exemplo n.º 32
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = myContext.LayoutInflater.Inflate(Resource.Layout.fragment_catalog_item, null);
            }

            var product = curLists[position];

            var pixelToDp = (int)Android.Content.Res.Resources.System.DisplayMetrics.Density;

            view.SetMinimumHeight(106 * pixelToDp);

            ImageView productImage = view.FindViewById <ImageView>(Resource.Id.productImage);


            Utils.AsyncImageSet(product.Photo, productImage);

            TextView       productTitle    = view.FindViewById <TextView>(Resource.Id.productTitle);
            TextView       productDiscount = view.FindViewById <TextView>(Resource.Id.productSale);
            TextView       productValue    = view.FindViewById <TextView>(Resource.Id.productPrice);
            TextView       itemCountText   = view.FindViewById <TextView>(Resource.Id.quantity);
            RelativeLayout discountLayout  = view.FindViewById <RelativeLayout>(Resource.Id.saleLayout);


            var discount = AppData.CurrentCart.DiscountFor(product);
            var price    = AppData.CurrentCart.PriceFor(product);
            var quantity = AppData.CurrentCart.QuantityFor(product);



            productTitle.Text         = product.Name;
            itemCountText.Text        = string.Format("{0} UN", quantity);
            productValue.Text         = price.ToString("C", CultureInfo.CreateSpecificCulture("pt-BR"));
            itemCountText.Text        = string.Format("{0} UN", quantity);
            discountLayout.Visibility = discount <= 0.0 ? ViewStates.Invisible : ViewStates.Visible;
            productDiscount.Text      = String.Format("↓{0:0.0}%", discount).Replace(".", ",");


            Button addButton = view.FindViewById <Button>(Resource.Id.addButon);
            Button subButton = view.FindViewById <Button>(Resource.Id.subButon);

            addButton.SetOnClickListener(new AddRemoveFromCart(product, 1, view));
            subButton.SetOnClickListener(new AddRemoveFromCart(product, -1, view));

            ImageButton favButton = view.FindViewById <ImageButton>(Resource.Id.favoriteBtn);

            favButton.SetOnClickListener(new FavoriteClickListener(product, favButton));
            favButton.SetImageResource(FavoritesManager.GetInstance().IsFavorite(product) ? Resource.Mipmap.ic_star : Resource.Mipmap.ic_star_border);

            //Section bar
            var currentSale = AppData.Sales.Find(x => x.Category_id == product.Category_id);
            var hasSale     = currentSale != null;

            var isNewCategory = position > 0 && product.Category_id != curLists[position - 1].Category_id;
            var hasSection    = position == 0 || isNewCategory;

            var section = view.FindViewById <RelativeLayout>(Resource.Id.section);

            section.Visibility = hasSection ? ViewStates.Visible : ViewStates.Invisible;
            section.LayoutParameters.Height = hasSection ? 32 * pixelToDp : 0;

            var sectionText = view.FindViewById <TextView>(Resource.Id.sectionText);

            sectionText.Text = !hasSection? "" : hasSale ? currentSale.Name : "Outros";

            return(view);
        }