public IHttpActionResult AddPrices(PriceKindDTO priceKindDTO) { var userId = User.Identity.GetUserId(); var currentPersonId = context.Persons.Where(p => p.IdentityUserId == userId).SingleOrDefault().Id; var currentKindId = priceKindDTO.KindId; //Edit if (context.PriceKinds.Where(s => s.PersonId == currentPersonId && s.KindId == currentKindId).Any()) { var currentPriceKind = context.PriceKinds.Where(s => s.PersonId == currentPersonId && s.KindId == currentKindId).Single(); currentPriceKind.Price = priceKindDTO.Price; context.SaveChanges(); }//New else { var pricekind = new PriceKind { Price = priceKindDTO.Price, Person = context.Persons.Where(p => p.IdentityUserId == userId).SingleOrDefault(), KindId = priceKindDTO.KindId }; context.PriceKinds.Add(pricekind); context.SaveChanges(); } return(Ok()); }
public void UpdatePriceKind(PriceKind entity) { using (var db = new LogistoDb()) { db.PriceKinds.Where(w => w.ID == entity.ID) .Set(u => u.Name, entity.Name) .Set(u => u.EnName, entity.EnName) .Update(); } }
public ContentResult SavePriceKind(PriceKind model) { var pricelist = pricelistLogic.GetPricelist(model.PricelistId); var product = dataLogic.GetProduct(pricelist.ProductId.Value); if ((product.ManagerUserId != CurrentUserId) && (product.DeputyUserId != CurrentUserId) && !IsSuperUser()) { return(Content(JsonConvert.SerializeObject(new { Message = "Вы не менеджер данного продукта." }))); } var entity = pricelistLogic.GetPriceKind(model.ID); entity.Name = model.Name; entity.EnName = model.EnName; pricelistLogic.UpdatePriceKind(entity); return(Content(JsonConvert.SerializeObject(""))); }
// 條件 public Dictionary <string, String> GetPriceKindList() { string key = "PRICE_KIND"; if (null == _Cache[key]) { Dictionary <String, String> categories = new Dictionary <String, String>(); CacheItemPolicy policy = CreateCacheItemPolicy(); categories = PriceKind.GetAll() .ToDictionary(x => x.Value, x => x.Text); _Cache.Set(key, categories, policy); } return((Dictionary <string, String>)_Cache[key]); }
public RaiseSources(IMapController map, PriceKind priceKind, int depth) : this(map, map.GetPrice(priceKind), depth) { }
public static double GetHasSources(PriceKind priceKind) { return GetHasSources(map.GetPrice(priceKind)); }
public CanHaveSourcesNode(ITreeNode trueNode, ITreeNode falseNode, PriceKind kind, IMapController map) : this(trueNode, falseNode, () => {return kind;}, map) { }
public ISourceAll GetPrice(PriceKind kind) { switch (kind) { case PriceKind.BRoad: return Settings.costRoad; case PriceKind.BTown: return Settings.costTown; case PriceKind.BFort: return Settings.costFort; case PriceKind.BMarket: return Settings.costMarket; case PriceKind.BMonastery: return Settings.costMonastery; case PriceKind.BMill: return Settings.costMill; case PriceKind.BStepherd: return Settings.costStephard; case PriceKind.BSaw: return Settings.costSaw; case PriceKind.BQuarry: return Settings.costQuarry; case PriceKind.BMine: return Settings.costMine; case PriceKind.UMill1: return Settings.costMonasteryCorn1; case PriceKind.UStepherd1: return Settings.costMonasteryMeat1; case PriceKind.UQuarry1: return Settings.costMonasteryStone1; case PriceKind.USaw1: return Settings.costMonasteryWood1; case PriceKind.UMine1: return Settings.costMonasteryOre1; case PriceKind.UMill2: return Settings.costMonasteryCorn2; case PriceKind.UStepherd2: return Settings.costMonasteryMeat2; case PriceKind.UQuarry2: return Settings.costMonasteryStone2; case PriceKind.USaw2: return Settings.costMonasteryWood2; case PriceKind.UMine2: return Settings.costMonasteryOre2; case PriceKind.MCorn1: return Settings.costMarketCorn1; case PriceKind.MMeat1: return Settings.costMarketMeat1; case PriceKind.MStone1: return Settings.costMarketStone1; case PriceKind.MWood1: return Settings.costMarketWood1; case PriceKind.MOre1: return Settings.costMarketOre1; case PriceKind.MCorn2: return Settings.costMarketCorn2; case PriceKind.MMeat2: return Settings.costMarketMeat2; case PriceKind.MStone2: return Settings.costMarketStone2; case PriceKind.MWood2: return Settings.costMarketWood2; case PriceKind.MOre2: return Settings.costMarketOre2; case PriceKind.AParade: return Settings.costFortParade; case PriceKind.ACaptureHexa: return Settings.costFortCapture; case PriceKind.AStealSources: return Settings.costFortSources; } return null; }
public int GetPoints(PriceKind kind) { switch (kind) { case PriceKind.BRoad: return Settings.pointsRoad; case PriceKind.BTown: return Settings.pointsTown; case PriceKind.BFort: return Settings.pointsFort; case PriceKind.BMarket: return Settings.pointsMarket; case PriceKind.BMonastery: return Settings.pointsMonastery; case PriceKind.BMill: return Settings.pointsMill; case PriceKind.BStepherd: return Settings.pointsStepherd; case PriceKind.BSaw: return Settings.pointsSaw; case PriceKind.BQuarry: return Settings.pointsQuarry; case PriceKind.BMine: return Settings.pointsMine; case PriceKind.UMill1: return Settings.pointsUpgradeLvl1; case PriceKind.UStepherd1: return Settings.pointsUpgradeLvl1; case PriceKind.UQuarry1: return Settings.pointsUpgradeLvl1; case PriceKind.USaw1: return Settings.pointsUpgradeLvl1; case PriceKind.UMine1: return Settings.pointsUpgradeLvl1; case PriceKind.UMill2: return Settings.pointsUpgradeLvl2; case PriceKind.UStepherd2: return Settings.pointsUpgradeLvl2; case PriceKind.UQuarry2: return Settings.pointsUpgradeLvl2; case PriceKind.USaw2: return Settings.pointsUpgradeLvl2; case PriceKind.UMine2: return Settings.pointsUpgradeLvl2; case PriceKind.MCorn1: return Settings.pointsMarketLvl1; case PriceKind.MMeat1: return Settings.pointsMarketLvl1; case PriceKind.MStone1: return Settings.pointsMarketLvl1; case PriceKind.MWood1: return Settings.pointsMarketLvl1; case PriceKind.MOre1: return Settings.pointsMarketLvl1; case PriceKind.MCorn2: return Settings.pointsMarketLvl2; case PriceKind.MMeat2: return Settings.pointsMarketLvl2; case PriceKind.MStone2: return Settings.pointsMarketLvl2; case PriceKind.MWood2: return Settings.pointsMarketLvl2; case PriceKind.MOre2: return Settings.pointsMarketLvl2; case PriceKind.AParade: return Settings.pointsFortParade; case PriceKind.ACaptureHexa: return Settings.pointsFortCapture; case PriceKind.AStealSources: return Settings.pointsFortSteal; } return 0; }
ActiveState state; // about which town, hexa etc it is about #endregion Fields #region Constructors public ActionSource(DelAction action, PriceKind price) : this(action, () => { return price;}) { }