public IHttpActionResult GetLatestByZone(int shareId, int?zoneId)
        {
            Ticker t = null;

            try
            {
                if (!zoneId.HasValue)
                {
                    t = new TickerBLL(_unit).GetLastTicker(shareId, null);
                }
                else
                {
                    var z = new ZoneBLL(_unit).GetByID(zoneId.Value);

                    t = new TickerBLL(_unit).GetLastTicker(shareId, z.TradingDate);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(t));
        }
Esempio n. 2
0
        public IActionResult DeleteZone(int IDNumber)
        {
            ZoneBLL zoneBll = new ZoneBLL();

            zoneBll.DeleteZone(IDNumber);
            return(RedirectToAction("Index"));
        }
        public void Test_GetList()
        {
            ZoneBLL tbll = new ZoneBLL(_unit);

            List <Zone> zList = tbll.GetList().ToList();

            Assert.IsTrue(zList.Count > 0);
        }
Esempio n. 4
0
        public IActionResult UpdateZone(string Owner, string Town, int IDNumber)
        {
            ZoneBLL zoneBLL = new ZoneBLL();

            zoneBLL.UpdateZone(Owner, Town, IDNumber);

            return(RedirectToAction("ZoneDetails", new { ID = IDNumber }));
        }
        public void Test_Delete()
        {
            ZoneBLL tbll = new ZoneBLL(_unit);

            List <Zone> zList = tbll.GetList().ToList();

            Zone zone = tbll.GetByID(zList[0].Id);

            tbll.Delete(zone.Id);
        }
        public void Test_GetById()
        {
            ZoneBLL tbll = new ZoneBLL(_unit);

            List <Zone> zList = tbll.GetList().ToList();

            Zone zone = tbll.GetByID(zList[0].Id);

            Assert.IsTrue(zone.Id > 0);
        }
Esempio n. 7
0
        public IActionResult ZoneDetails(int id)
        {
            ZoneBLL zoneBLL = new ZoneBLL();
            Zone    zone    = zoneBLL.GetZone(id);

            if (zone == null)
            {
                NotFound();
            }
            return(View(zone));
        }
        public void Test_Update()
        {
            ZoneBLL tbll = new ZoneBLL(_unit);

            List <Zone> zList = tbll.GetList().ToList();

            Zone zone = tbll.GetByID(zList[0].Id);

            zone.Note        = "udpate note on " + DateTime.Now.ToLongTimeString();
            zone.TradingDate = 20150101;
            tbll.Update(zone);
        }
Esempio n. 9
0
        public IActionResult UpdateZone(int IDNumber)
        {
            ZoneBLL zoneBLL = new ZoneBLL();
            Zone    zone    = zoneBLL.GetZone(IDNumber);

            if (zoneBLL == null)
            {
                NotFound();
            }

            return(View(zone));
        }
Esempio n. 10
0
        public void Test_Create()
        {
            ZoneBLL tbll = new ZoneBLL(_unit);

            Zone w = new Zone
            {
                Name        = "First Test Zone",
                Description = "Test Zone for main system",
                Owner       = "system",
                StartDate   = new DateTime(2015, 01, 01),
                TradingDate = 20150101,
                Status      = "Active",
                Note        = "test note"
            };

            tbll.Create(w);
        }
Esempio n. 11
0
        public IActionResult AddZone(
            string Owner,
            string Town)
        {
            ZoneBLL zone = new ZoneBLL();

            if (Owner != null)
            {
                zone.Add(
                    Town,
                    Owner);

                return(RedirectToAction("Index"));
            }

            return(View("AddZone"));
        }
        public async Task <IHttpActionResult> Get()
        {
            List <Zone> zlist = null;

            try
            {
                ZoneBLL bll = new ZoneBLL(_unit);

                zlist = bll.GetList().ToList();
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(zlist));
        }
        public IHttpActionResult GetNextByZone(int shareId, int?zoneId)
        {
            Ticker t = null;

            try
            {
                if (zoneId.HasValue)
                {
                    var z           = new ZoneBLL(_unit).GetByID(zoneId.Value);
                    int tradingDate = (int)(new IndicatorBLL(_unit)).GetNextTradingDate(z.TradingDate);
                    t = new TickerBLL(_unit).GetTickerByDate(shareId, tradingDate);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(t));
        }
        public async Task <IHttpActionResult> GetNextDayZone(int zoneId)
        {
            Zone         nextdayZone = null;
            TradeManager tm          = new TradeManager(_unit);

            try
            {
                var currentUser = await GetCurrentUser();

                ZoneBLL bll = new ZoneBLL(_unit);

                nextdayZone = bll.SetZoneNextDay(zoneId);
                tm.ProcessAccountsByZone(currentUser.Id, zoneId);
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }

            return(Ok(nextdayZone));
        }
        public async Task <IHttpActionResult> Delete(int id)
        {
            try
            {
                var currentUser = await GetCurrentUser();

                ZoneBLL bll = new ZoneBLL(_unit);

                bool isAdmin = await AppUserManager.IsInRoleAsync(currentUser.Id, "Admin");

                if (isAdmin)
                {
                    bll.Delete(id);
                }
                else
                {
                    var z = bll.GetByID(id);

                    if (z.Owner == currentUser.Id)
                    {
                        bll.Delete(id);
                    }
                    else
                    {
                        BadRequest("You don't have permission to delete this watch list.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }


            return(Ok());
        }
Esempio n. 16
0
        public void Test_SetZoneNextDay()
        {
            ZoneBLL tbll = new ZoneBLL(_unit);

            var nZone = tbll.SetZoneNextDay(2);
        }