//[Route("/Orders/ViewItem/{id}")] public IActionResult ViewItem(int id) { List <Item> existingItem = db .Items .Include(i => i.Owner) .Include(i => i.Brand) .Include(i => i.Model) .Include(i => i.Category) .Where(i => i.ID == id) .ToList(); if (existingItem.Count != 0) { Item item = existingItem[0]; string userId = User.Identity.IsAuthenticated ? User.FindFirst(ClaimTypes.NameIdentifier).Value : ""; bool owner = item.OwnerId == userId ? true : false; List <Guid> imageIds = db.Images.Where(m => m.Item.ID == id).Select(m => m.Id).ToList(); int watchers = db.WatchListItems.Where(i => i.ItemID == id).ToList().Count; ViewItemViewModel viewItemViewModel = new ViewItemViewModel() { Item = item, Owner = owner, ImageIds = imageIds, Watchers = watchers, }; return(View(viewItemViewModel)); } return(Redirect("/Search")); }
public ViewItemPage(DataDisplayModel dataDisplayModel) { InitializeComponent(); MessagingCenter.Subscribe <ViewItemViewModel>(this, "ItemDeleted", (sender) => { DisplayAlert("Alert", "Item deleted!", "OK"); }); BindingContext = new ViewItemViewModel(dataDisplayModel, Navigation); }
public ActionResult ViewTask(int id) { ToDoItemsDb db = new ToDoItemsDb(Properties.Settings.Default.ConStr); var vm = new ViewItemViewModel { ToDoItem = db.GetItem(id) }; return(View(vm)); }
public IActionResult ViewItem(string category, string slugurl, ViewItemViewModel model) { if (ModelState.IsValid) { var result = _projectEngine.CreateOffer(_userManager.GetUserId(User), model.Item.Id, category, slugurl, model.Comment, model.OfferPrice.Value); switch (result.Type) { case TransactionType.Success: return(RedirectToRoute("viewItem", new { category = category, slugurl = slugurl })); case TransactionType.Error: model = _projectEngine.GetItem(_userManager.GetUserId(User), category, slugurl); ViewBag.Title = model.Item.Title; ModelState.AddModelError("", result.Message); return(View(model)); } } return(View(model)); }
public ViewItemPage(Item item) { InitializeComponent(); BindingContext = new ViewItemViewModel(item); }
public ViewItemViewModel GetItem(string UserId, string categorySlug, string itemSlug) { var item = _dbContext.Item .Include(i => i.Province) .Include(i => i.District) .Include(i => i.User.Province) .Include(i => i.User.District) .Include(i => i.Category) .Include(i => i.Category.Parent) .FirstOrDefault(i => i.Category.SlugUrl == categorySlug && i.SlugUrl == itemSlug); var questions = JsonConvert.DeserializeObject <IEnumerable <CategoryQuestions> >(item.ItemCategoryQuestionsJSON); var images = new List <string>(); AddImagesToList(images, item.ImageUrl); AddImagesToList(images, item.ImageUrl2); AddImagesToList(images, item.ImageUrl3); AddImagesToList(images, item.ImageUrl4); AddImagesToList(images, item.ImageUrl5); var model = new ViewItemViewModel() { ItemUser = item.User, Item = item, Questions = questions, Images = images }; if (item.UserId == UserId) { model.Offers = _dbContext.Offer .Include(i => i.User) .Where(i => i.ItemId == item.Id) .OrderByDescending(i => i.OfferDate); var winner = model.Offers.FirstOrDefault(i => i.IsWinner == true); if (winner != null) { model.hasWinner = true; model.Offers = new List <Offer>() { winner }; } } else { var offer = _dbContext.Offer .Include(i => i.User) .FirstOrDefault(i => i.ItemId == item.Id && i.UserId == UserId); model.Offers = new List <Offer>(); if (offer != null) { if (offer.IsWinner.HasValue && offer.IsWinner.Value) { model.hasWinner = true; } model.Offers = new List <Offer>() { offer }; } } return(model); }