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)); }
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); }
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); }
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); }
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); }
public int Create(Player data) { ListContext.Add(data); return(data.PlayerId); }
public int Create(Enemy data) { ListContext.Add(data); return(data.EnemyId); }