public async Task <ActionResult <QuestChain> > Post(QuestChain questChain) { if (questChain == null) { return(BadRequest()); } _db.QuestChains.Add(questChain); await _db.SaveChangesAsync(); return(Ok(questChain)); }
public async Task <ActionResult <QuestPlayer> > Post(QuestPlayer questPlayer) { if (questPlayer == null) { return(BadRequest()); } _db.QuestPlayers.Add(questPlayer); await _db.SaveChangesAsync(); return(Ok(questPlayer)); }
public async Task <ActionResult <Item> > Post(Item item) { if (item == null) { return(BadRequest()); } if (_db.Items.Any(x => x.Name == item.Name)) { return(Conflict()); } _db.Items.Add(item); await _db.SaveChangesAsync(); return(Ok(item)); }
public async Task <ActionResult <Quest> > Post(Quest quest) { if (quest == null) { return(BadRequest()); } if (_db.Quests.Any(x => x.Name == quest.Name)) { return(Conflict()); } _db.Quests.Add(quest); await _db.SaveChangesAsync(); return(Ok(quest)); }
public async Task <ActionResult <Npc> > Post(Npc npc) { if (npc == null) { return(BadRequest()); } if (_db.Npcs.Any(x => x.Name == npc.Name)) { return(Conflict()); } _db.Npcs.Add(npc); await _db.SaveChangesAsync(); return(Ok(npc)); }
public async Task <ActionResult <Player> > Post(Player player) { if (player == null) { return(BadRequest()); } if (_db.Players.Any(x => x.Name == player.Name)) { return(Conflict()); } _db.Players.Add(player); await _db.SaveChangesAsync(); return(Ok(player)); }
public async Task <ActionResult <Chain> > Post(Chain chain) { if (chain == null) { return(BadRequest()); } if (_db.Chains.Any(x => x.Name == chain.Name)) { return(Conflict()); } _db.Chains.Add(chain); await _db.SaveChangesAsync(); return(Ok(chain)); }
public async Task <ActionResult <QuestItem> > Post(QuestItem item) { if (item == null) { return(BadRequest()); } var freeAmount = _db.Items.AsNoTracking().First(x => x.Id == item.ItemId).AmountReady - _db.QuestItems.AsNoTracking().Where(x => x.ItemId == item.ItemId && x.IsReady).Sum(x => x.AmountNeeded); if (freeAmount > item.AmountNeeded) { item.IsReady = true; } _db.QuestItems.Add(item); await _db.SaveChangesAsync(); return(Ok(item)); }
public async Task <ActionResult <Location> > Post(Location location) { if (location == null) { return(BadRequest()); } if (_db.Locations.Any(x => x.Name == location.Name)) { return(Conflict()); } _db.Locations.Add(location); await _db.SaveChangesAsync(); if (location.RequestsPayed > 0) { AddMaterialsRequest(location); } return(Ok(location)); }
public async Task <ActionResult <Material> > Post(Material material) { if (material == null) { return(BadRequest()); } if (_db.Materials.Any(x => x.Name == material.Name)) { return(Conflict()); } _db.Materials.Add(material); await _db.SaveChangesAsync(); if (material.AmountPerPayedRequestInLocation > 0) { AddSingleMaterialRequests(material.Name); } return(Ok(material)); }
public async Task <ActionResult <SingleMaterialRequestInfoView> > Put(SingleMaterialRequestInfoView singleMaterialRequestInfoView) { if (singleMaterialRequestInfoView == null) { return(BadRequest()); } if (!_db.SingleMaterialRequests.Any(x => x.Id == singleMaterialRequestInfoView.Id)) { return(NotFound()); } var singleMaterialRequest = _db.SingleMaterialRequests.First(x => x.Id == singleMaterialRequestInfoView.Id); singleMaterialRequest.QuantityServed = singleMaterialRequestInfoView.QuantityServed; _db.Update(singleMaterialRequest); await _db.SaveChangesAsync(); return(Ok(singleMaterialRequest)); }