示例#1
0
        private void StoreWearDetails(int type, int itemId)
        {
            ClothesItem clothesItem = DbContext.ClothesItems.Where(i => i.Type == type && i.Id == itemId).First();
            HistoryItem lastWorn    = new HistoryItem();

            switch (type)
            {
            case 1:
                lastWorn = DbContext.History.Where(j => j.TopId == itemId).OrderByDescending(x => x.HistoryDate).FirstOrDefault();
                break;

            case 2:
                lastWorn = DbContext.History.Where(j => j.TrousersId == itemId).OrderByDescending(x => x.HistoryDate).FirstOrDefault();
                break;

            case 3:
                lastWorn = DbContext.History.Where(j => j.ShoesId == itemId).OrderByDescending(x => x.HistoryDate).FirstOrDefault();
                break;
            }

            clothesItem.LastWornDate = lastWorn.HistoryDate != null ? lastWorn.HistoryDate : new DateTime(2000, 1, 1);
            clothesItem.WornCount++;
            clothesItem.LastModifiedDate = DateTime.Now;
            DbContext.Update(clothesItem);
            DbContext.SaveChanges();
        }
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                ClothesItem clothesItem = GetClothesItem()[indexPath.Row];
                var         cell        = (CT1Text)tableView.DequeueReusableCell(CT1Text.Key);

                cell.SetCellData(clothesItem.TypeId, clothesItem.Name, clothesItem.Icon, clothesItem.Size, tableView.Editing);
                return(cell);
            }
        private void LoadData()
        {
            var data = JsonValue.Parse(_filesystem.ReadFile(ClothesFolder));

            _allSizeData = JsonValue.Parse(_filesystem.ReadFile($"{AccountService.AccountDataFolder}/{AppSettings.SelectedAccount}_data.json"));
            var brandData = _allSizeData[AppSettings.SelectedBrandId.ToString()];

            foreach (KeyValuePair <string, JsonValue> item in data)
            {
                var clothesItem = new ClothesItem(item.Key, item.Value["Name"], item.Value["Icon"], brandData[item.Key]);
                _clothesList.Add(clothesItem);
            }
        }