public async Task <Quest> Update(Quest Quest) { var result = await Task.FromResult(_dapper.Update <Quest>($"update Quest set XpReward = {Quest.XpReward}, GoldReward = {Quest.GoldReward}," + $"IsComplete = {(Quest.IsComplete ? 1 : 0)}, NpcId = {Quest.Npc.NpcId} where QuestId = {Quest.QuestId}", null, commandType: CommandType.Text)); return(result); }
public async Task <Monster> Update(Monster monster) { var result = await Task.FromResult(_dapper.Update <Monster>($"update Monster set MonsterName = '{monster.MonsterName}', Level = {monster.Level}, Health = {monster.Health}," + $" MaxHealth = {monster.MaxHealth}, ZoneId = {monster.Zone.ZoneId} where MonsterId = {monster.MonsterId}", null, commandType: CommandType.Text)); return(result); }
public async Task <Event> Update(Event Event) { var result = await Task.FromResult(_dapper.Update <Event>($"update Event set EventSummary = '{Event.EventSummary}', EventAlreadyEncountered = {(Event.EventAlreadyEncountered ? 1 : 0)}, " + $" EventPassed = {(Event.EventPassed ? 1 : 0)}, MonsterId = {Event.Monster?.MonsterId.ToString() ?? "null"}, ItemId = {Event.Item?.ItemId.ToString() ?? "null"}, " + $"ZoneId = {Event.Zone.ZoneId} where EventId = {Event.EventId}", null, commandType: CommandType.Text)); return(result); }
public async Task <Npc> Update(Npc Npc) { var result = await Task.FromResult(_dapper.Update <Npc>($"update Npc set NpcName = '{Npc.NpcName}', IsMerchant = {(Npc.IsMerchant ? 1 : 0)}, " + $"GivesQuests = {(Npc.GivesQuests ? 1 : 0)} where NpcId = {Npc.NpcId}", null, commandType: CommandType.Text)); return(result); }
public async Task <Item> Update(Item item) { var result = await Task.FromResult(_dapper.Update <Item>($"update Item set ItemName = '{item.ItemName}', LevelRequirement = {item.LevelRequirement}, ItemType = '{item.ItemType}'," + $" Equipped = {(item.Equipped ? 1 : 0)}, StrengthBonus = {item.StrengthBonus}, DefenseBonus = {item.DefenseBonus}, HealthBonus = {item.HealthBonus}, PlayerId = {item.Player.PlayerId}" + $" where ItemId = {item.ItemId}", null, commandType: CommandType.Text)); return(result); }
public Task <int> Update(Teams team) { var dbPara = new DynamicParameters(); dbPara.Add("TeamId", team.TeamId, DbType.Int32); dbPara.Add("Name", team.Name, DbType.String); dbPara.Add("Category", team.Category, DbType.String); var updateTeam = Task.FromResult(_dapperService.Update <int>("[dbo].[spUpdateTeams]", dbPara, commandType: CommandType.StoredProcedure)); return(updateTeam); }
public IActionResult SaveChanges(IFormCollection collection) { if (collection != null) { foreach (var item in collection) { if (!string.IsNullOrWhiteSpace(item.Value) && item.Key != "formId") { _dapperService.Update <Feature, object>("[dbo].[Feature_UpdateClassifierId]", new { featureId = int.Parse(item.Key), classifierId = int.Parse(item.Value) }); } } } return(Redirect("RegPoz?regid=1")); }
public Task <int> Update(Player data) { var dbparams = new DynamicParameters(); dbparams.Add("PlayerId", data.PlayerId, DbType.Int32); dbparams.Add("PlayerName", data.PlayerName, DbType.String); dbparams.Add("Level", data.Level, DbType.Int32); dbparams.Add("Health", data.Health, DbType.Int32); dbparams.Add("MaxHealth", data.MaxHealth, DbType.Int32); dbparams.Add("Strength", data.Strength, DbType.Int32); dbparams.Add("Defense", data.Defense, DbType.Int32); dbparams.Add("Gold", data.PlayerId, DbType.Int32); dbparams.Add("Experience", data.Experience, DbType.Int32); dbparams.Add("CurrentZoneId", data.CurrentZone.ZoneId, DbType.Int32); var updatePlayer = Task.FromResult(_dapper.Update <int>("[dbo].[SP_Update_Player]", dbparams, commandType: CommandType.StoredProcedure)); return(updatePlayer); }
public ActionResult Index() { var sb = new StringBuilder("Dapper service\n"); int usersBefore = _repo.GetUsers().Count; sb.Append($"Users before: {usersBefore}\n"); var user = new User { Age = 18, Email = "*****@*****.**", IsMarried = false, Name = "some123", Sex = "male" }; _repo.Create(user); sb.Append($"Create user: {user.Id}\n"); int usersAfter = _repo.GetUsers().Count; sb.Append($"Users after: {usersAfter}\n"); user.Name = "Username123"; _repo.Update(user); User dbUser = _repo.Get(user.Id); sb.Append($"Update user: {dbUser.Name}\n"); _repo.Delete(dbUser.Id); sb.Append("Delete user\n"); int usersAfterDel = _repo.GetUsers().Count; sb.Append($"Users after delete: {usersAfterDel}\n"); return(Content(sb.ToString())); }
public async Task <Zone> Update(Zone zone) { var result = await Task.FromResult(_dapper.Update <Zone>($"update Zone set ZoneName = '{zone.ZoneName}' where ZoneId = {zone.ZoneId}", null, commandType: CommandType.Text)); return(result); }