Exemple #1
0
        public IActionResult DeleteConfirmed(Guid id)
        {
            var movie = MemoryContext.Movies
                        .FirstOrDefault(m => m.Id == id);

            MemoryContext.Movies.Remove(movie);
            MemoryContext.SaveChanges();

            return(RedirectToAction(nameof(Index)));
        }
Exemple #2
0
        public IActionResult Create(
            [Bind("ID,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                MemoryContext.Movies.Add(movie);
                MemoryContext.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Exemple #3
0
        public int AddInspection(InspectionPoco inspectionPoco)
        {
            using (var db = new MemoryContext())
            {
                db.InspectionDbSet.Add(inspectionPoco);

                db.SaveChanges();

                _getInMemory++;
                return(inspectionPoco.InspectionId);
            }
        }
Exemple #4
0
 public TodoController(MemoryContext context)
 {
     _context = context;
     if (_context.Todos.Count() == 0)
     {
         _context.Todos.Add(new MemoryDatabase.Entities.Todo {
             Name         = "Do Something",
             CreatedBy    = "sys",
             CreatedDate  = DateTimeOffset.Now,
             ModifiedBy   = "sys",
             ModifiedDate = DateTimeOffset.Now
         });
         _context.SaveChanges();
     }
 }
Exemple #5
0
        public IActionResult Edit(
            Guid id, [Bind("ID,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            var storedMovie = MemoryContext.Movies
                              .FirstOrDefault(m => m.Id == id);

            if (storedMovie == null || storedMovie.Id != movie.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                storedMovie = movie;
                MemoryContext.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Exemple #6
0
        static void Main()
        {
            using (memoryContext = new MemoryContext())
                using (ffxivContext = new FfxivContext())
                {
                    // Create sqlite database in memory for data processing...
                    Console.WriteLine("[Memory] Creating temporary database...");
                    Console.WriteLine();
                    memoryContext.Database.EnsureCreated();

                    // Read and cache global client data.
                    SqCache sqCache = new SqCache(GlobalClientPath, "0a0000.win32.index", "0a0000.win32.dat0");

                    // Process BaseParam into memory.
                    Console.WriteLine("[Memory][BaseParam] Processing...");
                    ExHFile baseParamExH = new ExHFile(sqCache.GetFile("exd", "BaseParam.exh"));
                    baseParamExH.Iterate(sqCache, "exd", "BaseParam_{0}_en.exd", exDFile => {
                        exDFile.Iterate(row => {
                            Memory.Models.BaseParamModel baseParam = new Memory.Models.BaseParamModel();
                            baseParam.SetFromRow(row);
                            memoryContext.Add(baseParam);
                        });
                    });
                    Console.WriteLine("[Memory][BaseParam] Saving...");
                    Console.WriteLine();
                    memoryContext.SaveChanges();

                    // Process ClassJobCategory into memory.
                    Console.WriteLine("[Memory][ClassJobCategory] Processing...");
                    ExHFile classJobCategoryExH = new ExHFile(sqCache.GetFile("exd", "ClassJobCategory.exh"));
                    classJobCategoryExH.Iterate(sqCache, "exd", "ClassJobCategory_{0}_en.exd", exDFile => {
                        exDFile.Iterate(row => {
                            Memory.Models.ClassJobCategoryModel classJobCategory = new Memory.Models.ClassJobCategoryModel();
                            classJobCategory.SetFromRow(row);
                            memoryContext.Add(classJobCategory);
                        });
                    });
                    Console.WriteLine("[Memory][ClassJobCategory] Saving...");
                    Console.WriteLine();
                    memoryContext.SaveChanges();

                    // Process EquipSlotCategory into memory.
                    Console.WriteLine("[Memory][EquipSlotCategory] Processing...");
                    ExHFile equipSlotCategoryExH = new ExHFile(sqCache.GetFile("exd", "EquipSlotCategory.exh"));
                    equipSlotCategoryExH.Iterate(sqCache, "exd", "EquipSlotCategory_{0}.exd", exDFile => {
                        exDFile.Iterate(row => {
                            Memory.Models.EquipSlotCategoryModel equipSlotCategory = new Memory.Models.EquipSlotCategoryModel();
                            equipSlotCategory.SetFromRow(row);
                            memoryContext.Add(equipSlotCategory);
                        });
                    });
                    Console.WriteLine("[Memory][EquipSlotCategory] Saving...");
                    Console.WriteLine();
                    memoryContext.SaveChanges();

                    // Process ItemUICategory into memory.
                    Console.WriteLine("[Memory][ItemUICategory] Processing...");
                    ExHFile itemUICategoryExH = new ExHFile(sqCache.GetFile("exd", "ItemUICategory.exh"));
                    itemUICategoryExH.Iterate(sqCache, "exd", "ItemUICategory_{0}_en.exd", exDFile => {
                        exDFile.Iterate(row => {
                            Memory.Models.ItemUICategoryModel itemUICategory = new Memory.Models.ItemUICategoryModel();
                            itemUICategory.SetFromRow(row);
                            memoryContext.Add(itemUICategory);
                        });
                    });
                    Console.WriteLine("[Memory][ItemUICategory] Saving...");
                    Console.WriteLine();
                    memoryContext.SaveChanges();

                    string[] equipmentCategories =
                    {
                        "Pugilist's Arm",
                        "Gladiator's Arm",
                        "Marauder's Arm",
                        "Archer's Arm",
                        "Lancer's Arm",
                        "One-handed Thaumaturge's Arm",
                        "Two-handed Thaumaturge's Arm",
                        "One-handed Conjurer's Arm",
                        "Two-handed Conjurer's Arm",
                        "Arcanist's Grimoire",
                        "Shield",
                        "Head",
                        "Body",
                        "Legs",
                        "Hands",
                        "Feet",
                        "Waist",
                        "Necklace",
                        "Earrings",
                        "Bracelets",
                        "Ring",
                        "Rogue's Arm",
                        "Dark Knight's Arm",
                        "Machinist's Arm",
                        "Astrologian's Arm",
                        "Samurai's Arm",
                        "Red Mage's Arm",
                        "Scholar's Arm",
                        "Blue Mage's Arm",
                        "Gunbreaker's Arm",
                        "Dancer's Arm"
                    };

                    // Process Item into memory.
                    Console.WriteLine("[Memory][Item] Processing...");
                    ExHFile itemExH = new ExHFile(sqCache.GetFile("exd", "Item.exh"));
                    itemExH.Iterate(sqCache, "exd", "Item_{0}_en.exd", exDFile => {
                        exDFile.Iterate(row => {
                            Memory.Models.ItemModel item = new Memory.Models.ItemModel();

                            Memory.Models.ItemUICategoryModel itemUICategory = item.GetItemUICategoryFromRow(row);
                            ushort itemLevel = item.GetItemLevelFromRow(row);

                            if (equipmentCategories.Contains(itemUICategory.Name) && itemLevel >= 430)
                            {
                                item.SetFromRow(row, "en");
                                memoryContext.Equipments.Add(item);
                            }
                            else if (itemUICategory.Name == "Meal" && itemLevel >= 430)
                            {
                                item.SetFromRow(row, "en");
                                memoryContext.Foods.Add(item);
                            }
                            else if (itemUICategory.Name == "Materia")
                            {
                                item.SetFromRow(row, "en");
                                memoryContext.Materias.Add(item);
                            }
                        });
                    });
                    Console.WriteLine("[Memory][Item] Saving...");
                    Console.WriteLine();
                    memoryContext.SaveChanges();

                    // Process Item.

                    /*Console.WriteLine("[Item] Processing...");
                     * ExHFile globalItemExH = new ExHFile(globalSqCache.GetFile("exd", "Item.exh"));
                     * globalItemExH.Iterate(globalSqCache, "exd", "Item_{0}_en.exd", exDFile =>
                     * {
                     *  exDFile.Iterate(row =>
                     *  {
                     *      // Construct new item model from row.
                     *      ItemModel item = new ItemModel()
                     *      {
                     *          RowKey = row.Key,
                     *          LastUpdated = GlobalVersion
                     *      };
                     *      item.SetFromRow(row, "en");
                     *
                     *      // See if item with the same row key already exists in the database.
                     *      ItemModel existingItem = ffxivContext.Items.FirstOrDefault(_item => _item.RowKey == item.RowKey);
                     *
                     *      // If doesn't exist, insert it.
                     *      if (existingItem == null)
                     *      {
                     *          ffxivContext.Add(item);
                     *      }
                     *      // If does exist, compare values and update it only if necessary.
                     *      else
                     *      {
                     *          item.NameJa = existingItem.NameJa;
                     *          item.NameKo = existingItem.NameKo;
                     *
                     *          if (!Utility.Equals<ItemBaseModel>(item, existingItem))
                     *          {
                     *              // Update to current values and set last updated patch version to current version.
                     *              Utility.Set<ItemBaseModel>(existingItem, item);
                     *              existingItem.LastUpdated = GlobalVersion;
                     *          }
                     *      }
                     *
                     *      ffxivContext.SaveChanges();
                     *  });
                     * });
                     */
                }
        }
Exemple #7
0
 public bool Save()
 {
     return(_context.SaveChanges() >= 0);
 }