private PriceItem GetPrice(CurrencyTypeEnum currencyType) { lock (_priceList) { if (!_priceList.Any() || _updateTime == null || (_updateTime != null && _updateTime < DateTime.Now)) { var list = new List <PriceItem>(); while (!list.Any()) { list = PriceManager.Get(_cs); PriceManager.Update(_cs); } _priceList = list; _updateTime = DateTime.Now.AddSeconds(10); } return(_priceList.FirstOrDefault(x => x.CurrencyCode == currencyType)); } }
public ServiceResult Update(PriceRule fat) { if (fat == null) { return(ServiceResponse.Error("Invalid PriceRule sent to server.")); } PriceManager financeManager = new PriceManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var res = financeManager.Get(fat.UUID); if (res.Code != 200) { return(res); } var dbS = (PriceRule)res.Result; if (dbS.DateCreated == DateTime.MinValue) { dbS.DateCreated = DateTime.UtcNow; } dbS.Name = fat.Name; dbS.Image = fat.Image; dbS.Deleted = fat.Deleted; dbS.Status = fat.Status; dbS.SortOrder = fat.SortOrder; dbS.Expires = fat.Expires; dbS.ReferenceType = fat.ReferenceType; dbS.Code = fat.Code; dbS.Operand = fat.Operand; dbS.Operator = fat.Operator; dbS.Minimum = fat.Minimum; dbS.Maximum = fat.Maximum; dbS.Mandatory = fat.Mandatory; dbS.MaxUseCount = fat.MaxUseCount; return(financeManager.Update(dbS)); }
public ServiceResult Update(PriceRule fat) { if (fat == null) { return(ServiceResponse.Error("Invalid PriceRule sent to server.")); } PriceManager financeManager = new PriceManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); var dbS = (PriceRule)financeManager.GetBy(fat.UUID); if (dbS == null) { return(ServiceResponse.Error("PriceRule was not found.")); } if (dbS.DateCreated == DateTime.MinValue) { dbS.DateCreated = DateTime.UtcNow; } dbS.Name = fat.Name; dbS.Image = fat.Image; dbS.Deleted = fat.Deleted; dbS.Status = fat.Status; dbS.SortOrder = fat.SortOrder; dbS.Expires = fat.Expires; dbS.ReferenceType = fat.ReferenceType; dbS.Code = fat.Code; dbS.Operand = fat.Operand; dbS.Operator = fat.Operator; dbS.Minimum = fat.Minimum; dbS.Maximum = fat.Maximum; dbS.Mandatory = fat.Mandatory; dbS.MaxUseCount = fat.MaxUseCount; return(financeManager.Update(dbS)); }