public void AddAssetToDb()
 {
     assets = use.AddProductToDb();
     context.Assets.AddRange(assets);
     context.SaveChanges();
     Console.WriteLine("Data Added");
 }
        public IActionResult ActivateCurrency(int id)
        {
            var selectedCurrency = _context.Currencies.Where(a => a.Id == id).FirstOrDefault();

            selectedCurrency.CurrencyActive = true;
            _context.Update(selectedCurrency);
            _context.SaveChanges();
            return(RedirectToAction(nameof(DeactivatedCurrencies)));
        }
        public ActionResult Create(AssetStatus assetstatus)
        {
            if (ModelState.IsValid)
            {
                db.AssetStatuses.Add(assetstatus);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assetstatus));
        }
Exemple #4
0
 public ActionResult Create(Asset asset)
 {
     if (ModelState.IsValid)
     {
         db.Assets.Add(asset);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     GenerateFormSelectData(asset.AssetID);
     return(View(asset));
 }
Exemple #5
0
        public ActionResult Create(Software software)
        {
            if (ModelState.IsValid)
            {
                db.Softwares.Add(software);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(software));
        }
Exemple #6
0
        public ActionResult Create([Bind(Include = "ID,Code,Name,Exchange,Currency,Category")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                db.Stocks.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stock));
        }
Exemple #7
0
        public ActionResult Create([Bind(Include = "ID,Cash,Stock,Reits,ETF,Bond,Property,Loan,Debt,CPFOrdinary,CPFMedisave,CPFSpecial,Amount,RecordDate")] AssetHistory assetHistory)
        {
            if (ModelState.IsValid)
            {
                db.AssetHistories.Add(assetHistory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assetHistory));
        }
Exemple #8
0
        public ActionResult Create(OSSystem ossystem)
        {
            if (ModelState.IsValid)
            {
                db.OSSystems.Add(ossystem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ossystem));
        }
Exemple #9
0
        public ActionResult Create(Building building)
        {
            if (ModelState.IsValid)
            {
                db.Buildings.Add(building);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(building));
        }
        public ActionResult Create(WorkStationType workstationtype)
        {
            if (ModelState.IsValid)
            {
                db.WorkStationTypes.Add(workstationtype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(workstationtype));
        }
Exemple #11
0
        public ActionResult Create(Branch branch)
        {
            if (ModelState.IsValid)
            {
                db.Branches.Add(branch);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DivisionID = new SelectList(db.Divisions, "DivisionID", "DivisionName", branch.DivisionID);
            return(View(branch));
        }
Exemple #12
0
        public ActionResult Create([Bind(Include = "ID,StockID,Amount")] Profit profit)
        {
            if (ModelState.IsValid)
            {
                db.Profits.Add(profit);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StockID = new SelectList(db.Stocks, "ID", "Code", profit.StockID);
            return(View(profit));
        }
Exemple #13
0
        public ActionResult Create([Bind(Include = "CashType,BankName,BankAccountName,BankAccountNo,Currency,Amount,MaturityDate")] Cash cash)
        {
            if (ModelState.IsValid)
            {
                cash.UpdatedDate = DateTime.Now;
                db.Cash.Add(cash);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cash));
        }
Exemple #14
0
        public ActionResult Create([Bind(Include = "ID,StockID,Amount,PayDate")] Divident divident)
        {
            if (ModelState.IsValid)
            {
                db.Dividents.Add(divident);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StockID = new SelectList(db.Stocks.OrderBy(o => o.Name).ToList(), "ID", "Name", divident.StockID);
            return(View(divident));
        }
Exemple #15
0
        public ActionResult Create(AssetType assettype)
        {
            if (ModelState.IsValid)
            {
                db.AssetTypes.Add(assettype);
                assettype.CreatedOn     = DateTime.Now;
                assettype.LastUpdatedOn = DateTime.Now;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assettype));
        }
Exemple #16
0
        public ActionResult Create([Bind(Include = "ID,StockID,Quantity,Cost")] Portfolio portfolio)
        {
            if (ModelState.IsValid)
            {
                portfolio.Stock = (from o in db.Stocks where o.ID == portfolio.StockID select o).FirstOrDefault();
                db.Portfolios.Add(portfolio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StockID = new SelectList(db.Stocks.OrderBy(o => o.Name).ToList(), "ID", "Name", portfolio.StockID);
            return(View(portfolio));
        }
        /*
         * This method is removing a product.
         * It takes one parameter, user choice of product: 1 is a computer and 2 is a phone.
         * Then another method is showing all products and user selects product id.
         * Selected product is removed from database.
         */
        private void RemoveProduct(int choice)
        {
            if (choice == 1)
            {
                if (context.Computers.Any())
                {
                    ShowAllComputers();
                    Console.WriteLine("\nWhich computer do you want to remove? ");
                    int computerID = int.Parse(Console.ReadLine());
                    var computer   = context.Computers.Find(computerID);
                    if (computer != null)
                    {
                        context.Computers.Remove(computer);
                        Console.WriteLine("Computer removed");
                    }
                    else
                    {
                        Console.WriteLine($"There is no computer with the id: {computerID} ");
                    }
                }
                else
                {
                    Console.WriteLine("There is no computers in database.");
                }
            }
            else
            {
                if (context.Phones.Any())
                {
                    ShowAllPhones();
                    Console.WriteLine("\nWhich phone do you want to remove? ");
                    int phoneID = int.Parse(Console.ReadLine());
                    var phone   = context.Phones.Find(phoneID);
                    if (phone != null)
                    {
                        context.Phones.Remove(phone);
                        Console.WriteLine("Phone removed");
                    }
                    else
                    {
                        Console.WriteLine($"There is no computer with the id {phoneID} ");
                    }
                }
                else
                {
                    Console.WriteLine("There is no phones in database.");
                }
            }

            context.SaveChanges();
        }
Exemple #18
0
 public ActionResult Create(Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Employees.Add(employee);
         //var currentTime = DateTime.Now;
         //employee.CreatedOn = currentTime;
         //employee.LastUpdatedOn = currentTime;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     CreateEmployeeDropDowns();
     CreateDivisionArray();
     return(View(employee));
 }
        public static void Add(AssetType assType)
        {
            var context = new AssetContext();

            context.AssetTypes.Add(assType);
            context.SaveChanges();
        }
Exemple #20
0
        // Adds asset category to the system
        public static void Add(AssetCategory aCat)
        {
            var context = new AssetContext();

            context.AssetCategories.Add(aCat);
            context.SaveChanges();
        }
        // Adds vendor to the system
        public static void Add(Vendor ven)
        {
            var context = new AssetContext();

            context.Vendors.Add(ven);
            context.SaveChanges();
        }
Exemple #22
0
    public static void InitData(AssetContext context)
    {
        var rnd = new Random();

        var adjectives = new [] { "Tiny", "Average", "Large", "Humungus" };
        var materials  = new [] { "Paper", "Wooden", "Concrete", "Plastic", "Granite", "Rubber" };
        var names      = new [] { "Tank", "Ship", "Submarine", "Interceptor", "Helicopter", "Transport" };
        var services   = new [] { "Army", "Navy", "Air Force" };

        context.Assets.AddRange(50.Times(x =>
        {
            var adjective = adjectives[rnd.Next(0, 4)];
            var material  = materials[rnd.Next(0, 5)];
            var name      = names[rnd.Next(0, 6)];
            var service   = services[rnd.Next(0, 3)];
            var assetId   = $"{x, -3:000}";

            return(new Asset
            {
                AssetNumber = $"{service.First()}{name.First()}{assetId}",
                Name = $"{adjective} {material} {name}",
                Price = (double)rnd.Next(10000, 200000000),
                Service = service
            });
        }));

        context.SaveChanges();
    }
        // Adds employee to the system
        public static void Add(Employee emp)
        {
            var context = new AssetContext();

            context.Employees.Add(emp);
            context.SaveChanges();
        }
        /// <summary>
        /// Inserts a new record into the "Asset" table of the database.
        /// </summary>
        /// <param name="asset">Asset object containing information entered by the user.</param>
        public static void Add(Asset asset)
        {
            var context = new AssetContext(); // Declares the database context.

            context.Assets.Add(asset);        //Adds the object to the database context.
            context.SaveChanges();            //Saves changes to the context, thereby updating the underlying database as well.
        }
Exemple #25
0
        public static void addAssetType(AssetType type)
        {
            var context = new AssetContext();

            context.AssetTypes.Add(type);
            context.SaveChanges();
        }
Exemple #26
0
        private async Task SwitchOwnership(string ContractAddress)
        { //replace the ownership upon the asset - buyer = new owner
            string               PublicKeySeller, PublicKeyNewOwner;
            DappAccount          account          = RegulatorController._regulator;
            SmartContractService deployedContract = new SmartContractService(account, ContractAddress);
            var report = (from d in _AssetInContractsContext.AssetsInContract
                          where d.ContractAddress == ContractAddress
                          select d).Single();

            PublicKeySeller   = report.SellerPublicKey;
            PublicKeyNewOwner = await deployedContract.getNewAssetOwner();

            Asset dealAsset = await deployedContract.getAssetDestails();

            int dealAssetID = dealAsset.AssetID;
            var PublicKeyNewOwnerToCheck = report.BuyerPublicKey.ToLower();


            if (PublicKeyNewOwnerToCheck.Equals(PublicKeyNewOwner))
            {
                PublicKeyNewOwner = report.BuyerPublicKey;
                int newOwnerID = await GetAddressID(PublicKeyNewOwner);

                var report2 = (from d in _AssetsContext.Assets
                               where d.AssetID == dealAssetID
                               select d).Single();
                report2.OwnerPublicKey = PublicKeyNewOwner;
                report2.Price          = dealAsset.Price;
                report2.OwnerID        = newOwnerID;
                _AssetsContext.Assets.Update(report2);
                _AssetsContext.SaveChanges();
            }
        }
        // Adds department to the system
        public static void Add(Department dept)
        {
            var context = new AssetContext();

            context.Departments.Add(dept);
            context.SaveChanges();
        }
        public static void Update(AssetType assetType)
        {
            var context = new AssetContext();

            context.AssetTypes.Update(assetType);
            context.SaveChanges();
        }
Exemple #29
0
        public static void Add(Asset asset)
        {
            var context = new AssetContext();

            context.Assets.Add(asset);
            context.SaveChanges();
        }
Exemple #30
0
        // Updates provided asset category
        public static void Update(AssetCategory aCat)
        {
            var context      = new AssetContext();
            var existingACat = context.AssetCategories.SingleOrDefault(ac => ac.Id == aCat.Id);

            existingACat.Name = aCat.Name;
            context.SaveChanges();
        }