Beispiel #1
0
        public ActionResult CreateStorage()
        {
            // Creates the Storage View Model for the Edit form
            var storageVM = new StorageVM()
            {
                Types = GetStorageTypes()
            };

            return(View(storageVM));
        }
        public ActionResult UpdateStorage(int id)
        {
            StorageVM svm = new StorageVM
            {
                Storage           = sRep.Find(id),
                StorageCategories = cRep.GetActives(),
                Suppliers         = supRep.GetActives()
            };

            return(View(svm));
        }
        public ActionResult AddStorage()
        {
            StorageVM svm = new StorageVM
            {
                Storage           = new Storage(),
                StorageCategories = cRep.GetActives(),
                Suppliers         = supRep.GetActives()
            };

            return(View(svm));
        }
        // GET: Manager/Storage
        public ActionResult StorageList(int?page)
        {
            StorageVM svm = new StorageVM
            {
                PagedStorages = sRep.GetAll().ToPagedList(page ?? 1, 15)
            };

            if (true)
            {
                TempData["stoID"] = true;
            }
            return(View(svm));
        }
Beispiel #5
0
        private StorageVM GetStorageVM(int?storageId)
        {
            var storages       = this.db.Storages.ToArray();
            var startStorageDB = storages.FirstOrDefault(x => x.Id == storageId);

            var startStorageVM = new StorageVM()
            {
                Id          = startStorageDB.Id,
                Name        = startStorageDB.Name,
                Address     = startStorageDB.Address,
                StorageType = startStorageDB.StorageType.Type,
                MapAddress  = startStorageDB.MapAddress
            };

            return(startStorageVM);
        }
Beispiel #6
0
        public ActionResult EditStorage(int storageId)
        {
            //Gets the selected storage from the database
            var storageDB = db.Storages.Find(storageId);

            // Creates the Storage View Model for the Edit form
            var storageVM = new StorageVM()
            {
                Id         = storageDB.Id,
                Name       = storageDB.Name,
                Address    = storageDB.Address,
                MapAddress = storageDB.MapAddress,
                Types      = GetStorageTypes()
            };

            return(View(storageVM));
        }
Beispiel #7
0
        public ActionResult CreateStorage(StorageVM storageVM)
        {
            Storage storageDb = new Storage();

            storageDb.Name          = storageVM.Name;
            storageDb.Address       = storageVM.Address;
            storageDb.MapAddress    = storageVM.MapAddress;
            storageDb.StorageTypeId = int.Parse(storageVM.TypeId);

            if (ModelState.IsValid)
            {
                db.Storages.Add(storageDb);
                db.SaveChanges();
                ViewBag.SuccessMessage = "Успешен запис!";
                return(View("~/Views/Shared/SuccessPage.cshtml"));
            }

            storageVM.Types = GetStorageTypes();
            return(View(storageVM));
        }
Beispiel #8
0
        public ActionResult EditStorage(StorageVM storage)
        {
            //Gets the edited storage
            var storageDB = db.Storages.Find(storage.Id);

            //Passes the new data to the dbModel
            storageDB.Name          = storage.Name;
            storageDB.Address       = storage.Address;
            storageDB.MapAddress    = storage.MapAddress;
            storageDB.StorageTypeId = int.Parse(storage.TypeId);

            if (ModelState.IsValid)
            {
                db.Entry(storageDB).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.SuccessMessage = "Успешен запис!";
                return(View("~/Views/Shared/SuccessPage.cshtml"));
            }

            storage.Types = GetStorageTypes();
            return(View(storage));
        }
Beispiel #9
0
        public ActionResult ListStorages()
        {
            //Gets all the storages
            var storagesDB = this.db.Storages.ToArray();

            //Creates an empty list of storages used in the view
            List <StorageVM> storagesList = new List <StorageVM>();

            //Fills the list with the data from the database
            for (int i = 0; i < storagesDB.Count(); i++)
            {
                var storageVM = new StorageVM()
                {
                    Id            = storagesDB[i].Id,
                    Name          = storagesDB[i].Name,
                    Address       = storagesDB[i].Address,
                    MapAddress    = storagesDB[i].MapAddress,
                    StorageType   = storagesDB[i].StorageType.Type,
                    WholeQuantity = GetStorageQuantity(storagesDB[i].Id)
                };
                storagesList.Add(storageVM);
            }
            return(View(storagesList));
        }
Beispiel #10
0
 public StoragePage()
 {
     InitializeComponent();
     DataContext = new StorageVM();
 }
Beispiel #11
0
        public async Task <IActionResult> IndexAsync(DateTime datum)
        {
            if (!_db.StorageDB.Any())
            {
                // await geListTickersAsync();
                var comp = ProcessCSV("constituents.csv");
                foreach (var item in comp)
                {
                    //Dohvatanje detaljnih podataka za iste
                    var client2  = new HttpClient();
                    var request2 = new HttpRequestMessage
                    {
                        Method     = HttpMethod.Get,
                        RequestUri = new Uri(@"https://apidojo-yahoo-finance-v1.p.rapidapi.com/stock/v2/get-summary?symbol=" + item.Symbol + "&region=US"),
                        Headers    =
                        {
                            { "x-rapidapi-key",  "59cd2485cemshf72578d1ef3ac2ap106076jsncc6280cf1332" },
                            { "x-rapidapi-host", "apidojo-yahoo-finance-v1.p.rapidapi.com"            },
                        },
                    };
                    System.Threading.Thread.Sleep(1000);
                    using (var response2 = await client2.SendAsync(request2))
                    {
                        response2.EnsureSuccessStatusCode();
                        var details = await response2.Content.ReadAsStringAsync();

                        Root2 financije2 = JSONSerializerWrapper.Deserialize <Root2>(details);
                        //Pohrana u bazu podataka
                        if (financije2.summaryProfile != null && financije2.price != null)
                        {
                            StorageDB s = new StorageDB()
                            {
                                symbol            = item.Symbol,
                                CompanyName       = item.Name,
                                numberOfEmployees = financije2.summaryProfile.fullTimeEmployees,
                                City      = financije2.summaryProfile.city,
                                State     = financije2.summaryProfile.country,
                                MarketCap = financije2.price.marketCap.longFmt
                            };
                            _db.StorageDB.Add(s);
                            _db.SaveChanges();
                        }
                    }
                }
            }

            List <Storage> podaci = new List <Storage>();

            if (!_db.FinanceStorageDB.Any(x => x.Datum.Year == datum.Year && x.Datum.Month == datum.Month && x.Datum.Day == datum.Day))
            {
                foreach (var item in _db.StorageDB)
                {
                    try
                    {
                        //Uzimanje samo onih kompanija, koje imaju "historical finanace" na odabrani datum
                        var h = await YahooFinanceApi.Yahoo.GetHistoricalAsync(item.symbol, new DateTime(datum.Year, datum.Month, datum.Day), new DateTime(datum.Year, datum.Month, datum.Day).AddDays(1), Period.Daily);

                        foreach (var candle in h)
                        {
                            podaci.Add(new Storage
                            {
                                OpenPrice  = candle.Open,
                                ClosePrice = candle.Close,
                                Datum      = candle.DateTime,
                                ID         = item.ID
                            });
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                for (int i = 0; i < podaci.Count; i++)
                {
                    FinanceStorageDB f = new FinanceStorageDB
                    {
                        OpenPrice   = podaci[i].OpenPrice,
                        ClosePrice  = podaci[i].ClosePrice,
                        Datum       = podaci[i].Datum,
                        StorageDBId = podaci[i].ID
                    };
                    _db.FinanceStorageDB.Add(f);
                    _db.SaveChanges();
                }
            }

            //Dohvatanje podataka iz baze podataka
            StorageVM model = new StorageVM();

            model.podaci = _db.FinanceStorageDB
                           .Include(i => i.StorageDB)
                           .Where(i => i.Datum.Year == datum.Year && i.Datum.Month == datum.Month && i.Datum.Day == datum.Day)
                           .Select(n => new StorageVM.Rows
            {
                symbol            = n.StorageDB.symbol,
                CompanyName       = n.StorageDB.CompanyName,
                numberOfEmployees = n.StorageDB.numberOfEmployees,
                City       = n.StorageDB.City,
                State      = n.StorageDB.State,
                MarketCap  = n.StorageDB.MarketCap,
                ClosePrice = n.ClosePrice,
                OpenPrice  = n.OpenPrice,
                Datum      = n.Datum
            })
                           .ToList();

            return(View(model));
        }