/// <inheritdoc /> Task <IEnumerable <CakeDto> > ICakeApi.GetNearbyCakes(DbPosition argPosition) { var arguments = new object[] { argPosition }; var func = requestBuilder.BuildRestResultFuncForMethod("GetNearbyCakes", new Type[] { typeof(DbPosition) }); return((Task <IEnumerable <CakeDto> >)func(Client, arguments)); }
public void CreateBitmexTrade(DbPosition pos) { var stopLoss = GetAlignedStopLoss(Convert.ToDouble(lblBidPrice.Content)); if (stopLoss.HasValue) { MainWnd.Controller.CreateBitmexTrade(pos, stopLoss.Value, Convert.ToDouble(tbRiskPcnt.Text), 0, 0);//!! _posWatcher.StopPrice.Value, _posWatcher.StartWatchingPrice.Value); } }
public void CreateBitmexTrade(DbPosition position, double stopValue, double riskPercent, double stopPrice, double startWatchPrice) { Position = position; StopValue = stopValue; StopPrice = stopPrice; RiskPercent = riskPercent; StartWatchPrice = startWatchPrice; _api.UserQuery("/v1/trade", HttpMethod.Post, JsonConvert.SerializeObject(this), true); }
public async Task <TokenDTO> LoginAsync(string Username, string Password) { try { Employee user = Context.Employee.Where(x => x.Username == Username).FirstOrDefault(); if (user == null) { EmployeeDTO ADUser = LDAPService.LDAP_Authenticate(Username, Password); if (ADUser.Username == null) { tokens.Message = "ไม่พบข้อมูลผู้ใช้งาน"; return(tokens); } else { string SystemCode = await CreateNewUserAsync(ADUser); tokens.empCode = SystemCode; tokens.Message = "Login Success"; return(tokens); } } else { Password = EncryptionService.HashToMD5(Password + user.Passwordsalt); Employee users = Context.Employee.Where(x => x.Username == Username && x.Password == Password).FirstOrDefault(); EmployeeProfile employeeProfile = Context.EmployeeProfile.Where(x => x.Empcode == user.Empcode).FirstOrDefault(); DbPosition dbPosition = Context.DbPosition.Where(x => x.PositonCode == employeeProfile.PositionCode).FirstOrDefault(); if (users == null) { //user.UpdDate = DateTime.Now; //Context.Employee.Update(user); //Context.SaveChanges(); tokens.Message = "ชื่อผู้ใช้ และ รหัสผ่านไม่ถูกต้อง"; return(tokens); } else { //TOKEN tokens.empCode = user.Empcode; tokens.Username = users.Username; tokens.Firstname = employeeProfile.FirstnameEn; tokens.Lastname = employeeProfile.LastnameEn; tokens.PositionCode = dbPosition.PositonCode; tokens.Token = GenerateToken(user.Empcode); tokens.Message = "Login Success"; return(tokens); } } } catch (Exception ex) { throw ex; } }
public async Task <string> CreateNewUserAsync(EmployeeDTO ADUser) { try { Employee user = new Employee(); EmployeeProfile employeeProfile = Context.EmployeeProfile.Where(x => x.Empcode == ADUser.Empcode).FirstOrDefault(); DbPosition dbPosition = Context.DbPosition.Where(x => x.PositionName == ADUser.Position).FirstOrDefault(); user.Empcode = ADUser.Empcode; user.Username = ADUser.Username; user.Passwordsalt = EncryptionService.GeneratePasswordSalt(); user.Password = EncryptionService.HashToMD5(ADUser.Password + user.Passwordsalt); user.Active = true; user.CrBy = "LDAP"; user.CrDate = DateTime.Now; Context.Employee.Add(user); Context.SaveChanges(); if (employeeProfile == null) { employeeProfile.Empcode = ADUser.Empcode; employeeProfile.FirstnameTh = ADUser.FirstnameEn; employeeProfile.LastnameEn = ADUser.LastnameEn; employeeProfile.Tel = ADUser.Tel; employeeProfile.Email = ADUser.Email; employeeProfile.Position = ADUser.Position; if (dbPosition != null) { employeeProfile.PositionCode = dbPosition.PositonCode; } Context.EmployeeProfile.Add(employeeProfile); Context.SaveChanges(); } //TOKEN tokens.empCode = ADUser.Empcode; tokens.Username = ADUser.Username; tokens.Firstname = ADUser.FirstnameEn; tokens.Lastname = ADUser.LastnameEn; tokens.PositionCode = dbPosition.PositonCode; tokens.Token = GenerateToken(user.Empcode); return(user.Empcode); } catch (Exception ex) { throw ex; } }
/// <inheritdoc/> public void NewPosition(NewPositionRequest request) { if (request.Grade < 0 || request.Grade > 15 || request.Name == string.Empty) { throw new ArgumentException(); } DbPosition dbPosition = _mapper.Map <NewPositionRequest, DbPosition>(request); dbPosition.Id = Guid.NewGuid(); _positionRepository.NewPosition(dbPosition); }
public async Task <IEnumerable <CakeDto> > GetNearbyCakes(DbPosition position) { try { return(await Api.GetNearbyCakes(position)); } catch (Exception ex) { Logger.Error(ex, nameof(GetNearbyCakes)); return(new List <CakeDto>()); } }
public Task <IEnumerable <CakeDto> > GetNearbyCakes(DbPosition argPosition) { return(Task.FromResult(_testCakes)); }
public void InsertPosition(DbPosition position) { gridPositions.Items.Insert(0, position); }
public void CreateBitmexTrade(DbPosition position, double stopValue, double riskPercent, double stopPrice, double startWatchPrice) { createTradeRequest().CreateBitmexTrade(position, stopValue, riskPercent, stopPrice, startWatchPrice); }
///<inheritdoc/> public void UpdatePosition(DbPosition position) { _db.Execute("UPDATE position SET name = @Name, grade = @Grade WHERE id = @Id", position); }
///<inheritdoc/> public void NewPosition(DbPosition dbPosition) { _db.Execute(@"INSERT INTO position VALUES (@Id, @Name, @Grade)", dbPosition); }