public Dictionary <double, decimal> GetChartForPosition(int?id) { if (id == null) { throw new ValidationException(Resource.Resource.PositionIdNotSet, ""); } var position = db.Positions.Get(id.Value); if (position == null) { throw new ValidationException(Resource.Resource.PositionNotFound, ""); } var tradeInfo = tradeSybolService.GetDateForSymbolInDateInterval(position.OpenDate, position.CloseDate ?? DateTime.Now, position.SymbolId); var dates = tradeInfo.Select(d => HelperService.ConvertToUnixTimestamp(d.TradeDate) * 1000); var gains = tradeInfo.Select(d => calculationService.GetGain(d.Price, position.ClosePrice, position.OpenPrice, position.OpenWeight, d.Dividends, (TradeTypesDTO)position.TradeType)); var dic = dates.Zip(gains, (k, v) => new { k, v }).ToDictionary(x => x.k, x => x.v); return(dic); }
public void ValidateOnlyLogin(UserDTO userDto) { if (!Regex.IsMatch(userDto.Login, Resource.Resource.loginPattern)) { throw new ValidationException(Resource.Resource.LoginValidateMessage, HelperService.GetMemberName((UserDTO c) => c.Login)); } }
public void Validate(ViewDTO view) { var exceptionList = new List <ValidationException>(); if (view.MoneyPrecision < 0 || view.MoneyPrecision > 8) { exceptionList.Add(new ValidationException(Resource.Resource.MoneyPrecisionValidate, HelperService.GetMemberName((ViewDTO c) => c.MoneyPrecision))); } if (view.PercentyPrecision < 0 || view.PercentyPrecision > 8) { exceptionList.Add(new ValidationException(Resource.Resource.PercentyPrecisionValidate, HelperService.GetMemberName((ViewDTO c) => c.PercentyPrecision))); } CheckForExceptions(exceptionList); }
public void Validate(UserDTO userDto) { var exceptionList = new List <ValidationException>(); if (!Regex.IsMatch(userDto.Login, Resource.Resource.loginPattern)) { exceptionList.Add(new ValidationException(Resource.Resource.LoginValidateMessage, HelperService.GetMemberName((UserDTO c) => c.Login))); } if (!Regex.IsMatch(userDto.Password, Resource.Resource.passwordPattern)) { exceptionList.Add(new ValidationException(Resource.Resource.PasswordValidateMessage, HelperService.GetMemberName((UserDTO c) => c.Password))); } CheckForExceptions(exceptionList); }
public void Validate(PositionDTO position) { if (position.OpenWeight < 1 || position.OpenWeight > 10000) { throw new ValidationException(Resource.Resource.PositionOpenWeightValidate, HelperService.GetMemberName((PositionDTO c) => c.OpenWeight)); } }