Beispiel #1
0
        public IActionResult OnPost()
        {
            foreach (var good in parsing.GetGoods())
            {
                if (itemData.GetItems().Where(i => i.IdMixx == good.GoodId).Any())
                {
                    Item item = itemData.GetItems().Where(i => i.IdMixx == good.GoodId).Single();
                    item.Price = good.Price;
                    itemData.Update(item);
                }
                else
                {
                    itemData.Add(new Item()
                    {
                        IdMixx = good.GoodId, Name = good.Name, Price = good.Price
                    });
                }
            }

            itemData.Commit();

            parsing.DeleteAll();
            parsing.Commit();

            return(RedirectToPage("../Items/List"));
        }
Beispiel #2
0
        public IActionResult OnPost(int itemId)
        {
            var item = itemData.Delete(itemId);

            itemData.Commit();

            if (item == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            TempData["Message"] = $"{item.Name} deleted";
            return(RedirectToPage("./List"));
        }
Beispiel #3
0
        public IActionResult AddItem([FromBody] Item model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            System.Security.Claims.Claim userIdClaim = User.Claims.Single(c => c.Type == "id");
            var user = _userManager.Users.FirstOrDefault(x => x.Id.ToString() == userIdClaim.Value);
            var item = new Item
            {
                ItemName         = model.ItemName,
                UserId           = user.Id,
                CreatedOnDate    = DateTime.UtcNow,
                CanBeBorrowed    = model.CanBeBorrowed,
                LentOut          = model.LentOut,
                LentTo           = model.LentTo,
                ImageFileContent = model.ImageFileContent,
                ImageFileType    = "URL"
            };

            _itemData.AddItem(item);
            _itemData.Commit();
            return(Ok(item));
        }
Beispiel #4
0
        public IActionResult OnPost()
        {
            foreach (var good in parsing.GetGoods())
            {
                Item item = itemData.GetItems().Where(i => i.IdMi92 == good.GoodId).Single();
                item.PriceMi92 = good.Price;
                itemData.Update(item);
            }
            itemData.Commit();

            parsing.DeleteAll();
            parsing.Commit();

            return(RedirectToPage("../Items/List"));
        }
Beispiel #5
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                Types = htmlHelper.GetEnumSelectList <ItemType>();
                return(Page());
            }

            if (Item.Id > 0)
            {
                itemData.Update(Item);
            }
            else
            {
                itemData.Add(Item);
            }
            itemData.Commit();
            TempData["Message"] = "Item saved!";
            return(RedirectToPage("./Detail", new { itemId = Item.Id }));
        }