public List<OrdersViewModel> GetOrders() { List<OrdersViewModel> allOrders = new List<OrdersViewModel>(); using (var connection = _databaseConnectionProvider.GetDbConnection()) { var orders = connection.Query<Order>("Select * from orders"); foreach (var item in orders) { OrdersViewModel model = new OrdersViewModel(); var product = _productMicroService.Search(item.productId); var customer = _customerMicroService.Search(item.customerId); model.Id = item.id; model.Amount = item.amount; model.ProductId = item.productId; model.ProductName = product.Name; model.Quantity = item.quantity; model.CustomerId = item.customerId; model.CustomerName = customer.Fullname; allOrders.Add(model); } } return allOrders; }
public IEnumerable <OrderTracker> GetOrderById(int OrderId) { var orders = new List <OrderTracker>(); using (var connection = _databaseConnectionProvider.GetDbConnection()) { orders = connection.Query <OrderTracker>(@"SELECT * from orderstatus WHERE orderid = @orderid", new { OrderId }).ToList(); } return(orders); }
public void Remove(int userId, int characterIndex) { using (var db = databaseConnectionProvider.GetDbConnection()) { db.Delete <CharactersTableDefinition>(c => c.UserId == userId && c.CharacterIndex == characterIndex); } }
public int GetUserId(string email) { using (var db = databaseConnectionProvider.GetDbConnection()) { var user = db.Single <UsersTableDefinition>(x => x.Email == email); return(user.Id); } }
public bool Verify(string name) { using (var db = databaseConnectionProvider.GetDbConnection()) { var isVerified = db.Exists <CharactersTableDefinition>(new { Name = name }); return(isVerified); } }
public bool Exists(int userId, CharacterIndex characterIndex) { using (var db = databaseConnectionProvider.GetDbConnection()) { var exists = db.Exists <CharactersTableDefinition>(new { UserId = userId, CharacterIndex = (int)characterIndex }); return(exists); } }
public bool IsExists(string email) { using (var db = databaseConnectionProvider.GetDbConnection()) { var isExists = db.Exists <UsersTableDefinition>(new { Email = email }); return(isExists); } }
public bool Exists(int userId) { using (var db = databaseConnectionProvider.GetDbConnection()) { var exists = db.Exists <UserProfilesTableDefinition>(new { UserId = userId }); return(exists); } }
public bool Verify(string email, string password) { using (var db = databaseConnectionProvider.GetDbConnection()) { var user = db.Single <UsersTableDefinition>(x => x.Email == email); var isVerified = user.Password == password; return(isVerified); } }
public CharacterParameters?GetCharacter(int userId, int characterIndex) { using (var db = databaseConnectionProvider.GetDbConnection()) { var charactersTable = db.Single <CharactersTableDefinition>(x => x.UserId == userId && x.CharacterIndex == characterIndex); var character = Utils.GetCharacterParameters(charactersTable); return(character); } }
public void Update(int userId, byte map) { using (var db = databaseConnectionProvider.GetDbConnection()) { db.UpdateOnly(() => new CharactersTableDefinition { LastMap = map }, @where: p => p.UserId == userId); } }
public void Update(int userId, int localId, ServerType serverType, ConnectionStatus connectionStatus) { using (var db = databaseConnectionProvider.GetDbConnection()) { db.UpdateOnly(() => new UserProfilesTableDefinition { LocalId = localId, CurrentServer = (byte)serverType, IsConnected = (byte)connectionStatus }, where : p => p.UserId == userId); } }
public void Create(int userId, int localId, ServerType serverType, ConnectionStatus connectionStatus) { using (var db = databaseConnectionProvider.GetDbConnection()) { var user = new UserProfilesTableDefinition { UserId = userId, CurrentServer = (byte)serverType, IsConnected = (byte)connectionStatus, LocalId = localId }; db.Insert(user); } }
public void Create(string email, string password, string firstName, string lastName) { using (var db = databaseConnectionProvider.GetDbConnection()) { var user = new UsersTableDefinition { Email = email, Password = password, FirstName = firstName, LastName = lastName }; db.Insert(user); } }
public void Create(int userId, string name, CharacterClasses characterClass, CharacterIndex characterIndex) { using (var db = databaseConnectionProvider.GetDbConnection()) { var user = new CharactersTableDefinition { UserId = userId, Name = name, CharacterType = characterClass.ToString(), CharacterIndex = (byte)characterIndex }; db.Insert(user); } }
public IEnumerable <CharacterParameters> GetCharacters(int userId) { using (var db = databaseConnectionProvider.GetDbConnection()) { // Should only be 3 characters. var charactersFromDatabase = db.Select <CharactersTableDefinition>().Where(x => x.UserId == userId); var charactersDatabase = charactersFromDatabase.Select(Utils.GetCharacterParameters).ToList(); // If there is no characters, it means that there is an empty character. var length = MAXIMUM_CHARACTERS - charactersDatabase.Count; for (var i = 0; i < length; i++) { charactersDatabase.Add(new CharacterParameters { HasCharacter = false, Index = CharacterIndex.Zero }); } // Make an order of characters which will be sent to a client. var characters = new List <CharacterParameters>(MAXIMUM_CHARACTERS) { new CharacterParameters { HasCharacter = false, Index = CharacterIndex.First }, new CharacterParameters { HasCharacter = false, Index = CharacterIndex.Second }, new CharacterParameters { HasCharacter = false, Index = CharacterIndex.Third } }; foreach (var character in charactersDatabase) { if (character.HasCharacter) { characters[(int)character.Index] = new CharacterParameters(character.Name, character.CharacterType, character.Index, character.LastMap); } } return(characters); } }