public async Task<Item> GetItemById(string id) { var itemObject = await GetRawItemObjectById(id); var category = new ItemCategoryHelper().GetItemCategoryById(itemObject.Get<string>("CategoryId")); Uri photoUri = null; Uri thumbUri = null; if (itemObject.ContainsKey("PhotoId")) { var photo = await GetPhotoById(itemObject.Get<string>("PhotoId")); photoUri = (photo?["RawData"] as ParseFile)?.Url; thumbUri = (photo?["RawData"] as ParseFile)?.Url; } var item = new Item { Id = itemObject.ObjectId, Name = itemObject.Get<string>("Name"), CategoryName = category?.Name, CategoryId = category?.Id, UpdatedAt = itemObject.UpdatedAt, CreatedAt = itemObject.CreatedAt, PhotoUri = photoUri, PhotoId = (itemObject.ContainsKey("PhotoId")) ? itemObject.Get<string>("PhotoId") : null, ThumbnailUri = thumbUri }; await AssociateAllItems(new List<Item> {item}); return item; }
// GET: Category/Edit/5 public ActionResult Edit(string id) { var category = new ItemCategoryHelper().GetItemCategoryById(id); return View(category); }