Пример #1
0
 public ActionResult Index()
 {
     var item = new Items
                {
                    Id = 1,
                    Name = "Bread",
                    Price = "1.00",
                    CreationDate = DateTime.Now,
                    LastUpdateTime = DateTime.Now,
                };
     _itemService.StoreOrUpdate(item);
     return View(_itemService.GetAllItems().ToList());
 }
Пример #2
0
        public Items StoreOrUpdate(Items item)
        {
            var existingItem = DocumentSession.Load<Items>(item.Name);
              if (existingItem != null)
               {
                    existingItem.Name = item.Name;
                    existingItem.Price = item.Price;
                    existingItem.CreationDate = item.CreationDate;
                    existingItem.LastUpdateTime = DateTime.Now;

            }
            else
            {
                DocumentSession.Store(item);
            }

            DocumentSession.SaveChanges();

            return item;
        }
Пример #3
0
 public ActionResult SaveData(Items item)
 {
     return Json(_itemService.StoreOrUpdate(item).Id);
 }