public aspnet_Users GetUserByLoginName(string loginName)
 {
     using (var ctx = new forexBox2Entities())
     {
         return ctx.aspnet_Users.FirstOrDefault(x => x.UserName.ToUpper() == loginName.ToUpper());
     }
 }
 public List<AccountData> GetAccountsByUserId(Guid id)
 {
     using (var ctx = new forexBox2Entities())
     {
         return ctx.AccountDatas.Where(x => x.UserId == id).ToList();
     }
 }
 public aspnet_Users GetUserById(Guid userId)
 {
     using (var ctx = new forexBox2Entities())
     {
         return ctx.aspnet_Users.FirstOrDefault(x => x.UserId == userId);
     }
 }
 public AccountData GetAccountById(int accountId)
 {
     using (var ctx = new forexBox2Entities())
     {
         return ctx.AccountDatas.FirstOrDefault(x => x.Id == accountId);
     }
 }
        public bool DeleteAccount(int id)
        {
            using (var ctx = new forexBox2Entities())
            {
                var account = ctx.AccountDatas.FirstOrDefault(x => x.Id == id);
                if (account != null)
                {
                    var datas = ctx.DepositsDatas.Where(x => x.AccountId == id);
                    foreach (var data in datas)
                    {
                        ctx.DeleteObject(data);
                    }

                    ctx.DeleteObject(account);
                }

                try
                {
                    ctx.SaveChanges();
                }
                catch { return false; }
            }

            return true;
        }
 /// <summary>
 /// Method get from database all deposits data by uerid
 /// </summary>
 /// <param name="userId">Account id</param>
 /// <returns>List of deposit data for current user</returns>
 public List<DepositsData> GetDepositsDataByUserId(int accountId)
 {
     using (var ctx = new forexBox2Entities())
     {
         var values = ctx.DepositsDatas.Where(x => x.AccountId == accountId).ToList();
         return values;
     }
 }
 public void UpdateUserStatisticSettings(UserStatisticSettings settings)
 {
     using (var ctx = new forexBox2Entities())
     {
         var entity = ctx.StatisticConfigurations.FirstOrDefault(x => x.UserId == settings.UserId);
         if (entity != null)
         {
             var data = SerializeObject(settings);
             entity.Data = data;
             ctx.SaveChanges();
         }
     }
 }
        public bool AddAcount(AccountData account)
        {
            using (var ctx = new forexBox2Entities())
            {
                ctx.AccountDatas.AddObject(account);

                try
                {
                    ctx.SaveChanges();
                }
                catch { return false; }
            }

            return true;
        }
        public UserStatisticSettings GetUserStatisticSettingsByUserId(Guid id)
        {
            UserStatisticSettings settings = null;

            using (var ctx = new forexBox2Entities())
            {
                var dbEntity = ctx.StatisticConfigurations.FirstOrDefault(x => x.UserId == id);
                if (dbEntity != null)
                {
                    settings = DeserializeObject(dbEntity.Data);
                    settings.UserId = id;
                }
            }

            return settings;
        }
        public void IncrementViewsById(int accountId)
        {
            using (var ctx = new forexBox2Entities())
            {
                var account = ctx.AccountDatas.FirstOrDefault(x => x.Id == accountId);

                if (account != null)
                {
                    account.Views = (account.Views == null) ? 1 : account.Views + 1;

                    try
                    {
                        ctx.SaveChanges();
                    }
                    catch { }
                }
            }
        }
        public bool AddUserStatisticSettings(UserStatisticSettings settings)
        {
            using (var ctx = new forexBox2Entities())
            {
                var data = SerializeObject(settings);
                ctx.StatisticConfigurations.AddObject(new StatisticConfiguration
                {
                    Data = data,
                    UserId = settings.UserId,
                });

                try
                {
                    ctx.SaveChanges();
                }
                catch { return false; }
            }

            return true;
        }
示例#12
0
 static UsersManager()
 {
     EntitiesContainer = new forexBox2Entities();
 }
示例#13
0
 static BrokersManagement()
 {
     EntitiesContainer = new forexBox2Entities();
 }
        public bool SaveAcount(AccountData account)
        {
            using (var ctx = new forexBox2Entities())
            {
                var existAccount = ctx.AccountDatas.FirstOrDefault(x => x.Id == account.Id);
                if (existAccount != null)
                {
                    existAccount.Broker = account.Broker;
                    existAccount.Leverage = account.Leverage;
                    existAccount.System = account.System;
                    existAccount.Technical = account.Technical;
                    existAccount.Trading = account.Trading;
                    existAccount.Type = account.Trading;
                    existAccount.Desctiption = account.Desctiption;

                    try
                    {
                        ctx.SaveChanges();
                    }
                    catch { return false; }
                }
            }

            return true;
        }
示例#15
0
 static AccountsManagement()
 {
     EntitiesContainer = new forexBox2Entities();
 }