Ejemplo n.º 1
0
 public void AddAssetToDb()
 {
     assets = use.AddProductToDb();
     context.Assets.AddRange(assets);
     context.SaveChanges();
     Console.WriteLine("Data Added");
 }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
0
        public ActionResult Create(AssetStatus assetstatus)
        {
            if (ModelState.IsValid)
            {
                db.AssetStatuses.Add(assetstatus);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assetstatus));
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 5
0
        public ActionResult Create(Software software)
        {
            if (ModelState.IsValid)
            {
                db.Softwares.Add(software);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(software));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 8
0
        public ActionResult Create(OSSystem ossystem)
        {
            if (ModelState.IsValid)
            {
                db.OSSystems.Add(ossystem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

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

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

            return(View(workstationtype));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 17
0
        /*
         * 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();
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 19
0
        public static void Add(AssetType assType)
        {
            var context = new AssetContext();

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

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

            context.Vendors.Add(ven);
            context.SaveChanges();
        }
Ejemplo n.º 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();
    }
Ejemplo n.º 23
0
        // 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.
        }
Ejemplo n.º 25
0
        public static void addAssetType(AssetType type)
        {
            var context = new AssetContext();

            context.AssetTypes.Add(type);
            context.SaveChanges();
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 27
0
        // Adds department to the system
        public static void Add(Department dept)
        {
            var context = new AssetContext();

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

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

            context.Assets.Add(asset);
            context.SaveChanges();
        }
Ejemplo n.º 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();
        }