示例#1
0
        public async Task <IActionResult> Create([Bind("ID,Description,CreatedDate")] TheList theList)
        {
            if (ModelState.IsValid)
            {
                _context.Add(theList);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(theList));
        }
示例#2
0
 public override int Create(InventoryItem data)
 {
     if (ListContext.Any(x => x.ItemId == data.ItemId))
     {
         ListContext.Where(x => x.ItemId == data.ItemId).First().Amount += data.Amount;
     }
     else
     {
         ListContext.Add(data);
     }
     return(data.InventoryItemId);
 }
示例#3
0
        public int Create(object data)
        {
            var inventoryItem = InventoryItemCast(data);

            if (ListContext.Any(x => x.ItemId == inventoryItem.ItemId))
            {
                ListContext.SingleOrDefault(x => x.ItemId == inventoryItem.ItemId).Amount += inventoryItem.Amount;
            }
            else
            {
                ListContext.Add(inventoryItem);
            }
            return(inventoryItem.InventoryItemId);
        }
示例#4
0
        public override int Create(Models.EnemyViewModel model)
        {
            var enemy = new DAL.Enemy()
            {
                AttackMax       = model.AttackMax.Value,
                CharacterTypeId = model.CharacterTypeId.Value,
                AttackMin       = model.AttackMin.Value,
                EnemyId         = model.EnemyId,
                CurrentLife     = model.CurrentLife.Value,
                MaxLife         = model.MaxLife.Value,
                SpeedRun        = model.SpeedRun.Value,
                SpeedWalk       = model.SpeedWalk.Value
            };

            ListContext.Add(enemy);
            return(enemy.EnemyId);
        }
示例#5
0
        public override int Create(Models.PlayerViewModel model)
        {
            var player = new DAL.Player()
            {
                AttackMax           = model.AttackMax,
                CharacterTypeId     = model.CharacterTypeId.Value,
                AttackMin           = model.AttackMin,
                PlayerId            = model.PlayerId,
                CurrentLife         = model.CurrentLife,
                MaxLife             = model.MaxLife,
                SpeedRun            = model.SpeedRun,
                SpeedWalk           = model.SpeedWalk,
                IsBeingControllable = model.IsBeingControllable,
                PlayerMode          = model.PlayerMode.Value,
                InitialX            = model.InitialX,
                InitialY            = model.InitialY,
                LastMoviment        = model.LastMoviment.Value
            };

            ListContext.Add(player);
            return(player.PlayerId);
        }
示例#6
0
 public int Create(Player data)
 {
     ListContext.Add(data);
     return(data.PlayerId);
 }
示例#7
0
 public int Create(Enemy data)
 {
     ListContext.Add(data);
     return(data.EnemyId);
 }