Exemple #1
0
        }//CreateUIList

        private void AddNewItem(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtShoppingItem.Text))
            {
                txtShoppingItem.ShowError(ShAppContext.GetString(Resource.String.InvalidProduct), ShAppContext);
            }
            else
            {
                txtShoppingItem.HideError();
            }

            if (string.IsNullOrEmpty(txtQuantity.Text))
            {
                txtQuantity.ShowError(ShAppContext.GetString(Resource.String.InvalidQuantity), ShAppContext);
            }
            else
            {
                txtQuantity.HideError();
            }


            if (!string.IsNullOrEmpty(txtShoppingItem.Text) && !string.IsNullOrEmpty(txtQuantity.Text))
            {
                int         quantity   = Convert.ToInt32(txtQuantity.Text);
                ItemListDTO newItemDto = ListsManager.Instance.CreateListItem(m_data.InternalId, txtShoppingItem.Text, quantity);
                CreateUIItem(newItemDto, 0);
                txtShoppingItem.HideError();
                txtQuantity.HideError();
                txtShoppingItem.Text = string.Empty;
                txtQuantity.Text     = string.Empty;
            }
        }//AddNewList
Exemple #2
0
        }//Initialize

        public void UpdateCtrlData(ItemListDTO aData)
        {
            m_Data           = aData;
            lblItem.Text     = m_Data.Description;
            lblQuantity.Text = ShAppContext.GetString(Resource.String.Quantity) + ":" + m_Data.Quantity;
            this.Invalidate();
        }
        public ItemListDTO Get()
        {
            ItemListDTO items  = new ItemListDTO();
            string      userId = User.Identity.GetUserId();

            items.ItemList = _repo.GetItems();
            return(items);
        }
Exemple #4
0
 /// <summary>
 /// CtrlShoppingList
 /// </summary>
 /// <param name="cnt"></param>
 public CtrlItemList(Activity parent, ShApplication cnt, ItemListDTO data) : base(cnt)
 {
     this.Id          = View.GenerateViewId();
     m_ParentActivity = parent;
     m_Data           = data;
     Inflate(cnt, Resource.Layout.CtrlItemList, this);
     Initialize();
 }//CtrlShoppingList
        public IActionResult GetWordsByRange([FromQuery] PagingParameters pagingParameters, int userId, int isUpdated)
        {
            ItemListDTO <Word> wordListDTO = _wordService.GetWordsByRange(userId, isUpdated, pagingParameters);

            if (wordListDTO == null)
            {
                throw new Exception("Could not get words");
            }

            return(Ok(wordListDTO));
        }
Exemple #6
0
        public static ItemListDTO <T> ToPagedItemList(IQueryable <T> source, int pageIndex, int pageItemCount)
        {
            ItemListDTO <T> itemListDto = new ItemListDTO <T>();

            var count = source.Count();
            var items = source.Skip((pageIndex - 1) * pageItemCount).Take(pageItemCount).ToList();

            itemListDto.ItemList  = new PagedItemList <T>(items, count, pageIndex, pageItemCount);
            itemListDto.PageCount = count / pageItemCount;

            return(itemListDto);
        }
Exemple #7
0
        }//GenerateUILists

        private void CreateUIItem(ItemListDTO newItem, int position = 0)
        {
            CtrlItemList item = new CtrlItemList(this, ShAppContext, newItem);

            item.Event_DeleteItem += (x) =>
            {
                var view = FindViewById <CtrlItemList>(x);
                if (view != null)
                {
                    (llLst as ViewGroup).RemoveView(view);
                    ListsManager.Instance.DeleteListItem(m_data.InternalId, view.Data.InternalId);
                }//endif
            };

            item.Event_BuyItem += (intId, status) => {
                ListsManager.Instance.ItemBought(m_data.InternalId, intId, status);
            };

            llLst.AddView(item, position);
            llLst.RequestLayout();
        }//CreateUIList
Exemple #8
0
        }     //AddNewList

        /// <summary>
        /// CreateListItem
        /// </summary>
        /// <param name="listInternalId"></param>
        /// <param name="description"></param>
        /// <param name="quantity"></param>
        /// <returns></returns>
        public ItemListDTO CreateListItem(string listInternalId, string description, int quantity)
        {
            ShoppingListDTO lst = GetListByInternalId(listInternalId);

            if (lst == null)
            {
                return(null);
            }

            lock (mLocker)
            {
                ItemListDTO item = new ItemListDTO();
                item.InternalId  = Guid.NewGuid().ToString();
                item.Quantity    = quantity;
                item.Description = description;

                lst.Items.Add(item);
                lst.IsDirty = true;
                return(item);
            }
        }//CreateListItem
Exemple #9
0
        public void ImportSyncData(string jsonHash, ResSyncDTO dto)
        {
            UpdateStorageHash(jsonHash);

            //delete those that are not returned
            List <string> idsLists = dto.listsMeta.items.Where(z => !string.IsNullOrEmpty(z.clientTag)).Select(x => x.clientTag).ToList();

            mStorage.ShLists.RemoveAll(x => !idsLists.Contains(x.InternalId) && !string.IsNullOrEmpty(x.Id)); //delete those that exists but not the new items that were just created


            dto.listsMeta.items.ForEach(L =>
            {
                ShoppingListDTO wantedlist = mStorage.ShLists.Where(x => x.InternalId == L.clientTag).FirstOrDefault();

                if (wantedlist == null)
                {
                    ShoppingListDTO newList = new ShoppingListDTO()
                    {
                        ListDate        = Tools.UnixTimeStampToDateTime(L.created),
                        IsDirty         = false,
                        InternalId      = Guid.NewGuid().ToString(),
                        Id              = L.id,
                        ListDescription = L.description,
                        ListName        = L.name
                    };

                    L.items.ForEach(I =>
                    {
                        ItemListDTO lstItem = new ItemListDTO(I);
                        newList.Items.Add(lstItem);
                    });

                    mStorage.ShLists.Add(newList);
                }//new one
                else
                {
                    //update list
                    wantedlist.Id = L.id;
                    wantedlist.ListDescription = L.description;
                    wantedlist.ListName        = L.name;

                    //delete listItems those that are not returned
                    List <string> lstItemsRet = L.items.Where(z => !string.IsNullOrEmpty(z.clientTag)).Select(x => x.clientTag).ToList();
                    wantedlist.Items.RemoveAll(x => !lstItemsRet.Contains(x.InternalId) && !string.IsNullOrEmpty(x.ProductId)); //delete those that exists but not the new items that were just created

                    L.items.ForEach(I =>
                    {
                        ItemListDTO wantedItem = wantedlist.Items.FirstOrDefault(x => x.InternalId == I.clientTag);
                        if (wantedItem == null)
                        {
                            wantedlist.Items.Add(new ItemListDTO(I));
                        }
                        else
                        {
                            wantedItem.Description = I.description;
                            wantedItem.ProductId   = I.productId;
                            wantedItem.Quantity    = I.quantity;
                            wantedItem.Bought      = (I.bought == 1);
                        }//else
                    });//items

                    wantedlist.IsDirty = false;//we did the sync
                }//else
            });
        }//ImportSyncData