Esempio n. 1
0
        public ServicePrinciple GetCurrentService(string email)
        {
            AccountDataModel accountDataModel = _accountData.Find(s => s.Email == email).FirstOrDefault();
            ServicePrinciple servicePrinciple = accountDataModel.servicePrinciples.Find(s => s.flag == true);

            return(servicePrinciple);
        }
Esempio n. 2
0
        }//END CreateAccount

        //Get Current Account Online
        public void GetAccountUser(int AccountId)
        {
            if (Session["userOnline"] == null)
            {
                return;
            }

            AccountModel     user    = (AccountModel)Session["userOnline"];
            AccountDataModel accUser = null;

            using (SGFEntitiess acc = new SGFEntitiess())
            {
                var result = from a in acc.SGF_T_ACCOUNT
                             join au in acc.SGF_T_ACCOUNT_USER on a.ACCOUNT_ID equals au.ACCOUNT_ID
                             where a.ACCOUNT_ID == AccountId && au.USER_ID == user.UserId
                             select a;

                var accResult = result.SingleOrDefault();

                //Asign account
                accUser                = new AccountDataModel();
                accUser.Account_Id     = accResult.ACCOUNT_ID;
                accUser.Account_Name   = accResult.ACCOUNT_NAME;
                accUser.Account_Number = accResult.ACCOUNT_NUMBER;
                accUser.Balance        = (double)accResult.BALANCE;
                accUser.Bank_Name      = accResult.BANK_NAME;
                accUser.Other_Info     = accResult.OTHER_INFO;
            }
            Session["accountOnline"] = accUser;
        }
Esempio n. 3
0
 public object Login(string email, string pwd)
 {
     if (_accountDao.UserIsExist(email))
     {
         AccountDataModel user = _accountDao.GetUserByEmail(email);
         if (user.Password == pwd)
         {
             TokenModel tokenInfo = _authBus.RequestToken(email, pwd);
             return(new
             {
                 success = true,
                 info = user.Id,
                 email = email,
                 access_token = tokenInfo.access_token
             });
         }
         else
         {
             return(new
             {
                 success = false,
                 info = 1
             });
         }
     }
     else
     {
         return(new
         {
             success = false,
             info = 0
         });
     }
 }
Esempio n. 4
0
        public string AddServicePrinciple(string email, ServicePrinciple servicePrinciple)
        {
            AccountDataModel        accountDataModel  = _accountData.Find(s => s.Email == email).FirstOrDefault();
            List <ServicePrinciple> servicePrinciples = accountDataModel.servicePrinciples;

            if (servicePrinciples != null)
            {
                ServicePrinciple service = servicePrinciples.Find(s => s.TenantId == servicePrinciple.TenantId && s.ClientId == servicePrinciple.ClientId);
                if (service == null)
                {
                    accountDataModel.servicePrinciples.Add(servicePrinciple);
                }
                else
                {
                    return("service is already Exist");
                }
            }
            else
            {
                List <ServicePrinciple> temp_servicePrinciples = new List <ServicePrinciple>();
                temp_servicePrinciples.Add(servicePrinciple);
                accountDataModel.servicePrinciples = temp_servicePrinciples;
            }
            var filter = Builders <AccountDataModel> .Filter.Eq("Email", email);

            var update = Builders <AccountDataModel> .Update.Set("ServicePrinciples", accountDataModel.servicePrinciples);

            //BsonDocument bd = BsonExtensionMethods.ToBsonDocument(accountDataModel);
            _accountData.UpdateOne(filter, update);
            return("success");
        }
Esempio n. 5
0
 public static void Update(AccountDataModel model)
 {
     try
     {
         MySqlCommand Command = new MySqlCommand()
         {
             Connection = DatabaseManager.Provider.getConnection(),
             // CommandText = "UPDATE `accounts_data` VALUES(@client,@bank,@kamas,@stable,@friend,@ennemy,@seefriend);",
             CommandText = "UPDATE `accounts_data` set bank = @bank, bankkamas = @kamas, stables = @stable , friends = @friend , enemys = @ennemy , seeFriend = @seefriend  WHERE guid= @guid;",
         };
         Command.Prepare();
         Command.Parameters.AddWithValue("@guid", model.Guid);
         Command.Parameters.AddWithValue("@bank", model.Bank);
         Command.Parameters.AddWithValue("@kamas", model.BankKamas);
         Command.Parameters.AddWithValue("@stable", model.Stables);
         Command.Parameters.AddWithValue("@friend", model.Friends);
         Command.Parameters.AddWithValue("@ennemy", model.Ennemys);
         Command.Parameters.AddWithValue("@seefriend", (model.showFriendConnection ? 1 : 0));
         Command.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         Logger.Error("Can't execute query : " + e.ToString());
     }
 }
Esempio n. 6
0
        public List <ServicePrinciple> ListServicePrinciples(string email)
        {
            AccountDataModel        accountDataModel  = _accountData.Find(s => s.Email == email).FirstOrDefault();
            List <ServicePrinciple> servicePrinciples = accountDataModel.servicePrinciples;

            return(servicePrinciples);
        }
Esempio n. 7
0
        public async Task <AccountDataModel> GetAccountAsync(string accountNumber)
        {
            try
            {
                var account = await ApiClient.NumberGetAsync(accountNumber);

                if (account == null)
                {
                    return(null);
                }

                var accountDto = new AccountDataModel()
                {
                    AccountNumber = account.Identifier.AccountNumber,
                    AccountName   = account.Name,
                    SortCode      = account.Identifier.SortCode
                };

                return(accountDto);
            }
            catch (Exception ex)
            {
                // Log this error to serilog

                throw;
            }
        }
Esempio n. 8
0
        }//GetAccountDashBoard

        //public ActionResult RegisterAccountBank()
        //{
        //    AccountDashBoardModel dashboardmodel = null;
        //    AccountDataModel model = new AccountDataModel();

        //    if (Session["accountDashboard"] != null)
        //    {
        //        int AccountId = 0;
        //        dashboardmodel = (AccountDashBoardModel)Session["accountDashboard"];
        //        AccountId = dashboardmodel.dashboard.Account_Id;

        //        using (SGFEntitiess accountData = new SGFEntitiess())
        //        {
        //            var result = from n in accountData.SGF_T_ACCOUNT
        //                         where n.ACCOUNT_ID == AccountId
        //                         select n;

        //            var acc = result.ToList().SingleOrDefault();
        //            model.Account_Id = acc.ACCOUNT_ID;
        //            model.Account_Name = acc.ACCOUNT_NAME;
        //            model.Account_Number = acc.ACCOUNT_NUMBER;
        //            model.Balance = (double)acc.BALANCE;
        //            model.Bank_Name = acc.BANK_NAME;
        //            model.Other_Info = acc.OTHER_INFO;

        //            Session["accountOnline"] = model;

        //        }
        //    }

        //    return View(model);
        //}//END RegisterAccountBank

        //// POST: /Home/RegisterAccountBank
        //[HttpPost]
        //public ActionResult RegisterAccountBank(AccountDataModel model)
        //{
        //    bool createAccount = false;
        //    CreateAccount(model.Account_Id, model.Account_Number, model.Account_Name, model.Bank_Name, model.Other_Info, out createAccount);

        //    if (createAccount)
        //    {
        //        return RedirectToAction("Index", "Home");
        //    }
        //    else
        //    {
        //        return View(model);
        //        //ModelState.AddModelError("", ErrorCodeToString(createStatus));
        //        //return RedirectToAction("Register", "Account");
        //    }

        //    // If we got this far, something failed, redisplay form
        //    return View(model);
        //}

        public ActionResult RegisterAccountBank(int Id = 0)
        {
            /*
             * AccountDashBoardModel dashboardmodel = null;
             * AccountDataModel model = new AccountDataModel();
             *
             * if (Session["accountDashboard"] != null)
             * {
             *  int AccountId = 0;
             *  dashboardmodel = (AccountDashBoardModel)Session["accountDashboard"];
             *  AccountId = dashboardmodel.dashboard.Account_Id;
             *
             *  using (SGFEntitiess accountData = new SGFEntitiess())
             *  {
             *      var result = from n in accountData.SGF_T_ACCOUNT
             *                   where n.ACCOUNT_ID == AccountId
             *                   select n;
             *
             *      var acc = result.ToList().SingleOrDefault();
             *      model.Account_Id = acc.ACCOUNT_ID;
             *      model.Account_Name = acc.ACCOUNT_NAME;
             *      model.Account_Number = acc.ACCOUNT_NUMBER;
             *      model.Balance = (double)acc.BALANCE;
             *      model.Bank_Name = acc.BANK_NAME;
             *      model.Other_Info = acc.OTHER_INFO;
             *
             *      Session["accountOnline"] = model;
             *
             *  }
             * }
             */

            AccountDataModel model = new AccountDataModel();

            if (Id == 0)
            {
                return(View(model));
            }
            int AccountId = Id;

            using (SGFEntitiess accountData = new SGFEntitiess())
            {
                var result = from n in accountData.SGF_T_ACCOUNT
                             where n.ACCOUNT_ID == AccountId
                             select n;

                var acc = result.ToList().SingleOrDefault();
                model.Account_Id     = acc.ACCOUNT_ID;
                model.Account_Name   = acc.ACCOUNT_NAME;
                model.Account_Number = acc.ACCOUNT_NUMBER;
                model.Balance        = (double)acc.BALANCE;
                model.Bank_Name      = acc.BANK_NAME;
                model.Other_Info     = acc.OTHER_INFO;

                Session["accountOnline"] = model;
            }

            return(View(model));
        }//END RegisterAccountBank
Esempio n. 9
0
        public Account Create(Account account)
        {
            AccountDataModel acct = _mapper.Map <AccountDataModel>(account);

            _DbContext.Accounts.Add(acct);
            _DbContext.SaveChanges();
            return(account);
        }
Esempio n. 10
0
        //View for Register Movements
        public ActionResult RegisterMovement()
        {
            if (Session["accountOnline"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                //Only load movtypes if nor yet in memory
                if (Session["movementTypes"] == null)
                {
                    GetMovementTypes();
                }

                AccountDataModel acc = (AccountDataModel)Session["accountOnline"];
                //Get all movements of Account Online
                using (SGFEntitiess accMovements = new SGFEntitiess())
                {
                    var result = from ac in accMovements.SGF_T_ACCOUNT_MOVEMENT
                                 join mt in accMovements.SGF_R_MOVEMENT_TYPE on ac.MOV_TYPE_ID equals mt.MOV_TYPE_ID
                                 join c in accMovements.SGF_R_CATEGORY on ac.CAT_ID equals c.CAT_ID
                                 join sc in accMovements.SGF_R_SUB_CATEGORY on ac.SUB_CAT_ID equals sc.SUB_CAT_ID
                                 where ac.ACCOUNT_ID == acc.Account_Id
                                 orderby ac.CREATED_DATE descending
                                 select new
                    {
                        ac.MOV_ID,
                        ac.ACCOUNT_ID,
                        MOV_TYPE_DES = mt.DESCRIPTION,
                        CAT_DES      = c.DESCRIPTION,
                        SUB_CAT_DES  = sc.DESCRIPTION,
                        ac.AMOUNT,
                        ac.DESCRIPTION,
                        ac.CREATED_DATE
                    };

                    List <AccountMovementModel> lstResult = new List <AccountMovementModel>();
                    foreach (var obj in result.ToList())
                    {
                        AccountMovementModel amm = new AccountMovementModel();
                        amm.MovId       = obj.MOV_ID;
                        amm.AccountId   = obj.ACCOUNT_ID;
                        amm.MovTypeDes  = obj.MOV_TYPE_DES;
                        amm.CatDes      = obj.CAT_DES;
                        amm.SubCatDes   = obj.SUB_CAT_DES;
                        amm.Amount      = (double)obj.AMOUNT;
                        amm.Description = obj.DESCRIPTION;
                        amm.CreatedDate = obj.CREATED_DATE;
                        lstResult.Add(amm);
                    }
                    Session["accountOnlineAllMovements"] = lstResult;
                    return(View());
                }
            }
        }//END RegisterMovement
Esempio n. 11
0
        private Dictionary <string, object> ExcludeProperties(AccountDataModel accountDataModel, IEnumerable <string> propertyNames)
        {
            var response   = new Dictionary <string, object>();
            var properties = propertyNames.Select(x => x.ToLower());

            if (!properties.Contains(nameof(accountDataModel.Id).ToLower()))
            {
                response.Add("id", accountDataModel.Id);
            }

            if (!properties.Contains(nameof(accountDataModel.String).ToLower()))
            {
                response.Add("string", accountDataModel.String);
            }

            if (!properties.Contains(nameof(accountDataModel.Integer).ToLower()))
            {
                response.Add("integer", accountDataModel.Integer);
            }

            if (!properties.Contains(nameof(accountDataModel.Float).ToLower()))
            {
                response.Add("float", accountDataModel.Float);
            }

            if (!properties.Contains(nameof(accountDataModel.Double).ToLower()))
            {
                response.Add("double", accountDataModel.Double);
            }


            if (!properties.Contains(nameof(accountDataModel.Decimal).ToLower()))
            {
                response.Add("decimal", accountDataModel.Decimal);
            }

            if (!properties.Contains(nameof(accountDataModel.PropertyFour).ToLower()))
            {
                response.Add("propertyFour", accountDataModel.PropertyFour);
            }

            if (!properties.Contains(nameof(accountDataModel.PropertyFive).ToLower()))
            {
                response.Add("propertyFive", accountDataModel.PropertyFive);
            }

            if (!properties.Contains(nameof(accountDataModel.PropertySix).ToLower()))
            {
                response.Add("propertySix", accountDataModel.PropertySix);
            }

            return(response);
        }
Esempio n. 12
0
        public object CreateUser(string email, string pwd)
        {
            AccountDataModel accountDataModel = new AccountDataModel
            {
                Email             = email,
                Password          = pwd,
                servicePrinciples = null
            };

            _accountData.InsertOneAsync(accountDataModel);
            return(new { success = true });
        }
        private static void CallSeeder(BasicTestAppDbContext context)
        {
            AccountDataModel account = new AccountDataModel()
            {
                AccountId   = 1,
                Created     = new DateTime(2017, 10, 10),
                AccountName = "Test",
                CreatedBy   = "Fenix"
            };

            context.Accounts.Add(account);
            context.SaveChanges();
        }
Esempio n. 14
0
        public string UpdateClientSecret(string email, ServicePrinciple servicePrinciple)
        {
            AccountDataModel accountDataModel = _accountData.Find(s => s.Email == email).FirstOrDefault();

            accountDataModel.servicePrinciples.Find(s => s.TenantId == servicePrinciple.TenantId && s.ClientId == servicePrinciple.ClientId).ClientSecret = servicePrinciple.ClientSecret;
            var filter = Builders <AccountDataModel> .Filter.Eq("Email", email);

            var update = Builders <AccountDataModel> .Update.Set("ServicePrinciples", accountDataModel.servicePrinciples);

            //BsonDocument bd = BsonExtensionMethods.ToBsonDocument(accountDataModel);
            _accountData.UpdateOne(filter, update);
            return("success");
        }
Esempio n. 15
0
        public ActionResult RegisterAccountBank(AccountDataModel model)
        {
            bool createAccount = false;

            CreateAccount(model.Account_Id, model.Account_Number, model.Account_Name, model.Bank_Name, model.Other_Info, out createAccount);

            if (createAccount)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(model));
                //ModelState.AddModelError("", ErrorCodeToString(createStatus));
                //return RedirectToAction("Register", "Account");
            }
        }
Esempio n. 16
0
 public AccountDataModel GetUserByEmail(string email)
 {
     if (UserIsExist(email))
     {
         AccountDataModel accountDataModel = _accountData.Find(s => s.Email == email).FirstOrDefault();
         AccountModel     accountModel     = new AccountModel
         {
             email    = accountDataModel.Email,
             password = accountDataModel.Password,
         };
         return(accountDataModel);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 17
0
        private async Task <ActionResult> GetAccountDataView(AccountDataContent content)
        {
            string errorText   = null;
            string logoutUrl   = this.AuthClient.GetLogoutUrl(this.SiteRootPath + "account/logout");
            var    accountData = new AccountDataModel()
            {
                LogoutURL       = logoutUrl,
                ShowContactsURL = ShowContactsUrl,
                HomeURL         = this.SiteRootPath
            };

            LiveConnectClient   client   = new LiveConnectClient(this.AuthClient.Session);
            LiveOperationResult meResult = await QueryUserData(client, "me");

            if (meResult != null)
            {
                dynamic meInfo = meResult.Result;
                accountData.Name = meInfo.name;

                accountData.ProfileImage = await GetProfileImageData(client);
            }
            else
            {
                errorText = "There was an error while retrieving the user's information. Please try again later.";
            }

            if (errorText == null && (content & AccountDataContent.Contacts) == AccountDataContent.Contacts)
            {
                LiveOperationResult contactsResult = await QueryUserData(client, "me/contacts");

                if (contactsResult != null)
                {
                    dynamic contacts = contactsResult.Result;
                    accountData.Contacts = contacts.data;
                }
                else
                {
                    errorText = "There was an error while retrieving the user's contacts data. Please try again later.";
                }
            }

            accountData.Error = errorText;
            return(View("AccountData", accountData));
        }
Esempio n. 18
0
        public static AccountDataModel Get(int id)
        {
            AccountDataModel model = null;
            var reader             = DatabaseManager.Provider.ExecuteReader("SELECT * FROM accounts_data WHERE guid = " + id);

            if (reader.Read())
            {
                model = new AccountDataModel()
                {
                    Guid                 = reader.GetInt32("guid"),
                    Bank                 = reader.GetString("bank"),
                    BankKamas            = reader.GetInt64("bankkamas"),
                    Stables              = reader.GetString("stables"),
                    Friends              = reader.GetString("friends"),
                    Ennemys              = reader.GetString("enemys"),
                    showFriendConnection = reader.GetInt32("seeFriend") == 1,
                };
            }
            reader.Close();
            return(model);
        }
Esempio n. 19
0
        public string SetServicePrinciple(string email, string tenantId, string clientId)
        {
            AccountDataModel accountDataModel         = _accountData.Find(s => s.Email == email).FirstOrDefault();
            ServicePrinciple current_servicePrinciple = accountDataModel.servicePrinciples.Find(s => s.flag == true);
            ServicePrinciple servicePrinciple         = accountDataModel.servicePrinciples.Find(s => s.TenantId == tenantId && s.ClientId == clientId);

            if (current_servicePrinciple == null)
            {
                servicePrinciple.flag = true;
            }
            else
            {
                current_servicePrinciple.flag = false;
                servicePrinciple.flag         = true;
            }
            var filter = Builders <AccountDataModel> .Filter.Eq("Email", email);

            var update = Builders <AccountDataModel> .Update.Set("ServicePrinciples", accountDataModel.servicePrinciples);

            _accountData.UpdateOne(filter, update);
            return("success");
        }
Esempio n. 20
0
        public ActionResult SaveMovement()
        {
            //For several movements at same time should use json
            //string[] movs = operations.Split('|');

            string operations = null;

            operations = HttpContext.Request.Form[0].ToString();

            if (operations == null)
            {
                return(View());
            }

            string[] vars = operations.ToString().Split(';');
            //    var sendstr = "-1;true;" + ";" + mtype + ";" + cattype + ";" + subcattype + ";" + movamount + ";" + movdescription + ";" + dipckerdate;
            using (SGFEntitiess accM = new SGFEntitiess())
            {
                AccountDataModel acc  = (AccountDataModel)Session["accountOnline"];
                AccountModel     user = (AccountModel)Session["userOnline"];

                Int32?subcat = null;
                try{
                    subcat = Int32.Parse(vars[4]);
                }
                catch (Exception e) {}

                //Add new Movement
                SGF_T_ACCOUNT_MOVEMENT accMov = SGF_T_ACCOUNT_MOVEMENT.CreateSGF_T_ACCOUNT_MOVEMENT(Int32.Parse(vars[0]), acc.Account_Id, Int32.Parse(vars[2]), Int32.Parse(vars[3]), subcat, (decimal)Double.Parse(vars[5]), vars[6].ToString(), user.Name.ToString(), DateTime.Parse(vars[7]));

                accM.AddToSGF_T_ACCOUNT_MOVEMENT(accMov);

                //commit changes
                accM.SaveChanges();
            }

            return(View());
        }
Esempio n. 21
0
        }//END RegisterMovement

        //View for Reports
        public ActionResult Reports()
        {
            if (Session["accountOnline"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                AccountDataModel acc = (AccountDataModel)Session["accountOnline"];
                ReportsModel     rpt = new ReportsModel();
                List <SGF_PROC_REPORTS_BY_CATEGORY_Result> data = new List <SGF_PROC_REPORTS_BY_CATEGORY_Result>();
                rpt.ReportType = 1;

                using (SGFEntitiess accRpt = new SGFEntitiess())
                {
                    data = accRpt.SGF_PROC_GET_REPORT_BY_CATEGORIES(acc.Account_Id, null, null, null).ToList();
                }

                rpt.ReportData           = data;
                Session["accountReport"] = rpt;
                return(View());
            }
        }//END Reports
Esempio n. 22
0
 public static void Add(AccountDataModel model)
 {
     try
     {
         MySqlCommand Command = new MySqlCommand()
         {
             Connection  = DatabaseManager.Provider.getConnection(),
             CommandText = "REPLACE INTO `accounts_data` VALUES(@guid,@bank,@kamas,@stable,@friend,@ennemy,@seefriend);",
         };
         Command.Prepare();
         Command.Parameters.AddWithValue("@guid", model.Guid);
         Command.Parameters.AddWithValue("@bank", model.Bank);
         Command.Parameters.AddWithValue("@kamas", model.BankKamas);
         Command.Parameters.AddWithValue("@stable", model.Stables);
         Command.Parameters.AddWithValue("@friend", model.Friends);
         Command.Parameters.AddWithValue("@ennemy", model.Ennemys);
         Command.Parameters.AddWithValue("@seefriend", (model.showFriendConnection ? 1 : 0));
         Command.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         Logger.Error("Can't execute query : " + e.ToString());
     }
 }
Esempio n. 23
0
 public ExchangeItemListMessagePerAccount(AccountDataModel adm, int bhi)
 {
     this.Account    = adm;
     this.BidHouseID = bhi;
 }
Esempio n. 24
0
        public string GetClientSecret(string email, string tenantId, string clientId)
        {
            AccountDataModel accountDataModel = _accountData.Find(s => s.Email == email).FirstOrDefault();

            return(accountDataModel.servicePrinciples.Find(s => s.TenantId == tenantId && s.ClientId == clientId).ClientSecret);
        }