Exemple #1
0
        public AccountModel Post([FromUri] string option, [FromBody] AccountModel model, int id)
        {
            AccountModel result = null;

            switch (option)
            {
            case "current":
                var ca = DataSession.Query <ClientAccount>().FirstOrDefault(x => x.ClientOrg.ClientOrgID == id && x.Account.AccountID == model.AccountID);

                if (ca == null)
                {
                    //no existing ClientAccount record so create a new one
                    ca = new ClientAccount()
                    {
                        ClientOrg = DataSession.Single <ClientOrg>(id),
                        Account   = DataSession.Single <Account>(model.AccountID),
                        IsDefault = false,
                        Manager   = false
                    };

                    DataSession.Insert(ca);
                }

                Provider.Data.ActiveLog.Enable(ca);

                //may need to restore physical access because there is now an active acct and other requirements are met
                string  alert;
                IClient c = DataSession.Single <ClientInfo>(ca.ClientOrg.Client.ClientID);
                Provider.Data.Client.UpdatePhysicalAccess(c, out alert);

                result = ApiUtility.CreateAccountModel(ca.Account);

                break;
            }

            return(result);
        }