コード例 #1
0
        public HttpResponseMessage Put([FromBody] StoreAccount storeAccount)
        {
            if (storeAccount == null || storeAccount.StoreAccountId == 0)
            {
                return(this.Request.CreateResponse(HttpStatusCode.BadRequest, storeAccount));
            }

            try
            {
                var storeAccountToUpdate =
                    this.StoreAccountManager.GetById <StoreAccount>(
                        new object[] { storeAccount.StoreAccountId, storeAccount.UserIdentityName });

                storeAccountToUpdate.FirstName    = storeAccount.FirstName;
                storeAccountToUpdate.LastName     = storeAccount.LastName;
                storeAccountToUpdate.TelephoneNo  = storeAccount.TelephoneNo;
                storeAccountToUpdate.Address      = storeAccount.Address;
                storeAccountToUpdate.CountryId    = storeAccount.CountryId;
                storeAccountToUpdate.City         = storeAccount.City;
                storeAccountToUpdate.PostCode     = storeAccount.PostCode;
                storeAccountToUpdate.EmailAddress = storeAccount.EmailAddress;

                this.StoreAccountManager.Save();

                return(this.Request.CreateResponse(HttpStatusCode.OK, storeAccountToUpdate));
            }
            catch (Exception)
            {
                return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, storeAccount));
            }
        }
コード例 #2
0
        public void SetFileExpiryAbsolute(StoreAccount account, FsPath path, System.DateTimeOffset expiretime)
        {
            var ut        = new FsUnixTime(expiretime);
            var unix_time = ut.MillisecondsSinceEpoch;

            this.RestClient.FileSystem.SetFileExpiry(account.Name, path.ToString(), ExpiryOptionType.Absolute, unix_time);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Account customer = new Account("Dimitris", 2000, 0);

            Console.WriteLine(customer);

            bool success = customer.Withdraw(200);

            if (success)
            {
                Console.WriteLine(" Withdrawal successfull :)");
            }

            else
            {
                Console.WriteLine(" Withdrawal unsuccessfull :(");
            }



            customer.Withdraw(200);
            Console.WriteLine(customer);

            customer.Withdraw(200);
            Console.WriteLine(customer);

            customer.Withdraw(2000);
            Console.WriteLine(customer);

            StoreAccount storeAccount = new StoreAccount("manos", 2000, 0, "ypokatastima", "deposit");

            Console.WriteLine(storeAccount);

            storeAccount.Withdraw(200);
        }
コード例 #4
0
        public List <StoreAccount> GetStoreAccount(string storeId)
        {
            List <StoreAccount> list    = new List <StoreAccount>();
            StringBuilder       builder = new StringBuilder();

            builder.AppendFormat(StoreSqls.SELECT_STORE_ACCOUNT_BY_STORE_ID, storeId);
            string    sql = builder.ToString();
            DataTable dt  = DatabaseOperationWeb.ExecuteSelectDS(sql, "T").Tables[0];

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    StoreAccount storeAccount = new StoreAccount
                    {
                        heartNum    = dr["HEARTS"].ToString(),
                        paymentDays = dr["ACCOUNT_FROM"].ToString() + " - " + dr["ACCOUNT_TO"].ToString(),
                        state       = dr["STATE"].ToString() == "0" ? "待付款" : "已付款",
                    };
                    list.Add(storeAccount);
                }
            }

            return(list);
        }
コード例 #5
0
        public FsAcl GetAclStatus(StoreAccount store, FsPath path)
        {
            var acl_result = this.RestClient.FileSystem.GetAclStatus(store.Name, path.ToString());
            var acl_status = acl_result.AclStatus;

            var fs_acl = new FsAcl(acl_status);

            return(fs_acl);
        }
コード例 #6
0
        public HttpResponseMessage Post([FromBody] StoreAccount newStoreAccount)
        {
            if (string.IsNullOrEmpty(newStoreAccount.UserIdentityName))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, newStoreAccount));
            }

            var storeAccountExists =
                this.StoreAccountManager.Get <StoreAccount>()
                .Any(
                    m => m.UserIdentityName == newStoreAccount.UserIdentityName);

            if (storeAccountExists)
            {
                return(this.Request.CreateResponse(
                           HttpStatusCode.BadRequest, newStoreAccount, "store account already exists"));
            }

            try
            {
                this.StoreAccountManager.Add <StoreAccount>(newStoreAccount);
                this.StoreAccountManager.Save();


                var shoppingCartExists =
                    this.StoreAccountManager.Get <ShoppingCart>()
                    .Any(
                        m => m.StoreAccountId == newStoreAccount.StoreAccountId);

                if (shoppingCartExists)
                {
                    return(this.Request.CreateResponse(
                               HttpStatusCode.BadRequest, newStoreAccount, "shopping cart already exists"));
                }


                //create and save shopping cart
                var newShoppingCart = new ShoppingCart
                {
                    StoreAccountId = newStoreAccount.StoreAccountId,
                    StoreAccount   = newStoreAccount
                };

                this.StoreAccountManager.Add(newShoppingCart);
                this.StoreAccountManager.Save();

                //then pass the newly created shoppingcartid to new store account
                newStoreAccount.ShoppingCartId = newShoppingCart.ShoppingCartId;
                this.StoreAccountManager.Save();
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, newStoreAccount));
            }

            return(Request.CreateResponse(HttpStatusCode.Created, newStoreAccount));
        }
コード例 #7
0
        public void When(StoreAccount message)
        {
            var entry = message.Entry;

            if (_index.TryAdd(entry.UserId, entry))
            {
                Sender.Tell(new AccountStored(entry));
            }
            else
            {
                Sender.Tell(new AccountStorageFailed(entry));
            }
        }
コード例 #8
0
        public StoreAccount Get()
        {
            //try to get based on who is logged in
            var userIdentityName = HttpContext.Current.User.Identity.Name;
            var storeAccount     =
                this.StoreAccountManager.Get <StoreAccount>().FirstOrDefault(m => m.UserIdentityName == userIdentityName);

            if (storeAccount == null)
            {
                storeAccount = new StoreAccount();
            }

            return(storeAccount);
        }
コード例 #9
0
        // GET: StoreAccounts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StoreAccount storeAccount = this.StoreAccountManager.Get <StoreAccount>().Single(m => m.StoreAccountId == id);

            if (storeAccount == null)
            {
                return(HttpNotFound());
            }
            return(View(storeAccount));
        }
コード例 #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            StoreAccount storeAccount = this.StoreAccountManager.Get <StoreAccount>().Single(m => m.StoreAccountId == id);

            if (storeAccount.CreditCards.Any())
            {
                ModelState.AddModelError(string.Empty, "Credit Cards exist. Delete these first");
                return(this.View(storeAccount));
            }

            this.StoreAccountManager.Delete(storeAccount);
            this.StoreAccountManager.Save();
            return(RedirectToAction("Index"));
        }
コード例 #11
0
        public ActionResult Edit([Bind(Include = "UserIdentityName,FirstName,LastName,TelephoneNo,Address,City,PostCode,CountryId,EmailAddress,ShoppingCartId, StoreAccountId")] StoreAccount storeAccount)
        {
            if (ModelState.IsValid)
            {
                var storeAccountToUpdate = this.StoreAccountManager.Get <StoreAccount>().Single(m => m.StoreAccountId == storeAccount.StoreAccountId);

                if (this.TryUpdateModel(storeAccountToUpdate, string.Empty, new [] { "FirstName", "LastName", "TelephoneNo", "Address", "City", "PostCode", "CountryId", "EmailAddress" }))
                {
                    this.StoreAccountManager.Save();
                    return(RedirectToAction("Index"));
                }
            }
            this.PopulateCountriesDropDownList(storeAccount.CountryId);
            this.PopulateUsersDropDownList(storeAccount.UserIdentityName);
            return(View(storeAccount));
        }
コード例 #12
0
        // GET: StoreAccounts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            StoreAccount storeAccount = this.StoreAccountManager.Get <StoreAccount>().Single(m => m.StoreAccountId == id);

            if (storeAccount == null)
            {
                return(HttpNotFound());
            }
            this.PopulateCountriesDropDownList(storeAccount.CountryId);
            this.PopulateUsersDropDownList(storeAccount.UserIdentityName);
            return(View(storeAccount));
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "UserIdentityName,FirstName,LastName,TelephoneNo,Address,City,PostCode,CountryId,EmailAddress")] StoreAccount storeAccount)
        {
            try
            {
                var storeAccountExists =
                    this.StoreAccountManager.Get <StoreAccount>()
                    .Any(
                        m => m.UserIdentityName == storeAccount.UserIdentityName);

                if (storeAccountExists)
                {
                    ModelState.AddModelError(string.Empty, "StoreAccount already exists");
                    return(RedirectToAction("Index"));
                }

                var storeAccountExist =
                    this.StoreAccountManager.Get <StoreAccount>()
                    .FirstOrDefault(m => m.UserIdentityName == storeAccount.UserIdentityName);

                if (storeAccountExist != null)
                {
                    this.ModelState.AddModelError(
                        string.Empty,
                        "Store Account for " + storeAccountExist.UserIdentityName + " already exists.");
                }

                if (ModelState.IsValid)
                {
                    this.StoreAccountManager.Add(storeAccount);
                    this.StoreAccountManager.Save();
                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException)
            {
                // Log the error (uncomment dex variable name and add a line here to write a log.)
                this.ModelState.AddModelError(
                    string.Empty,
                    "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }

            this.PopulateCountriesDropDownList(storeAccount.CountryId);
            this.PopulateUsersDropDownList(storeAccount.UserIdentityName);
            return(View(storeAccount));
        }
コード例 #14
0
        public StoreAccount Save(StoreAccount storeAccount)
        {
            storeAccount.IsValid();

            DO.StoreAccount result;

            var storeAccountDO = new DO.StoreAccount(storeAccount);

            var account = accRepository.Get(storeAccountDO.Account.Code);

            if (account.IsNull())
            {
                throw new ArgumentException("Usuário não encontrado");
            }

            var store = storeRepository.Get(storeAccountDO.Store.Code);

            if (store.IsNull())
            {
                throw new ArgumentException("Loja não encontrada");
            }

            var link = storeAccountRepository.Get(storeAccountDO.Store.Code, storeAccountDO.Account.Code);

            if (!link.IsNull())
            {
                throw new ArgumentException("O usuário já possui vínculo com a loja");
            }

            storeAccountDO.Account     = null;
            storeAccountDO.Store       = null;
            storeAccountDO.AccountCode = account.Code;
            storeAccountDO.StoreCode   = store.Code;

            using (var transaction = Connection.BeginTransaction())
                result = storeAccountRepository.Save(storeAccountDO);

            return(new DTO.StoreAccount(result));
        }
コード例 #15
0
        private void LoadAccountsForStore()
        {
            if (ResultStore == null || AccountsList == null)
            {
                return;
            }
            StoreAccountsList.Clear();
            foreach (var account in AccountsList.Where(a => a.AccountsStoreDetailsSets.Any(s => s.AccountStore == ResultStore.StoreNumber)))
            {
                var storeAccount = new StoreAccount();
                var status       = account.AccountsStatusDetailsSets.LastOrDefault();
                var capexes      = account.AccountsCapexInfoSets;

                storeAccount.AccountAmount = account.AccountAmount.Value;
                if (capexes != null)
                {
                    var i = 1;
                    foreach (var capex in capexes)
                    {
                        if (i == capexes.Count)
                        {
                            storeAccount.AccountCapex += capex.AccountCapexName;
                        }
                        else
                        {
                            storeAccount.AccountCapex += capex.AccountCapexName + ";";
                        }
                        i++;
                    }
                }
                storeAccount.AccountCompany     = account.AccountCompany;
                storeAccount.AccountDate        = account.AccountDate;
                storeAccount.AccountDescription = account.AccountDescription;
                storeAccount.AccountNumber      = account.AccountNumber;
                storeAccount.AccountStatus      = status.AccountStatus;
                storeAccount.AccountStatusDate  = status.AccountStatusDate;
                StoreAccountsList.Add(storeAccount);
            }
        }
コード例 #16
0
        public IEnumerable <FsFileStatusPage> ListFilesPaged(StoreAccount store, FsPath path, ListFilesOptions options)
        {
            string after = null;

            while (true)
            {
                var result = RestClient.FileSystem.ListFileStatus(store.Name, path.ToString(), options.PageSize, after);

                if (result.FileStatuses.FileStatus.Count > 0)
                {
                    var page = new FsFileStatusPage();
                    page.Path = path;

                    page.FileItems = result.FileStatuses.FileStatus.Select(i => new FsFileStatus(i)).ToList();
                    yield return(page);

                    after = result.FileStatuses.FileStatus[result.FileStatuses.FileStatus.Count - 1].PathSuffix;
                }
                else
                {
                    break;
                }
            }
        }
コード例 #17
0
 public void Move(StoreAccount store, FsPath src_path, FsPath dest_path)
 {
     this.RestClient.FileSystem.Rename(store.Name, src_path.ToString(), dest_path.ToString());
 }
コード例 #18
0
        public void Concat(StoreAccount store, IEnumerable <FsPath> src_paths, FsPath dest_path)
        {
            var src_file_strings = src_paths.Select(i => i.ToString()).ToList();

            this.RestClient.FileSystem.Concat(store.Name, dest_path.ToString(), src_file_strings);
        }
コード例 #19
0
 public void Append(StoreAccount store, FsFileStatusPage file, System.IO.Stream steamContents)
 {
     this.RestClient.FileSystem.Append(store.Name, file.ToString(), steamContents);
 }
コード例 #20
0
 public System.IO.Stream Open(StoreAccount store, FsPath path, long offset, long bytesToRead)
 {
     return(this.RestClient.FileSystem.Open(store.Name, path.ToString(), bytesToRead, offset));
 }
コード例 #21
0
 public System.IO.Stream Open(StoreAccount store, FsPath path)
 {
     return(this.RestClient.FileSystem.Open(store.Name, path.ToString()));
 }
コード例 #22
0
 public void RemoveDefaultAcl(StoreAccount store, FsPath path)
 {
     this.RestClient.FileSystem.RemoveDefaultAcl(store.Name, path.ToString());
 }
コード例 #23
0
        public void SetAcl(StoreAccount store, FsPath path, IEnumerable <FsAclEntry> entries)
        {
            var s = FsAclEntry.EntriesToString(entries);

            this.RestClient.FileSystem.SetAcl(store.Name, path.ToString(), s);
        }
コード例 #24
0
 public void ModifyAclEntries(StoreAccount store, FsPath path, FsAclEntry entry)
 {
     this.RestClient.FileSystem.ModifyAclEntries(store.Name, path.ToString(), entry.ToString());
 }
コード例 #25
0
        public ContentSummary GetContentSummary(StoreAccount store, FsPath path)
        {
            var summary = this.RestClient.FileSystem.GetContentSummary(store.Name, path.ToString());

            return(summary.ContentSummary);
        }
コード例 #26
0
        public FsFileStatus GetFileStatus(StoreAccount store, FsPath path)
        {
            var info = RestClient.FileSystem.GetFileStatus(store.Name, path.ToString());

            return(new FsFileStatus(info.FileStatus));
        }
コード例 #27
0
 public void Create(StoreAccount store, FsPath path, System.IO.Stream streamContents, CreateFileOptions options)
 {
     RestClient.FileSystem.Create(store.Name, path.ToString(), streamContents, options.Overwrite);
 }
コード例 #28
0
 public void Delete(StoreAccount store, FsPath path, bool recursive)
 {
     var result = RestClient.FileSystem.Delete(store.Name, path.ToString(), recursive);
 }
コード例 #29
0
 public void Mkdirs(StoreAccount store, FsPath path)
 {
     var result = RestClient.FileSystem.Mkdirs(store.Name, path.ToString());
 }
コード例 #30
0
 public void SetOwner(StoreAccount store, FsPath path, string owner, string group)
 {
     this.RestClient.FileSystem.SetOwner(store.Name, path.ToString(), owner, group);
 }